-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling datamodels.open
on a SlitModel
clears wht
#296
Comments
@nden @perrygreenfield This is the bug I mentioned. |
There appears to be other issues with import numpy as np
import stdatamodels.jwst.datamodels as dm
m0 = dm.ImageModel((256, 256))
np.testing.assert_allclose(m0.data, 0.0) # data starts as all 0s
m1 = dm.open(m0) # what should we expect this to do?
assert m1 is not m0 # the models are not the same
assert m1.data is m0.data # however both use the same data array
m1.data[:] = 42 # modifying m1.data now modifies m0.data
np.testing.assert_allclose(m0.data, 42.0) Passing a model to stdatamodels/src/stdatamodels/jwst/datamodels/util.py Lines 111 to 113 in 4041d5f
Passing a model to |
A similar "shared" issue can be seen with the metadata and can persist across model type changes. See the following: img = dm.ImageModel((256, 256))
assert img.meta.observation.visit_number is None
clone = dm.open(img)
assert clone.meta.observation.visit_number is None
clone.meta.observation.visit_number = '42'
# changing `visit_number` in clone also modified img
assert img.meta.observation.visit_number == '42'
# we can convert img to a CubeModel by doing the following
cube = dm.CubeModel(img)
cube.meta.observation.visit_number = '26'
assert img.meta.observation.visit_number == '26' |
Minimal example:
The text was updated successfully, but these errors were encountered: