Skip to content

Commit 692d13d

Browse files
authored
fix bug where nodes couldn't be deep copied (#511)
1 parent 77ca5a7 commit 692d13d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

changes/511.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where nodes couldn't be deepcopied after use.

src/roman_datamodels/stnode/_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SchemaProperties:
5757
"""
5858

5959
def __init__(self, explicit_properties, patterns):
60-
self.explicit_properties = explicit_properties
60+
self.explicit_properties = set(explicit_properties)
6161
self.patterns = patterns
6262

6363
def __contains__(self, attr):

tests/test_models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import warnings
22
from contextlib import nullcontext
3+
from copy import deepcopy
34

45
import asdf
56
import numpy as np
@@ -1301,3 +1302,14 @@ def test_wfi_wcs_no_wcs(caplog):
13011302
assert not hasattr(wfi_wcs, "wcs_l2")
13021303

13031304
assert "Model has no WCS defined" in caplog.text
1305+
1306+
1307+
def test_deepcopy_after_use():
1308+
"""
1309+
Test that nodes constructed from using models can be copied
1310+
1311+
See: https://github.com/spacetelescope/roman_datamodels/issues/486
1312+
"""
1313+
m = datamodels.ImageModel()
1314+
m.meta = {}
1315+
deepcopy(m.meta)

0 commit comments

Comments
 (0)