-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
Fixes #3441 call processed variables with custom spatial coordinates #3472
Closed
Saswatsusmoy
wants to merge
10
commits into
pybamm-team:develop
from
Saswatsusmoy:Saswatsusmoy-#3441-Call-processed-variables-with-custom-spatial-coordinates
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
19c159c
Updated processed_variable.py
Saswatsusmoy 2f38dff
Updated processed_variable_computed.py
Saswatsusmoy a270a48
Added tests to test_processed_variable_computed.py
Saswatsusmoy 843b4bf
style: pre-commit fixes
pre-commit-ci[bot] d21dc24
Added tests to test_processed_variable.py
Saswatsusmoy 369034f
style: pre-commit fixes
pre-commit-ci[bot] 78a2ee6
Merge branch 'pybamm-team:develop' into Saswatsusmoy-#3441-Call-proce…
Saswatsusmoy bbc63df
style: pre-commit fixes
pre-commit-ci[bot] aa338d9
Merge branch 'pybamm-team:develop' into Saswatsusmoy-#3441-Call-proce…
Saswatsusmoy 22caa58
Merge branch 'develop' into Saswatsusmoy-#3441-Call-processed-variabl…
arjxn-py File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you improve the tests so they actually tests that the variables are passed correctly? At the moment it only checks that no error message is thrown.
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.
Something like this? @brosaplanella
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 was thinking something more PyBaMM specific. Maybe something like this example (
PyBaMM/tests/unit/test_solvers/test_processed_variable.py
Lines 139 to 163 in 369034f
a
and try both passinga
to see it works and passingb
to check it throws an error.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.
def call_func(t=None, a=None, b=None): if a is not None: return a + 1 elif b is not None: return b + 2 else: return np.array([0])
`class TestProcessedVariableComputedCalls(unittest.TestCase):
def test_call_kwargs(self):
var = pybamm.Variable("var")
a = pybamm.InputParameter("a")
model = pybamm.BaseModel()
geom = pybamm.Geometry()
mesh = pybamm.Mesh(geom)
var.mesh = mesh
Something like this? @brosaplanella
The key changes are:
Define a simple call_func that takes kwargs
Create a dummy model/variable/solution
Convert the variable to casadi function
Create the ProcessedVariableComputed
Test calling it with correct and incorrect kwargs
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 think so. Note that you want
a
to be aSpatialVariable
rather than anInputParameter
because the latter needs to be passed at solving stage.