Skip to content

Commit

Permalink
Merge pull request #3600 from pybamm-team/doctest-conf
Browse files Browse the repository at this point in the history
configure doctest so we don't have to import pybamm
  • Loading branch information
valentinsulzer authored Dec 8, 2023
2 parents 32fad00 + 20a9492 commit 93c265b
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

doctest_global_setup = """
from docs import *
import pybamm
"""

# Add any paths that contain templates here, relative to this directory.
Expand Down
1 change: 0 additions & 1 deletion pybamm/citations.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Citations:
Examples
--------
>>> import pybamm
>>> pybamm.citations.register("Sulzer2021")
>>> pybamm.citations.register("@misc{Newton1687, title={Mathematical...}}")
>>> pybamm.print_citations("citations.txt")
Expand Down
8 changes: 6 additions & 2 deletions pybamm/expression_tree/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,12 @@ def set_id(self):
need to hash once.
"""
self._id = hash(
(self.__class__, self.name, *tuple([child.id for child in self.children]), *tuple([(k, tuple(v)) for k, v in self.domains.items() if v != []]))
(
self.__class__,
self.name,
*tuple([child.id for child in self.children]),
*tuple([(k, tuple(v)) for k, v in self.domains.items() if v != []]),
)
)

@property
Expand Down Expand Up @@ -532,7 +537,6 @@ def pre_order(self):
Examples
--------
>>> import pybamm
>>> a = pybamm.Symbol('a')
>>> b = pybamm.Symbol('b')
>>> for node in (a*b).pre_order():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Thevenin(pybamm.BaseModel):
Examples
--------
>>> import pybamm
>>> model = pybamm.equivalent_circuit.Thevenin()
>>> model.name
'Thevenin Equivalent Circuit Model'
Expand Down
1 change: 0 additions & 1 deletion pybamm/models/full_battery_models/lithium_ion/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class DFN(BaseModel):
Examples
--------
>>> import pybamm
>>> model = pybamm.lithium_ion.DFN()
>>> model.name
'Doyle-Fuller-Newman model'
Expand Down
1 change: 0 additions & 1 deletion pybamm/models/full_battery_models/lithium_ion/mpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class MPM(SPM):
Examples
--------
>>> import pybamm
>>> model = pybamm.lithium_ion.MPM()
>>> model.name
'Many-Particle Model'
Expand Down
1 change: 0 additions & 1 deletion pybamm/models/full_battery_models/lithium_ion/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class SPM(BaseModel):
Examples
--------
>>> import pybamm
>>> model = pybamm.lithium_ion.SPM()
>>> model.name
'Single Particle Model'
Expand Down
1 change: 0 additions & 1 deletion pybamm/models/full_battery_models/lithium_ion/spme.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class SPMe(SPM):
Examples
--------
>>> import pybamm
>>> model = pybamm.lithium_ion.SPMe()
>>> model.name
'Single Particle Model with electrolyte'
Expand Down
4 changes: 1 addition & 3 deletions pybamm/parameters/parameter_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ class ParameterSets(Mapping):
.. doctest::
>>> import pybamm
>>> list(pybamm.parameter_sets)
['Ai2020', 'Chen2020', ...]
Get the docstring for a parameter set:
.. doctest::
>>> import pybamm
>>> print(pybamm.parameter_sets.get_docstring("Ai2020"))
<BLANKLINE>
Parameters for the Enertech cell (Ai2020), from the papers :footcite:t:`Ai2019`,
Expand All @@ -44,7 +42,7 @@ def __init__(self):
@staticmethod
def get_entries(group_name):
# Wrapper for the importlib version logic
if sys.version_info < (3, 10): # pragma: no cover
if sys.version_info < (3, 10): # pragma: no cover
return importlib.metadata.entry_points()[group_name]
else:
return importlib.metadata.entry_points(group=group_name)
Expand Down
1 change: 0 additions & 1 deletion pybamm/parameters/parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ParameterValues:
Examples
--------
>>> import pybamm
>>> values = {"some parameter": 1, "another parameter": 2}
>>> param = pybamm.ParameterValues(values)
>>> param["some parameter"]
Expand Down

0 comments on commit 93c265b

Please sign in to comment.