Parse function-call strings into frozen scipy.stats distributions
Project description
distparser
Parse function‑call strings into frozen scipy.stats distributions —
with dependency resolution, arithmetic expressions, and seed management.
Installation
pip install distparser
Quick Start
import distparser as lib
# Parse a single distribution string
d = lib.parse_dist("norm(loc=0, scale=1)")
print(d.rvs(size=3)) # array([...])
DistGraph — dependency-aware evaluation
from distparser import DistGraph
config = {
"mean": 5.0,
"noise": "norm(0, 0.1)",
"measurement": "mean + noise",
}
graph = DistGraph(config, seed=42)
result = graph.resolve_all()
print(result["measurement"]) # 5.0 + sample from N(0, 0.1)
Features
- 15 built-in distributions —
uniform,norm,expon,gamma,beta,lognorm,weibull_min,t,chi2,f,pareto,cauchy,laplace,logistic,rayleigh - Distribution aliases —
normal→norm,gaussian→norm,unif→uniform - DistGraph — automatic dependency resolution via topological sort
- Arithmetic expressions —
"60 + 30 * uniform(0, 1)"withsin,cos,exp,sqrt,piand more - Seed management — global
seed(), context managerseed_context(), per-instanceDistGraph(seed=...) - Bounds clipping — clamp sampled values with
min/maxorlbound/rbound - Extensible registry — register custom distributions at runtime
Docs
Full documentation at distparser.readthedocs.io.
Development
See AGENTS.md for setup and guidelines.
License
MIT
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
distparser-0.3.2.tar.gz
(13.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file distparser-0.3.2.tar.gz.
File metadata
- Download URL: distparser-0.3.2.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64975bdaa8382081b321ea34ecb28960a7a9f7d42d3b42a25f9c40bd668ecc0a
|
|
| MD5 |
5fe1598b05b96a4bb33a7f1d9cf53d21
|
|
| BLAKE2b-256 |
e17c392745c7f07d1640bfd5ef0575c3e3067a6172da51c505799ec8afae4e8c
|
File details
Details for the file distparser-0.3.2-py3-none-any.whl.
File metadata
- Download URL: distparser-0.3.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c649bfab3cee5bc2863edf783f836dd8e0836fc8c265160002c703f3a921586c
|
|
| MD5 |
4d3d38d6bc0831cb62d014c8eb5bf8b1
|
|
| BLAKE2b-256 |
c32c0025f94b77e660dece0d081240e8667ec4ef21e8df5cdc87d90413244e12
|