-
-
Notifications
You must be signed in to change notification settings - Fork 594
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 support for time series temperature in an experiment step #4855
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4855 +/- ##
===========================================
- Coverage 98.70% 98.70% -0.01%
===========================================
Files 304 304
Lines 23432 23459 +27
===========================================
+ Hits 23129 23155 +26
- Misses 303 304 +1 ☔ View full report in Codecov by Sentry. |
if isinstance(temperature_and_units, np.ndarray): | ||
if temperature_and_units.ndim == 2 and temperature_and_units.shape[1] == 2: | ||
# Assume first column is time (s) and second column is temperature (K) | ||
times = temperature_and_units[:, 0] | ||
temps = temperature_and_units[:, 1] | ||
# Create an interpolant function parameter that depends on time | ||
return pybamm.Interpolant(times, temps, pybamm.t, interpolator="linear") | ||
else: | ||
raise ValueError( | ||
"Temperature time-series must be a 2D array with two columns (time, temperature)." | ||
) |
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.
Can you write a test for this. Sometimes it is easiest to cover error handling code by extracting a smaller function and using that in the tests. You can make the if-else block a helper function, then covering it in tests should be easy
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.
yeah sure, I'll add a test for it
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've added the tests
Can I get a review on this? |
Description
Added support for time series temperature in an experiment step, now it can be passed something like this:
Fixes #4200
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)
Important checks:
Please confirm the following before marking the PR as ready for review:
nox -s pre-commit
nox -s tests
nox -s doctests