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.
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
Issue #1320 Add CopyFiles package #1321
Issue #1320 Add CopyFiles package #1321
Changes from 6 commits
0606aed
5585cbb
fad5851
8977eab
7d5e03f
1d211c9
e38befd
404ec6e
8c89944
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why does this class inherit from the MetaSwapPackage?
It seems like a really general class. I don't know how it is being used but is it possible to use composition over inheritance?
If it is possible to have this class without MetaSwapPackage as its parent class then you also don't need xarray as the data container and you have a member variable that is a list of paths
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 thought about that, my main reason why I decided to inherit MetaSwapPackage is that it makes the package object function consistently to other packages. For instance, we have plans to create a
MetaSwapModel.dump
method, which would dump all packages to file. To have a functional MetaSWAP model, we also need to store the paths to files that need to be copied somewhere. So by wrenching this list of strings/paths in a xarray Dataset, I'm quite sure no special-cased logic is required for this specific filecopy package and keeps things stored consistently in NetCDFs, instead of some custom textfile.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.
Why are you using curly brackets and not block brackets? I thought curly brackets are only for dictionaries, but this seems to be a list.
The same thing occurs on line 39
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.
This is a Python builtin type
set
. Sets are very useful to check values in iterables for uniqueness. And if one set contains values not present, or present, in another set. For docs, see: https://docs.python.org/3/library/stdtypes.html#setI wanted to make this more explicit by doing
set([Path(p[0]) for p in paths])
, but Ruff disagreed with me. I guess the Ruff devs think the set is common knowledge as it is a Python builtin (though a bit more niche).