Preserve the concrete type in DD deepcopy - #313
Merged
Conversation
`Base.deepcopy_internal(x::IMAS.DD{T}, dict)` dispatches for every `DD` subtype
but built an `IMAS.dd{T}`, while `fieldnames(typeof(x))` kept walking the
original's fields. Any container other than `IMAS.dd` — e.g. one defined by a
satellite package — therefore came back as an `IMAS.dd`.
A bare `deepcopy(dd)` never reached this: IMASdd's `Base.deepcopy(::DD)` shadows
it. The bug only surfaced when a dd was reached through a container, such as
`deepcopy([dd])` or `FUSE.Checkpoint`'s `getindex`.
Adds test/runtests_satellite.jl, which defines a stand-in satellite container on
top of `IMAS.DD` and runs it through the same assertions as `IMAS.dd`: direct and
nested deepcopy, `_frozen`, and the `_aux[:fxp]` sharing this method exists for.
`deepcopy_internal` had no coverage before — only test_fxp.ipynb, which CI does
not run.
Member
Author
jmcclena
approved these changes
Aug 10, 2026
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.
Summary
Base.deepcopy_internal(x::IMAS.DD{T}, dict)dispatches for everyDDsubtype but hardcodedIMAS.dd{T}, so any otherDDcontainer came back as anIMAS.dd. Fixed withnew_obj = typeof(x)().A bare
deepcopy(dd)never reaches this method — IMASdd'sBase.deepcopy(::DD)shadows it — so it only shows up when a dd is reached through a container, e.g.deepcopy([dd])orFUSE.Checkpoint'sgetindex.Adds
test/runtests_satellite.jl, which runs a stand-in satellite container through the same deepcopy assertions asIMAS.dd. This method had no test coverage before.