pybamm.
get_infinite_nested_dict
()[source]¶Return a dictionary that allows infinite nesting without having to define level by level.
Example
>>> import pybamm
>>> d = pybamm.get_infinite_nested_dict()
>>> d["a"] = 1
>>> d["a"]
1
>>> d["b"]["c"]["d"] = 2
>>> d["b"]["c"] == {"d": 2}
True
pybamm.
load_function
(filename)[source]¶Load a python function from a file “function_name.py” called “function_name”. The filename might either be an absolute path, in which case that specific file will be used, or the file will be searched for relative to PyBaMM root.
Parameters: | filename (str) – The name of the file containing the function of the same name. |
---|---|
Returns: | The python function loaded from the file. |
Return type: | function |
pybamm.
rmse
(x, y)[source]¶Calculate the root-mean-square-error between two vectors x and y, ignoring NaNs
pybamm.
Timer
[source]¶Provides accurate timing.
Example
timer = pybamm.Timer() print(timer.format(timer.time()))
format
(time=None)[source]¶Formats a (non-integer) number of seconds, returns a string like “5 weeks, 3 days, 1 hour, 4 minutes, 9 seconds”, or “0.0019 seconds”.
Parameters: | time (float, optional) – The time to be formatted. |
---|---|
Returns: | The string representation of time in human-readable form. |
Return type: | string |