PyBaMM icon indicating copy to clipboard operation
PyBaMM copied to clipboard

Add more doctests to PyBaMM

Open Saransh-cpp opened this issue 2 years ago • 2 comments

Description

It would be nice to have examples in docstrings that are tested periodically. For example, the Simulation class could have something like this -

>>> spm = pybamm.lithium_ion.SPM()
<some output>
>>> sim = pybamm.Simulation(spm)
<some output>
>>> sim.solve([0, 10, 2])
<some output>

Motivation

Would make minor examples available in the documentation itself and would make sure that the docs are not outdated.

Possible Implementation

No response

Additional context

No response

Saransh-cpp avatar Mar 23 '22 04:03 Saransh-cpp

Hey @Saransh-cpp , Can i work on this issue?

parthxtripathi avatar Mar 23 '22 08:03 parthxtripathi

Yes! Go ahead! (Multiple people can work on this)

Saransh-cpp avatar Mar 23 '22 08:03 Saransh-cpp

Close or keep open @Saransh-cpp ?

valentinsulzer avatar Sep 27 '22 01:09 valentinsulzer

With time I have realized that maybe doctests are not that feasible for PyBaMM. Most of PyBaMM's functionality is designed to integrate together (if I am not wrong), which makes it a bit tough to write standalone (and short) doctests. For instance, writing doctests for solve would require building a simple model first. Also, the doctests added after the creation of this issue do not test anything substantial, so I think it should be okay to close this issue (?)

Saransh-cpp avatar Sep 27 '22 17:09 Saransh-cpp

Yeah, I agree

valentinsulzer avatar Sep 27 '22 17:09 valentinsulzer