muutils
, stylized as "$\mu$utils" or "μutils", is a collection of miscellaneous python utilities, meant to be small and with no dependencies outside of standard python.
json_serialize
is a tool for serializing and loading arbitrary python objects into json. plays nicely withZANJ
statcounter
is an extension ofcollections.Counter
that provides "smart" computation of stats (mean, variance, median, other percentiles) from the counter object without usingCounter.elements()
misc
contains a few utilities:stable_hash()
useshashlib.sha256
to compute a hash of an object that is stable across runs of pythonsanitize_fname()
takes any string and makes it only alphanumeric plus-
and_
shorten_numerical_to_str()
turns numbers like123456789
into"123M"
- a couple other things
- [
nbutils
] (WIP) contains some utilities for working in notebooks (printing latex nicely) and also running notebooks as tests in CI by converting them to python scripts - [
tensor_utils
] contains minor utilities for working with pytorch tensors and numpy arrays. This needs to be moved into ZANJ, probably group_equiv
groups elements from a sequence according to a given equivalence relation, without assuming that the equivalence relation obeys the transitive propertylogger
implements a logger with "streams" and a timer context managerjsonlines
extremely simple utility for reading/writingjsonl
filesZANJ
is a WIP hdf5 alternative. Thiswill probably behas been spun off into its own repo
There are a couple work-in-progress utilities in _wip
that aren't ready for anything, but nothing in this repo is suitable for production. Use at your own risk!
PyPi: muutils
pip install muutils
Note that for using mlutils
, tensor_utils
, nbutils.configure_notebook
, or the array serialization features of json_serialize
, you will need to install with optional array
dependencies:
pip install muutils[array]
- option to have notebook conversion create pytest-compatible tests