sweepexp.sweepexp.sweepexp#
- sweepexp.sweepexp.sweepexp(func: Callable, parameters: dict[str, list], mode: Literal['sequential', 'parallel', 'mpi'] = 'sequential', save_path: Path | str | None = None, **kwargs: dict) se.SweepExp | se.SweepExpMPI | se.SweepExpParallel[source]#
Create a new instance of the SweepExp class.
Parameters#
- funcCallable
The experiment function to run. The function should take the parameters as keyword arguments and return a dictionary with the return values.
- parametersdict[str, list]
The parameters to sweep over. The keys are the parameter names and the values are lists of the parameter values.
- mode“sequential” | “parallel” | “mpi”, default=”sequential”
The mode to run the experiments in.
- save_pathPath | str | None (optional)
The path to save the results to. Supported file formats are: ‘.zarr’, ‘.nc’, ‘.cdf’, ‘.pkl’. The ‘.zarr’ and ‘.nc’ formats only support numeric and boolean data. Only the ‘.pkl’ format supports saving data of any type.
- **kwargsdict
Additional settings: - timeit: bool, measure the duration of each experiment. - auto_save: bool, automatically save the results after each experiment. - enable_priorities: bool, run experiments with higher priority first. - pass_uuid: bool, pass a unique identifier to the experiment function.
Returns#
- SweepExp | SweepExpMPI | SweepExpParallel
An instance of the appropriate SweepExp class based on the mode.
Examples#
from sweepexp import sweepexp # Create a simple experiment function def my_experiment(x: int, y: float) -> dict: return {"sum": x + y, "product": x * y} # Initialize the sweepexp object sweep = sweepexp( func=my_experiment, parameters={"x": [1, 2, 3], "y": [4, 5, 6]}, ) # Run the sweep sweep.run()