Utility functions#

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(keys: str | list[str], print_values: bool = False)[source]#

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

Parameters:
  • keys (str or list of str) – Search term(s)

  • print_values (bool, optional) – If True, print both keys and values. Otherwise, print only keys. Default is False.

pybamm.load(filename)[source]#

Load a saved object

pybamm.has_jax()[source]#

Check if jax and jaxlib are installed with the correct versions

Returns:

True if jax and jaxlib are installed with the correct versions, False if otherwise

Return type:

bool

pybamm.is_jax_compatible()[source]#

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

Returns:

True if jax and jaxlib are compatible with PyBaMM, False if otherwise

Return type:

bool

pybamm.set_logging_level(level)[source]#

Set the logging level for PyBaMM

Parameters:

level (str) – The logging level to set. Should be one of ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’