-
Notifications
You must be signed in to change notification settings - Fork 105
Raise Warning if the Capacity Array is Not Set But mapc2p is #752
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
base: master
Are you sure you want to change the base?
Conversation
…the capacity array and its index is set when mapc2p is also set. - added method is_mapped_solution_valid to check whether every state has a valid mapping at runtime.
|
I'd like to see this implemented following the pattern we use everywhere else:
This ensures that higher level code doesn't need to know details about the object it is using. If mapc2p is set, you should check that the capacity index is set to an integer between zero and num_aux - 1, inclusive. |
…tern in all objects - implemented the is_mapped_state_valid method from state class to is_valid so only the is_valid function is used to check for validity
|
I hope this is better now. I added the checks to the is_valid method from the state object and removed the new method from the solution object. I also added instructions the the errors to guide the user to the right settings. |
|
This looks good, modulo one comment I left above. Have you tested this? It would be great to include a test in the PR. |
|
I would happly add a unittests. The questions is where should I add it to? I can only see regression tests in you test folder |
- the fixture is taken from the example advection_2d_annulus to get a minial setup to test the validity of the state
|
@ketch I added a unit test to the test folder. I added it into a folder called unittest to not interfere with the current test structure. I took the setup from the example mentioned in the issue #614 to get a valid setup to run the tests. I included every possible error in the tests to check whether every error is reached at the right time. I know that the project currently just tests via regression tests or tests the example separately, but I would propose to include this test and maybe expand unit testing to be sure about new code coming into the project. It also could be included in GitHub Actions or pre-hooks. |
Changes:
The names of the methods are debatable. I tried to I adapt to the existing structure.
Also the ValueError can be exchanged to Warnings or bools. Depending on want you all want.
Raising an ValueError seemed more logical, because the program should break, when the mapping isn't valid, but can go through when no mapping isn't present. That's why I used the boolean there.
To give out logging with a boolean value seems a little bit outdated. I can also introduce errorhandling somewhere, but I'm not sure where it should be. Maybe that should be done when a simulation is created.