Skip to main content

A collection of miscellaneous python utilities

Project description

PyPI PyPI - Downloads

Checks Coverage

GitHub commit activity GitHub closed pull requests code size, bytes

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 with ZANJ
  • statcounter is an extension of collections.Counter that provides "smart" computation of stats (mean, variance, median, other percentiles) from the counter object without using Counter.elements()
  • misc contains a few utilities:
    • stable_hash() uses hashlib.sha256 to compute a hash of an object that is stable across runs of python
    • sanitize_fname() takes any string and makes it only alphanumeric plus - and _
    • shorten_numerical_to_str() turns numbers like 123456789 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 property
  • logger implements a logger with "streams" and a timer context manager
  • jsonlines extremely simple utility for reading/writing jsonl files
  • ZANJ is a WIP hdf5 alternative. This will probably be has 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!

installation

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]

todos:

  • option to have notebook conversion create pytest-compatible tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muutils-0.5.8.tar.gz (72.9 kB view hashes)

Uploaded Source

Built Distribution

muutils-0.5.8-py3-none-any.whl (86.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page