Skip to content

Model shape attribute can become out-of-sync with primary array #681

@emolter

Description

@emolter

Consider the following:

import stdatamodels.jwst.datamodels as dm
import numpy as np
data = np.ones((10,10))
model = dm.ImageModel(data=data)
model.shape # 10, 10
model.data = np.ones((5,5))
model.shape # 10, 10
model.data.shape # (5,5)

This happens because the model.shape property definition only queries the primary array shape if model._shape is None; otherwise it just returns model._shape. This should be fixed in some way that prevents these from being different.

model._shape is set either on __init__ (if the primary array was provided on initialization of the model) or else the first time model.shape is requested, e.g.

model = dm.ImageModel()
model.shape # None
model.data = np.ones((10,10))
model._shape # None
model.shape # (10,10)
model._shape # (10,10)

Relates to #505

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions