-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
Fixed issue #3724 #3726
Fixed issue #3724 #3726
Conversation
Documentation added for pybamm.Experiment.read_termination
pybamm/experiment/experiment.py
Outdated
def read_termination(self, termination): | ||
""" | ||
Read the termination reason. If this condition is hit, the experiment will stop. | ||
|
||
Parameters | ||
---------- | ||
termination : list[str], optional | ||
A single string, or a list of strings, representing the conditions to terminate the experiment. | ||
Only capacity or voltage can be provided as a termination reason. | ||
e.g. '4 Ah capacity' or ['80% capacity', '2.5 V'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to say that the type is a list[str]
then we should enforce that as well. The signature can be changed to def read_termination(self, termination: list[str]):
and the check for the termination being a single string can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at the moment we accept both a string and a list, which is probably not ideal but there quite a few other methods work like this and changing them at the moment is a big change.
For context, this PR from Jon was to test the pre-workshop exercise instructions we are giving attendees of our next Hackathon. To ensure they know how to use Github we ask them to add a docstring somewhere and open a PR (this way we improve documentation too).
I think probably the best solution for the moment would be to write
termination : str or list[str], optional
which reflects current use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this was only to update documentation that is fine, but I would say we should open a ticket for making it just a list[str]
. Long term it reduces code complexity to support only a single type of input for interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is always good to clean up as we go, even for easy PRs
Updated the documentation based on the discussion so that the argument passed to read_termination is of type str or list[str]
…into Workshop2024_SJC
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3726 +/- ##
========================================
Coverage 99.59% 99.59%
========================================
Files 257 257
Lines 20802 20806 +4
========================================
+ Hits 20718 20722 +4
Misses 84 84 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks Jon!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing my requested changes after discussion with @brosaplanella
I do think we should make a ticket to only support list[str]
for the type though. It makes interfaces much nicer when there is only 1 input type and requires less error handling. For users this just requires putting [] around their single strings, so it is not a huge change.
@all-contributors please add @jonchapman1 for docs |
I've put up a pull request to add @jonchapman1! 🎉 |
* Fixed issue pybamm-team#3724 Documentation added for pybamm.Experiment.read_termination * Issue pybamm-team#3724 Updated the documentation based on the discussion so that the argument passed to read_termination is of type str or list[str] --------- Co-authored-by: Ferran Brosa Planella <[email protected]> Co-authored-by: Agriya Khetarpal <[email protected]> Co-authored-by: Robert Timms <[email protected]>
Documentation added for pybamm.Experiment.read_termination
Description
Testing the workflow for participants of the developed training workshop in April 2024 to get used to contributing with simple fixes in advance of the workshop. I added documentation for pybamm.Experiment.read_termination
Fixes #3724
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python run-tests.py --all
(or$ nox -s tests
)$ python run-tests.py --doctest
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ python run-tests.py --quick
(or$ nox -s quick
).Further checks: