Utility functions

pybamm.get_git_commit_info()[source]

Get the git commit info for the current PyBaMM version, e.g. v22.8-39-gb25ce8c41 (version 22.8, commit b25ce8c41)

pybamm.rmse(x, y)[source]

Calculate the root-mean-square-error between two vectors x and y, ignoring NaNs

pybamm.root_dir()[source]

return the root directory of the PyBaMM install directory

class pybamm.Timer[source]

Provides accurate timing.

Example

timer = pybamm.Timer() print(timer.time())

reset()[source]

Resets this timer’s start time.

time()[source]

Returns the time (float, in seconds) since this timer was created, or since meth:reset() was last called.

class pybamm.TimerTime(value)[source]
class pybamm.FuzzyDict[source]
copy() a shallow copy of D[source]
get_best_matches(key)[source]

Get best matches from keys

search(key, print_values=False)[source]

Search dictionary for keys containing ‘key’. If print_values is True, then both the keys and values will be printed. Otherwise just the values will be printed. If no results are found, the best matches are printed.

pybamm.load_function(filename, funcname=None)[source]

Load a python function from an absolute or relative path using importlib. Example - pybamm.load_function(“pybamm/input/example.py”)

Parameters:
  • filename (str) – The path of the file containing the function.

  • funcname (str, optional) – The name of the function in the file. If None, assumed to be the same as the filename (ignoring the path)

Returns:

The python function loaded from the file.

Return type:

function

pybamm.load(filename)[source]

Load a saved object

pybamm.get_parameters_filepath(path)[source]

Returns path if it exists in current working dir, otherwise get it from package dir

pybamm.have_julia()[source]

Checks whether the Julia programming language has been installed

pybamm.have_jax()[source]

Check if jax and jaxlib are installed with the correct versions

pybamm.is_jax_compatible()[source]

Check if the available version of jax and jaxlib are compatible with PyBaMM