Add NDCube._extra_attrs_to_copy for subclass attribute propagation#940
Open
nabobalis wants to merge 1 commit into
Open
Add NDCube._extra_attrs_to_copy for subclass attribute propagation#940nabobalis wants to merge 1 commit into
nabobalis wants to merge 1 commit into
Conversation
Subclasses can declare instance attributes that are automatically propagated (by reference) to cubes derived through _new_instance (arithmetic operations) and through to_nddata when the target type is a subclass carrying the same attributes. This removes the need for subclasses to override both methods just to keep domain-specific metadata alive on derived cubes. Slicing is deliberately not covered, as shape-dependent attributes cannot be sliced generically.
7bc1534 to
278b965
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Description
Subclasses can declare instance attributes that are automatically propagated (by reference) to cubes derived through _new_instance (arithmetic operations) and through to_nddata when the target type is a subclass carrying the same attributes. This removes the need for subclasses to override both methods just to keep domain-specific metadata alive on derived cubes. Slicing is deliberately not covered, as shape-dependent attributes cannot be sliced generically.
This is a controversial change and due to something I have to do in irispy as I have attached (to Stuart's horror) lots of new attrs to make my life easier.
I think this will not be merged in, and the fix is for me to attach more of the attrs into the metadata instead.
AI Assistance Disclosure
AI tools were used for: