A collection of utilities to make it easier to interact with scipy in a marimo notebook, e.g. manipulate distributions, visualize data, etc.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 marimo_scipy_utils-0.1.2.tar.gz.
File metadata
- Download URL: marimo_scipy_utils-0.1.2.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b237b704deed866c58e859ff9449fa1fd87eb24fba2759dcfffec48d3b250408
|
|
| MD5 |
4eb45fcaae628cc80811fcd19a7ad896
|
|
| BLAKE2b-256 |
65793a229a94bbbcaaac89642f91d9b7af51af3740c5d4b47b913f793ba2afed
|
Provenance
The following attestation bundles were made for marimo_scipy_utils-0.1.2.tar.gz:
Publisher:
publish.yml on hbmartin/marimo-scipy-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marimo_scipy_utils-0.1.2.tar.gz -
Subject digest:
b237b704deed866c58e859ff9449fa1fd87eb24fba2759dcfffec48d3b250408 - Sigstore transparency entry: 278894768
- Sigstore integration time:
-
Permalink:
hbmartin/marimo-scipy-utils@f3961bc61f77d5a40f326d4672b8cd1271f7a1ea -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/hbmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3961bc61f77d5a40f326d4672b8cd1271f7a1ea -
Trigger Event:
release
-
Statement type:
File details
Details for the file marimo_scipy_utils-0.1.2-py3-none-any.whl.
File metadata
- Download URL: marimo_scipy_utils-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd33e7f137a1f95e5f3eafb1a5cbddcf5940baa35b2fd6a1b166e2e08ee5f80b
|
|
| MD5 |
97dd1c31551d3004fe6695dd23c5ed07
|
|
| BLAKE2b-256 |
6bdccac1b7784660cecd93427f3652590ed3479f286f23d18e7ea28626ea6f70
|
Provenance
The following attestation bundles were made for marimo_scipy_utils-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on hbmartin/marimo-scipy-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marimo_scipy_utils-0.1.2-py3-none-any.whl -
Subject digest:
cd33e7f137a1f95e5f3eafb1a5cbddcf5940baa35b2fd6a1b166e2e08ee5f80b - Sigstore transparency entry: 278894809
- Sigstore integration time:
-
Permalink:
hbmartin/marimo-scipy-utils@f3961bc61f77d5a40f326d4672b8cd1271f7a1ea -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/hbmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3961bc61f77d5a40f326d4672b8cd1271f7a1ea -
Trigger Event:
release
-
Statement type: