Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue #1465 Move mask to common utilities #1466

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

Merged
merged 5 commits into from
Feb 28, 2025

Conversation

JoerivanEngelen
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen commented Feb 27, 2025

Fixes #1465

Description

  • Move mask utilities to common utilities.
  • Move aux variable logic to Package.mask and refactor it
  • Move two generic utilities from imod.mf6.utilities.dataset.py to imod.common.utilities.value_filters.py
  • Move generic schemata utility module to common utilities

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example

@@ -575,8 +575,11 @@ def mask(self, mask: GridDataArray) -> Any:
masked: Package
The package with part masked.
"""

return mask_package(self, mask)
result = cast(IPackage, deepcopy(self))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cast necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I otherwise get this error message:

imod\mf6\package.py:580: error: Incompatible types in assignment (expression has type "IPackage", variable has type "Package")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried fixing it, but gave up after an hour, in my search found this interesting post which could clean up interfaces a bit https://levelup.gitconnected.com/python-interfaces-choose-protocols-over-abc-3982e112342e but using Protocols didn't resolve the problem.

remove_expanded_auxiliary_variables_from_dataset(result)
result = mask_package(result, mask)
expand_transient_auxiliary_variables(result)
return result
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the return type? IPackage? Package? The type hint is any. We can be more specific

@JoerivanEngelen JoerivanEngelen merged commit feb0b86 into master Feb 28, 2025
@JoerivanEngelen JoerivanEngelen deleted the issue_#1465_move_mask_to_common_utilities branch February 28, 2025 08:57
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move mask from imod.mf6.utilities to imod.common.utilities
2 participants