-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Sliceable MetaData Class #455
Conversation
Refactor involved moving comments and axes out of the core values and putting them into their own dictionaries. This removed cascading consequences for self.values(), self.__setitem__, etc.
Hello @DanRyanIrish! Thanks for updating this PR.
Comment last updated at 2021-11-18 14:32:19 UTC |
Also put in overwrite error check to Meta.__setitem__ if axis is not None. This way the value shape and axes cannot easily be corrupted accidentally.
Only store entries in the comments and axes dicts that aren't None. This saves a lot of space and requires the get method be used when looking for comment and axes values to avoid errors is that key doesn't have a comment or axis.
@nabobalis Could you give this PR a review? It should be very similar if not the same as what's in your sunraster PR. |
@Cadair this PR is ready for review. To pre-empt possible concerns regarding DKIST tools, the introduction of this new class does not require that metadata be sliceable. Instead it allows for it if desired. In order for the Not all entries in the Therefore, as far as I understand, this new class should not threaten your assumption in the DKIST tools that |
@Cadair, this is ready to merge as far as I can see. Do you still want more time to look at it given your DKIST concerns? As I above, I don't think this causes an issues as the new functionalities are optional and don't have to change previous behaviour. |
ping @Cadair. A friendly reminder for a review on this PR :) |
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.
Can't see any major issues.
Co-authored-by: Stuart Mumford <[email protected]>
59e2b75
to
db18ebb
Compare
@nabobalis Can you interpret this doc error for me? |
I think you need to add the warning to the nitpick-exceptions file so something like this but no 100% sure of the syntax.
|
Description
This PR introduces a sliceable
Meta
class based ondict
, which allows metadata to be associated with data axes and the whole class to be sliced using the normal Python slicing API. Metadata not associated with any axes is not touched by the slicing mechanism.This PR introduces two types of axis-aware metadata: axis-aligned and grid-aligned. Axis-aligned metadata gives one value for each of its associated axes, and is scalar or a string if only associated with one axis. This type of metadata is only changed if the axis/axes within which it is associated is dropped by slicing. In this case, the values corresponding to the dropped axes are also dropped.
Grid-aligned metadata provides a value for each data array element in its associated axis/axes. This metadata cannot be scalar. Since this metadata mirrors at least part of the data array, it is sliced as if it were data, and its shape is kept consistent with its associated data axes. If all its axes are sliced away, the scalar value at the row/column location at which it was sliced is kept, and its axis-awareness is dropped, i.e. it becomes a piece of normal non-axis-aware scalar metadata.
API Summary
To Do
__delitem__
and removeremove
method.NDMeta.data_shape
which verifies that it's compatible with pre-existing axis- and grid-aligned metadata.