Monaco Dictionary Utils
A Python library for easily bootstrapping Monaco Monte Carlo simulations with a dictionary-based workflow.
Overview
Monaco Dictionary Utils provides a simplified interface for creating and running Monte Carlo simulations using the Monaco framework. It streamlines the process of setting up simulations by allowing you to define model factories, input parameters, and distributions using dictionary-based configuration.
Features
- Dictionary-based configuration: Define simulations using simple dictionary structures
- Model factory support: Create models from factory functions with configurable parameters
- Input variable management: Handle both probabilistic distributions and constants
- Output conversion: Convert simulation results to easily accessible dictionary format
- Parameter normalization: Automatic parameter name normalization for consistency
Installation
uv add monaco-dict-utils
Requirements
- Python ≥ 3.11
- Monaco ≥ 0.16.0
Quick Start
from monaco_dict_utils import sim_factory, outvals_to_dict
# Define your model factory
def my_model_factory(param1, param2):
def model(x, y):
return {"result": x * param1 + y * param2}
return model
# Configure simulation
factory_vars = {"param1": 2, "param2": 3}
invars = {
"x": {"dist": "uniform", "params": {"loc": 0, "scale": 1}},
"y": {"dist": "_constant", "params": 5}
}
# Create and run simulation
sim = sim_factory(
name="my_simulation",
model_factory=my_model_factory,
factory_vars=factory_vars,
invars=invars,
ndraws=1000
)
sim.run()
# Convert outputs to dictionary
results = outvals_to_dict(sim)
API Reference
sim_factory(name, model_factory, factory_vars, invars, ndraws, *, verbose=True, debug=False)
Create a Monte Carlo simulation from a model factory and parameters.
Parameters:
name(str): Name of the simulationmodel_factory(Callable): Factory function that creates the modelfactory_vars(dict): Dictionary of variables to pass to model factoryinvars(dict): Dictionary mapping input names to distribution parametersndraws(int): Number of Monte Carlo draws to simulateverbose(bool, optional): Whether to print simulation progress. Defaults to True.debug(bool, optional): Whether to run in debug mode. Defaults to False.
Returns:
Sim: Configured Monaco Sim object ready to run simulations
Example:
sim = sim_factory(
name="example_sim",
model_factory=my_factory,
factory_vars={"param": 10},
invars={"x": {"dist": "normal", "params": {"loc": 0, "scale": 1}}},
ndraws=5000
)
outvals_to_dict(sim)
Convert simulation output values to a dictionary.
Parameters:
sim(Sim): A Monaco Sim object that has been run
Returns:
dict: Dictionary mapping output variable names to numpy arrays of output values
Example:
results = outvals_to_dict(sim)
# results = {"Result": array([1.23, 4.56, ...]), "Other_Output": array([...])}
Input Variables Configuration
The invars dictionary supports two types of inputs:
1. Probabilistic Distributions
For random variables, specify a distribution and its parameters:
invars = {
"temperature": {
"dist": "normal",
"params": {"loc": 20, "scale": 5}
},
"pressure": {
"dist": "uniform",
"params": {"loc": 10, "scale": 2}
}
}
2. Constants
For constant values, use the special _constant distribution:
invars = {
"gravity": {
"dist": "_constant",
"params": 9.81
},
"config": {
"dist": "_constant",
"params": {"setting1": 100, "setting2": 200}
}
}
Parameter Normalization
The library automatically normalizes parameter names by:
- Converting to lowercase
- Removing special characters
- Replacing spaces with underscores
For example: "Air Temperature" becomes "air_temperature"
Output Formatting
Output values are automatically formatted with:
- Title case conversion
- Underscore preservation
- Example:
"time_savings"becomes"Time_Savings"
Metadata
Release files for monaco-dict-utils 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| monaco_dict_utils-0.1.0.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| monaco_dict_utils-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.1 kB
Release files / monaco_dict_utils-0.1.0.tar.gz
| Download URL | monaco_dict_utils-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa0c997a1a5480a8487c0e047668a3caebcd7b3276d22102e332fa6b1d9db133
|
|
BLAKE2b-256 checksum How to use checksums |
113c1ab278bd2f3ce478a03fc2b33411a75a2850e26e0a3a266f808e42c92d63
|
| 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 / monaco_dict_utils-0.1.0-py3-none-any.whl
| Download URL | monaco_dict_utils-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9ae55ba34c68e5396f2f7cdcb5d338832173230bc268d094d46a991ae2605c0
|
|
BLAKE2b-256 checksum How to use checksums |
5b49aaad78af64fef98decbed8c6d4c70785ddae20e34b7903caee6226781ce6
|
| 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