Marimo SciPy Utils
Utility functions for creating interactive marimo components with scipy distributions.
This package provides functions for creating and configuring interactive UI elements in marimo notebooks, with a focus on parameter input and visualization using scipy probability distributions.
Installation
uv add marimo-scipy-utils
Functions
abbrev_format(x: float, pos: int | None) -> str
Format numbers with k/M suffixes for thousands/millions.
Parameters:
x: The number to formatpos: The tick position (unused but required by matplotlib formatter interface)
Returns:
str: The formatted number string with k/M suffix if applicable
Example:
abbrev_format(1500, None) # Returns "2k"
abbrev_format(2500000, None) # Returns "3M"
abbrev_format(42.7, None) # Returns "42.7"
display_sliders(name: str, sliders: mo.ui.dictionary | mo.ui.slider, invars: dict[str, dict], dist: str | Callable | None = None, descriptions: dict = {}) -> mo.Html
Display parameter sliders with optional distribution plot.
Parameters:
name: Name of the parameter group to displaysliders: Either a single slider or dictionary of sliders for distribution paramsinvars: Dictionary to store input variable configurationsdist: Distribution to use (string name or callable), required for multi-slidersdescriptions: Optional dict mapping parameter names to descriptions
Returns:
- Marimo component displaying the sliders and optional distribution plot
For a single slider, displays it as a constant parameter. For multiple sliders, displays them with a plot of the resulting distribution. Distribution must be specified for multiple sliders, either as a string name matching a scipy distribution or as a callable distribution object.
Raises:
DistributionConfigurationError: If dist is None for multiple sliders
generate_ranges(distribution: str, ranged_distkwargs: dict) -> dict
Generate parameter ranges for a probability distribution.
Takes a distribution name and dictionary of parameter ranges, validates the ranges against allowed bounds for that distribution, and returns a merged dictionary with complete range specifications.
Parameters:
distribution: Name of the probability distribution (e.g. "normal", "beta")ranged_distkwargs: Dictionary mapping parameter names to their range specifications. Each range spec should have "lower" and "upper" bounds.
Returns:
dict: Complete parameter range specifications with distribution defaults merged with provided ranges
Raises:
MissingParameterError: If a required parameter range is not providedParameterBoundError: If a provided range exceeds the allowed bounds for a param
params_sliders(ranged_distkwargs: dict) -> mo.ui.dictionary
Create a dictionary of sliders for parameter ranges.
Takes a dictionary of param ranges and creates interactive sliders for each param. The sliders will be bounded by the lower/upper values specified in the ranges dict. The step size and initial value can optionally be specified per param.
Parameters:
ranged_distkwargs: Dictionary mapping parameter names to their range specifications. Each range spec should have "lower" and "upper" bounds, and optionally "step" and "value" keys.
Returns:
mo.ui.dictionary: A dictionary of marimo slider UI elements, one per parameter. Each slider will be configured according to the parameter's range spec.
Example:
ranges = {
"mean": {"lower": 0, "upper": 100, "step": 1, "value": 50},
"std": {"lower": 0, "upper": 10}
}
sliders = params_sliders(ranges)
Supported Distributions
Any scipy distribution can be used.
Included helpers following scipy distributions:
uniform: Uniform distributiontriang: Triangular distributionbeta: Beta distributionnorm: Normal distribution
Dependencies
- marimo
- matplotlib
- scipy
Metadata
Release files for marimo-scipy-utils 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| marimo_scipy_utils-0.1.2.tar.gz | 10.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| marimo_scipy_utils-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.5 kB
Release files / marimo_scipy_utils-0.1.2.tar.gz
| Download URL | marimo_scipy_utils-0.1.2.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b237b704deed866c58e859ff9449fa1fd87eb24fba2759dcfffec48d3b250408
|
|
BLAKE2b-256 checksum How to use checksums |
65793a229a94bbbcaaac89642f91d9b7af51af3740c5d4b47b913f793ba2afed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 16, 2025.
Transparency logRelease files / marimo_scipy_utils-0.1.2-py3-none-any.whl
| Download URL | marimo_scipy_utils-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd33e7f137a1f95e5f3eafb1a5cbddcf5940baa35b2fd6a1b166e2e08ee5f80b
|
|
BLAKE2b-256 checksum How to use checksums |
6bdccac1b7784660cecd93427f3652590ed3479f286f23d18e7ea28626ea6f70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 16, 2025.
Transparency log