Skip to content

Add NDCube._extra_attrs_to_copy for subclass attribute propagation#940

Open
nabobalis wants to merge 1 commit into
sunpy:mainfrom
nabobalis:extra-attrs-to-copy
Open

Add NDCube._extra_attrs_to_copy for subclass attribute propagation#940
nabobalis wants to merge 1 commit into
sunpy:mainfrom
nabobalis:extra-attrs-to-copy

Conversation

@nabobalis

Copy link
Copy Markdown
Member

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:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding
  • No AI tools were used

Regardless of AI use, the human contributor remains fully responsible for correctness, design choices, licensing compatibility, and long-term maintainability.

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.
@nabobalis nabobalis force-pushed the extra-attrs-to-copy branch from 7bc1534 to 278b965 Compare June 11, 2026 21:44
@nabobalis nabobalis marked this pull request as ready for review June 11, 2026 21:44
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.

1 participant