Skip to content

collection of miscellaneous python utilities -- including but not limited to serialization, logging, tensor shenanigans, and more

License

Notifications You must be signed in to change notification settings

mivanit/muutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,288 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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!

About

collection of miscellaneous python utilities -- including but not limited to serialization, logging, tensor shenanigans, and more

Topics

Resources

License

Stars

Watchers

Forks

Contributors 6