Skip to content

Preserve the concrete type in DD deepcopy - #313

Merged
jmcclena merged 1 commit into
masterfrom
fix/deepcopy_dd_subtypes
Aug 10, 2026
Merged

Preserve the concrete type in DD deepcopy#313
jmcclena merged 1 commit into
masterfrom
fix/deepcopy_dd_subtypes

Conversation

@mgyoo86

@mgyoo86 mgyoo86 commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

Base.deepcopy_internal(x::IMAS.DD{T}, dict) dispatches for every DD subtype but hardcoded IMAS.dd{T}, so any other DD container came back as an IMAS.dd. Fixed with new_obj = typeof(x)().

A bare deepcopy(dd) never reaches this method — IMASdd's Base.deepcopy(::DD) shadows it — so it only shows up when a dd is reached through a container, e.g. deepcopy([dd]) or FUSE.Checkpoint's getindex.

Adds test/runtests_satellite.jl, which runs a stand-in satellite container through the same deepcopy assertions as IMAS.dd. This method had no test coverage before.

`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.
@mgyoo86

mgyoo86 commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

@jmcclena FYI,
FUSE CI is running here.
FUSE CI ran successfully.

@mgyoo86
mgyoo86 requested a review from jmcclena August 10, 2026 19:30
@jmcclena
jmcclena merged commit 9413f6b into master Aug 10, 2026
2 checks passed
@mgyoo86
mgyoo86 deleted the fix/deepcopy_dd_subtypes branch August 11, 2026 17:51
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.

2 participants