Skip to main content

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.

PyPI version Python 3.8+ License: MIT

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 distributionsuniform, norm, expon, gamma, beta, lognorm, weibull_min, t, chi2, f, pareto, cauchy, laplace, logistic, rayleigh
  • Distribution aliasesnormalnorm, gaussiannorm, unifuniform
  • DistGraph — automatic dependency resolution via topological sort
  • Arithmetic expressions"60 + 30 * uniform(0, 1)" with sin, cos, exp, sqrt, pi and more
  • Seed management — global seed(), context manager seed_context(), per-instance DistGraph(seed=...)
  • Bounds constraints — annotate parameters with physical limits for downstream validation
  • 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.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

distparser-0.3.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file distparser-0.3.1.tar.gz.

File metadata

  • Download URL: distparser-0.3.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for distparser-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1f12620c8add4b9d707ac72f2acd86f9cb3c2b55772a9eee23907c75fff50971
MD5 2cfdc48f9e7f40fb49212a48ed0eeade
BLAKE2b-256 04ea6aae78f407e63a627e925210daad7a3af9be1fa0943b25220a4f5cc11289

See more details on using hashes here.

File details

Details for the file distparser-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: distparser-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for distparser-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cac9bff57951f27cfef5d053529340465107ac1d0c424589e6d051326d5ee346
MD5 3a724cf8003f36e15947c306421738b5
BLAKE2b-256 f857c6d91a536996cbcbf7dd47e88276b9ef6d958597346a0d305b71ab84d0a0

See more details on using hashes here.

Supported by

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