docs for muutils v0.9.0
View Source on GitHub

muutils

PyPI PyPI - Downloads docs

Checks Checks Coverage

GitHub commits 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.

installation

PyPi: muutils

pip install muutils

Optional dependencies:

pip install muutils[array]    # numpy, torch, jaxtyping -- for mlutils, tensor_utils, tensor_info, ml, json_serialize array features
pip install muutils[notebook] # ipython -- for nbutils.configure_notebook
pip install muutils[parallel] # multiprocess, tqdm -- for parallel processing with progress
pip install muutils[web]      # weasyprint -- for web/html_to_pdf

documentation

https://miv.name/muutils

modules

Module Description
statcounter Extension of collections.Counter with smart stats computation (mean, variance, percentiles)
dictmagic Dictionary utilities: dotlist conversion, DefaulterDict, tensor dict condensing
kappa Anonymous getitem (Kappa(lambda x: x**2)[2] returns 4)
sysinfo System information collection for logging
misc Utilities: stable_hash, list_join/list_split, filename sanitization, freeze
interval Mathematical intervals (open/closed/half-open) with containment, clamping, set operations
errormode Enum-based error handling (raise/warn/log/ignore)
validate_type Runtime type validation for basic and generic types
console_unicode Safe console output with Unicode/ASCII fallback
spinner Animated spinners with elapsed time and status updates
timeit_fancy Enhanced timing with multiple runs, profiling, and statistics
dbg Debug printing inspired by Rust's dbg! macro
collect_warnings Context manager to capture and summarize warnings
parallel Simplified parallel processing with progress bars
jsonlines Simple jsonl file reading/writing
group_equiv Group elements by equivalence relation (non-transitive)
json_serialize Serialize arbitrary Python objects to JSON (works with ZANJ)
nbutils Jupyter utilities: notebook conversion, configuration, mermaid/TeX display
math Binning functions and matrix power computation
cli CLI utilities: boolean argument parsing, flag actions
web HTML asset inlining for standalone documents
logger (deprecated) Logging framework, use trnbl instead
mlutils ML pipeline: device detection, seeding, checkpoints (requires array)
tensor_utils PyTorch/numpy type conversions (requires array)
tensor_info Tensor metadata extraction and formatting (requires array)
ml CUDA memory monitoring (requires array)

ZANJ

ZANJ is a human-readable and simple format for ML models, datasets, and arbitrary objects. It's built around having a zip file with json and npy files, and has been spun off into its own project.

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!


 1"""
 2.. include:: ../README.md
 3"""
 4
 5from __future__ import annotations
 6
 7__all__ = [
 8    # submodules (with sub-submodules)
 9    "json_serialize",
10    "logger",
11    "math",
12    "misc",
13    "nbutils",
14    "web",
15    # submodules
16    "collect_warnings",
17    "console_unicode",
18    "dbg",
19    "dictmagic",
20    "errormode",
21    "group_equiv",
22    "interval",
23    "jsonlines",
24    "kappa",
25    "mlutils",
26    "parallel",
27    "spinner",
28    "statcounter",
29    "sysinfo",
30    "tensor_info",
31    "tensor_utils",
32    "timeit_fancy",
33    "validate_type",
34]