Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running doctests using doctest-plus #4117

Merged
merged 22 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eef52fb
Adding doctest using doctest-plus
prady0t May 29, 2024
1144cb8
Skipping failing tests
prady0t May 29, 2024
1f84179
Merge branch 'develop' into using-doctestplus
kratman May 29, 2024
8863623
Merge branch 'develop' into using-doctestplus
agriyakhetarpal May 30, 2024
b282bb7
Merge branch 'develop' into using-doctestplus
kratman May 30, 2024
d38e2d8
Merge branch 'develop' into using-doctestplus
kratman May 31, 2024
22f6463
Merge branch 'develop' into using-doctestplus
kratman May 31, 2024
e6e7877
Update run-tests.py
prady0t Jun 1, 2024
74730b7
style: pre-commit fixes
pre-commit-ci[bot] Jun 1, 2024
f943852
Merge branch 'develop' into using-doctestplus
kratman Jun 3, 2024
67688d1
Merge branch 'develop' into using-doctestplus
kratman Jun 3, 2024
18893f1
Removing unrelated subprocess
prady0t Jun 5, 2024
cc64fe4
Merge remote-tracking branch 'origin/using-doctestplus' into using-do…
prady0t Jun 5, 2024
06eaf89
style: pre-commit fixes
pre-commit-ci[bot] Jun 5, 2024
3538515
Merge branch 'develop' into using-doctestplus
arjxn-py Jun 5, 2024
e95a4a9
Update docs/source/user_guide/installation/index.rst
prady0t Jun 5, 2024
8284100
Update docs/source/user_guide/installation/index.rst
prady0t Jun 5, 2024
b8286b6
Update pybamm/parameters/parameter_sets.py
prady0t Jun 5, 2024
aa93df1
Merge branch 'develop' into using-doctestplus
agriyakhetarpal Jun 5, 2024
c3be511
Fixing doctest directive
prady0t Jun 6, 2024
0a0b2f0
Merge branch 'develop' into using-doctestplus
prady0t Jun 6, 2024
c20d315
Merge branch 'develop' into using-doctestplus
agriyakhetarpal Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pybamm/expression_tree/operations/latexify.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class Latexify:
>>> model = pybamm.lithium_ion.SPM()

This will returns all model equations in png
>>> model.latexify("equations.png")
>>> model.latexify("equations.png") # doctest: +SKIP

This will return all the model equations in latex
>>> model.latexify()
>>> model.latexify() # doctest: +SKIP

This will return the list of all the model equations
>>> model.latexify(newline=False)
>>> model.latexify(newline=False) # doctest: +SKIP

This will return first five model equations
>>> model.latexify(newline=False)[1:5]
>>> model.latexify(newline=False)[1:5] # doctest: +SKIP
"""

def __init__(self, model, filename: str | None = None, newline: bool = True):
Expand Down
8 changes: 4 additions & 4 deletions pybamm/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,16 +1345,16 @@ def latexify(self, filename=None, newline=True, output_variables=None):
>>> model = pybamm.lithium_ion.SPM()

This will returns all model equations in png
>>> model.latexify("equations.png")
>>> model.latexify("equations.png") # doctest: +SKIP

This will return all the model equations in latex
>>> model.latexify()
>>> model.latexify() # doctest: +SKIP

This will return the list of all the model equations
>>> model.latexify(newline=False)
>>> model.latexify(newline=False) # doctest: +SKIP

This will return first five model equations
>>> model.latexify(newline=False)[1:5]
>>> model.latexify(newline=False)[1:5] # doctest: +SKIP
"""
from pybamm.expression_tree.operations.latexify import Latexify

Expand Down
2 changes: 1 addition & 1 deletion pybamm/models/full_battery_models/lithium_metal/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Doyle-Fuller-Newman (DFN) Model
#
import pybamm
from ..lithium_ion.dfn import DFN as LithiumIonDFN
from pybamm.models.full_battery_models.lithium_ion.dfn import DFN as LithiumIonDFN
arjxn-py marked this conversation as resolved.
Show resolved Hide resolved


class DFN(LithiumIonDFN):
Expand Down
1 change: 1 addition & 0 deletions pybamm/parameters/parameter_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ParameterSets(Mapping):

.. doctest::
prady0t marked this conversation as resolved.
Show resolved Hide resolved

>>> import pybamm
>>> list(pybamm.parameter_sets)
['Ai2020', 'Chen2020', ...]

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ dev = [
"nox",
# For coverage
"pytest-cov",
# For doctest
"pytest-doctestplus",
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
# For test parameterization
"parameterized>=0.9",
# For testing Jupyter notebooks
Expand Down
9 changes: 9 additions & 0 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ def run_doc_tests():
],
check=True,
)
print("Checking for doctests.")
prady0t marked this conversation as resolved.
Show resolved Hide resolved
subprocess.run(
[
"pytest",
"--doctest-plus",
prady0t marked this conversation as resolved.
Show resolved Hide resolved
"pybamm",
],
check=True,
)
except subprocess.CalledProcessError as e:
prady0t marked this conversation as resolved.
Show resolved Hide resolved
print(f"FAILED with exit code {e.returncode}")
sys.exit(e.returncode)
Expand Down
Loading