-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Added InputParameter support in PyBamm experiments #4826
Conversation
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.
Thanks for taking this on but this isn't quite what I had in mind, the interface should be:
step = pybamm.step.current(pybamm.InputParameter("I_app"), termination="2.5 V")
experiment = pybamm.Experiment([step])
sim = pybamm.Simulation(..., experiment=experiment)
sim.solve(inputs={"I_app": 1})
made changes, now user can pass input params like this: step = pybamm.step.current(pybamm.InputParameter("I_app"), termination="2.5 V")
experiment = pybamm.Experiment([step])
sim = pybamm.Simulation(..., experiment=experiment)
sim.solve(inputs={"I_app": 1}) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4826 +/- ##
========================================
Coverage 98.70% 98.70%
========================================
Files 304 304
Lines 23432 23452 +20
========================================
+ Hits 23129 23149 +20
Misses 303 303 ☔ View full report in Codecov by Sentry. |
Just a follow up anything else I need to change? |
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.
@Rishab87 thanks for putting this PR together! I left a few comments
The So for this PR, we need to ensure that any termination has an operator, because we cannot make the assumption. We probably want to keep the string parsing available, so a nice syntax would be "{operator} {value} {unit}", e.g. "< 2.5 V". But the operator must be in the termination, not the step. |
@aabills I've made changes accordingly just as you told now operator gets passed in termination like "< 2.5 V". And thanks for explaining about why we need directions in first place and why we need an operator now it helped me a lot while making changes |
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.
Thanks! This is much closer. Just a few more small changes, and make sure you hit coverage.
@aabills thanks for the review I've added the callable case and also added few test cases accordingly to ensure full coverage |
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.
So close! Just one more change and this is good from my side
@aabills I've changed the code and added a check to see if symbol has input params |
Looks good! Fix coverage and you're good to go from my side. @MarcBerliner @valentinsulzer anything else from y'all? |
Oh and don't forget to add something to the CHANGELOG.md |
Also fix this failing integration test. |
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
9084495
@aabills added my PR to changelog and tests for full coverage. Also fixed the integration test |
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 great to me!
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.
Thanks @Rishab87! Looks great
Description
Added InputParameter support in experiments, now you can pass them something like this:
Fixes #4799
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 -m pytest
(or$ nox -s tests
)$ python -m pytest --doctest-plus src
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks: