-
Notifications
You must be signed in to change notification settings - Fork 41
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
Cache flag-related objects and refactor extraction of flags #520
base: main
Are you sure you want to change the base?
Conversation
If both: Mix of independent and mutually exclusive flags. | ||
""" | ||
if self._flag_dict is not None: | ||
return self._flag_dict |
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.
The problem is that you can change the underlying values in the DataArray and then the flags will be wrong.
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 forgot that if for DataArray.data most operations are not done in place (you get a new DataArray), changing DataArray.attrs
is easily done in place. I only see either checking if any of the attributes have changed, or urging to use DataArray.assign_attrs()
in the documentation...
Nice! Re: API if it is useful to get |
I am not sure I'm following. Something like |
The dictionary of flag values/masks is cached in the CFAccessor, moving the code of
create_flag_dict
into a property of the accessor.The dataset of booleans masks is cached in the CFDataArrayAccessor. I don't know if this is a welcomed change. I would argue that if it is presented as a property (
.flags
), I would expect it to be the same instance on different calls, contrary to a method like.flags()
or.get_flags()
. But I'm not very familiar with the rest of the cf-xarray API. Anyway it can be reverted easily.I have also refactored the construction of that flag dataset to make it (hopefully) more readable and understable. It makes use of the FlagParams named-tuple. The operations on the data are unchanged.