Skip to content

Repository files navigation

PyPIPyPI - Downloadsdocs

ChecksChecksCoverage

GitHub commitsGitHub commit activityGitHub closed pull requestscode 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

ModuleDescription
statcounterExtension of collections.Counter with smart stats computation (mean, variance, percentiles)
dictmagicDictionary utilities: dotlist conversion, DefaulterDict, tensor dict condensing
kappaAnonymous getitem (Kappa(lambda x: x**2)[2] returns 4)
sysinfoSystem information collection for logging
miscUtilities: stable_hash, list_join/list_split, filename sanitization, freeze
intervalMathematical intervals (open/closed/half-open) with containment, clamping, set operations
errormodeEnum-based error handling (raise/warn/log/ignore)
validate_typeRuntime type validation for basic and generic types
console_unicodeSafe console output with Unicode/ASCII fallback
spinnerAnimated spinners with elapsed time and status updates
timeit_fancyEnhanced timing with multiple runs, profiling, and statistics
dbgDebug printing inspired by Rust's dbg! macro
collect_warningsContext manager to capture and summarize warnings
parallelSimplified parallel processing with progress bars
jsonlinesSimple jsonl file reading/writing
group_equivGroup elements by equivalence relation (non-transitive)
json_serializeSerialize arbitrary Python objects to JSON (works with ZANJ)
nbutilsJupyter utilities: notebook conversion, configuration, mermaid/TeX display
mathBinning functions and matrix power computation
cliCLI utilities: boolean argument parsing, flag actions
webHTML asset inlining for standalone documents
logger(deprecated) Logging framework, use trnbl instead
mlutilsML pipeline: device detection, seeding, checkpoints (requires array)
tensor_utilsPyTorch/numpy type conversions (requires array)
tensor_infoTensor metadata extraction and formatting (requires array)
mlCUDA 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

Stars

11 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages