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

Corrects "electrode diffusivity" error catch #4267

Merged
merged 10 commits into from
Jul 23, 2024

Conversation

BradyPlanden
Copy link
Member

@BradyPlanden BradyPlanden commented Jul 15, 2024

Description

This reverts an incorrect change applied in #4179. This adds to the error catch for the old parameter name "{domain} electrode diffusivity [m2.s-1]" to use the new name, likewise if the new name "{domain} particle diffusivity [m2.s-1]" is provided the error catch uses the old name.

I've confirmed it fixes the MWE in #4176, and currently works with the old parameter name within PyBOP. A quick MWE to test this fix is below:

import pybamm
# create the model
model = pybamm.lithium_ion.DFN()

# set the default model parameters
param = model.default_parameter_values

# use both parameter names
neg_old = param["Negative electrode diffusivity [m2.s-1]"] = 2.0
pos_new = param["Positive particle diffusivity [m2.s-1]"] = 2.0
assert neg_old == pos_new

Fixes #4176

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

@BradyPlanden BradyPlanden requested a review from a team as a code owner July 15, 2024 18:37
Copy link

codecov bot commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.45%. Comparing base (668e563) to head (77e6a9c).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4267   +/-   ##
========================================
  Coverage    99.45%   99.45%           
========================================
  Files          288      288           
  Lines        22089    22092    +3     
========================================
+ Hits         21969    21972    +3     
  Misses         120      120           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thanks, @BradyPlanden – just one question since this was deprecated before the v24.1 release cycle and thus with the release of v24.1 (but incorrectly as far as I understand), so the plan would have been to remove it in v25.1 (three releases). Since the behaviour change is being made "not breaking" now but has existed beforehand, when should/could this be deprecated? It would help reduce the code for dependents like PyBOP where it has caused much trouble, I assume, so there's a case to be made for deprecating earlier.

pybamm/util.py Outdated Show resolved Hide resolved
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
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.

Seems fine

@kratman kratman merged commit ce407ae into pybamm-team:develop Jul 23, 2024
26 checks passed
kratman added a commit that referenced this pull request Jul 23, 2024
* fix: error catch for electrode diffusivity

* refactor: update diffusivity error catch and test

* tests: up coverage for diffusivity name catches

* Update pybamm/util.py

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Ferran Brosa Planella <Ferran.Brosa-Planella@warwick.ac.uk>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
@kratman kratman mentioned this pull request Jul 23, 2024
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
* fix: error catch for electrode diffusivity

* refactor: update diffusivity error catch and test

* tests: up coverage for diffusivity name catches

* Update pybamm/util.py

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>

---------

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Co-authored-by: Ferran Brosa Planella <Ferran.Brosa-Planella@warwick.ac.uk>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants