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

Fixed issue #3724 #3726

Merged
merged 8 commits into from
Feb 5, 2024
Merged

Conversation

jonchapman1
Copy link
Contributor

@jonchapman1 jonchapman1 commented Jan 15, 2024

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.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ 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)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ 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:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Documentation added for pybamm.Experiment.read_termination
Comment on lines 141 to 150
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']
Copy link
Contributor

@kratman kratman Jan 15, 2024

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.

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor

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]
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (705baff) 99.59% compared to head (81578c0) 99.59%.
Report is 3 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@brosaplanella brosaplanella left a 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!

Copy link
Contributor

@kratman kratman left a 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.

@rtimms
Copy link
Contributor

rtimms commented Feb 5, 2024

@all-contributors please add @jonchapman1 for docs

Copy link
Contributor

@rtimms

I've put up a pull request to add @jonchapman1! 🎉

@agriyakhetarpal agriyakhetarpal merged commit c0c00c1 into pybamm-team:develop Feb 5, 2024
44 of 47 checks passed
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants