Utilities¶
Utility functions for handling files and plotting data.
- ionworkspipeline.util.subplots_autolayout(n, *args, n_rows=None, figsize=None, layout='constrained', **kwargs)¶
Create a subplot element
- ionworkspipeline.util.export_python_script(parameter_values, filename, data_path=None)¶
Print a python script that can be used to reproduce the parameter set
Parameters¶
- parameter_valuesiwp.ParameterValues
The parameter valyes to export
- filenamestring
The name to save the parameter set under
- data_pathstring, optional
The path to the where to look for data, e.g. when loading using PyBaMM’s process_parameter_data functions. If None, then data will be looked for in the same directory as the exported file. Default is None.
- ionworkspipeline.util.exp_safe(x)¶
Safe exponential function that avoids overflow.
- ionworkspipeline.util.square_safe(x)¶
Safe square function that avoids overflow.
- ionworkspipeline.util.FunctionPrefactor(function, prefactor)¶
Wrapper for a function that, when called, multiplies the original function output by a prefactor.
Parameters¶
- functioncallable
The function to wrap.
- prefactorfloat, int, or pybamm.Parameter
The prefactor to multiply the output of the function by.
Examples¶
>>> def my_function(x): >>> return x**2 >>> my_function_prefactor = FunctionPrefactor(my_function, 2) >>> my_function_prefactor(3) >>> 18