Skip to content

I3790 idaklu outvars#3803

Merged
martinjrobins merged 8 commits intopybamm-team:developfrom
jsbrittain:i3790-idaklu-outvars
Feb 22, 2024
Merged

I3790 idaklu outvars#3803
martinjrobins merged 8 commits intopybamm-team:developfrom
jsbrittain:i3790-idaklu-outvars

Conversation

@jsbrittain
Copy link
Contributor

Description

When run with output_variables, the IDAKLU solver does not fail gracefully when requesting a variable that was not specified in the requested variables list. Note that 'model parameters' that do not appear in output_variables should still be returned upon request.

Fixes #3790

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

@jsbrittain jsbrittain marked this pull request as ready for review February 5, 2024 13:28
@codecov
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d201899) 99.60% compared to head (b97af3c) 99.60%.
Report is 40 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3803   +/-   ##
========================================
  Coverage    99.60%   99.60%           
========================================
  Files          258      259    +1     
  Lines        21226    21287   +61     
========================================
+ Hits         21142    21203   +61     
  Misses          84       84           

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

Copy link
Member

@valentinsulzer valentinsulzer 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, though I think Symbol.contains duplicates the existing Symbol.has_symbol_of_classes. Might be worth benchmarking to see which implementation is fastest (I'm guessing contains when there is a match since it returns immediately)

Comment on lines +986 to +997
def contains(self, expr_type):
"""
Does the symbol tree contain a given node type?
"""
if type(self) is expr_type:
return True
elif "children" in dir(self):
for child in self.children:
if child.contains(expr_type):
return True
return False

Copy link
Member

Choose a reason for hiding this comment

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

how is this different from has_symbol_of_classes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tinosulzer I hadn't spotted that method - I've reverted to using has_symbol_of_classes as the more pythonic implementation to avoid duplicating this behaviour.

Copy link
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

looks great, thanks @jsbrittain

Copy link
Member

@valentinsulzer valentinsulzer 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, thanks!

@martinjrobins martinjrobins merged commit 4df6a87 into pybamm-team:develop Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: IDAKLUSolver with output_variables provides accesss to alternative variables

4 participants