-
Notifications
You must be signed in to change notification settings - Fork 6
Issue #1738 add ignore time arguments #1742
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
|
| state_for_boundary : optional, Union[xr.DataArray, xu.UgridDataArray] | ||
| A grids with states that are used to put as boundary values. This | ||
| model will get a :class:`imod.mf6.ConstantHead`. | ||
| ignore_time_purge_empty : bool, default False |
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 find this a very confusing name.
I think that we need to keep the user away from the internals of this method. They shouldn't have to know that packages are being purged.
Would ignore_time_validation work? Or have them provide a ValidationContext?
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.
Legitimate critique. Unfortunately there are already some methods with this argument as name in the public API, so if I change it here, I have to change it everywhere, and keep on supporting the old argument for the next versions to keep the API stable.
Not the end of the world, but perhaps out of scope for this PR?
I want to refrain from letting users provide ValidationContext themselves, as limiting the amount of custom objects users have to create themselves decreases the learning curve for iMOD Python.
| """ | ||
|
|
||
| _mask_all_packages(self, mask) | ||
| mask_all_packages(self, mask, ignore_time_purge_empty) |
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 first thought that this method was calling itself but it is actually calling a utilities method.
Would it be clearer to add the module name to it?:
utitlities.mas. mask_all_packages
Same applies to mask_all_models
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.
Right, that might have been part of the reason the underscore was left there in the first place.
I tried the following:
- Import the utilities module
from imod.common import utilities as common_utilities
...
common_utilities.mask.mask_all_packages(...)Pythons runs this without error, but this was not understood by the linters and VSCode couldn't trace the function for some reason.
- Import the mask utilities module
import imod.common.utilities as utilities
...
def mask_all_packages(mask, ...)
...
mask.mask_all_packages(mask, ...)The function also has mask as argument here, so the module name clashes here with the argument name.
- Import under alias
import imod.common.utilities.mask as mask_utils
...
mask_utils.mask_all_packages(...)This too can lead to confusion, as it can lead to developers looking for a module file/folder named mask_utils which is not present (if they overlook the aliasing in the imports). Given that this way of importing is done nowhere else in the codebase, I deem this confusion quite likely.
- Reference all modules in function call
import imod
...
imod.common.utilities.mask.mask_all_packages(...)Too much clutter in my opinion.
I think I keep it as is in this PR, downside is that developers have to be sharp for the difference between function and method calls here. It appears changing it back to how it was (as a function starting with an underscore) and using it outside the module is a no no in the python world.
| model will get a :class:`imod.mf6.ConstantHead`. | ||
| ignore_time_purge_empty : bool, default False | ||
| Whether to ignore time dimension when purging empty packages. Can | ||
| improve performance when clipping models with many time steps. |
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 this explanation can use some improvement.
Maybe elaborate more on the fact that after clipping packages can become empty e.g. ...
An package is considered empty when ...
This boolean determines if the time dimension is taken into account when determining empty packages
| from imod.tests.fixtures.mf6_modelrun_fixture import assert_simulation_can_run | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("ignore_time", [True, False]) |
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.
In all the test it doesnt matter what the flag does
It would be good to have some tests where the outcome is different depending on the flag



Fixes #1738
Description
Checklist
Issue #nr, e.g.Issue #737pixi run generate-sbomand committed changes