-
Notifications
You must be signed in to change notification settings - Fork 26
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
Force array validation when initializing a datamodel from another datamodel of different type #403
Conversation
…amodel of different type
jwst regression tests https://github.com/spacetelescope/RegressionTests/actions/runs/13311698850 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #403 +/- ##
==========================================
+ Coverage 78.16% 78.42% +0.25%
==========================================
Files 115 115
Lines 5144 5155 +11
==========================================
+ Hits 4021 4043 +22
+ Misses 1123 1112 -11 ☔ View full report in Codecov by Sentry. |
Failing JWST regression tests are due to one instance that took advantage of this bug to initialize a CubeModel with an ImageModel. So this PR is blocked until spacetelescope/jwst#9192 is merged |
@jdavies-st this is the other fix associated with the validation issue you raised a while back, please feel free to review if you are interested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good.
A meta question is why are there are tree of tests under src
? The whole point of the src
layout is to separate the package from the tests
dir and not have the tests there, as recommended by Python packaging guides for the last decade and by pytest.
Pytest describes both options as valid here, including a method involving both: https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules Placing unit tests in subdirectories inline with their source follows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Closes #307
This PR fixes a bug that allowed initialization of a datamodel from a different datamodel with an incompatible schema. For example, a CubeModel could be used as input to an ImageModel, e.g.,
model = ImageModel(CubeModel(10,10,10))
, leading to a situation where theImageModel
contained a 3-D data array that was incompatible with its schemandim
. This PR forces validation of arrays when attempting this kind of assignment.Tasks
docs/
pageno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)jwst
regression tests with this branch installed ("git+https://github.com/<fork>/stdatamodels@<branch>"
)news fragment change types...
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: fixes an issuechanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.misc.rst
: infrastructure or miscellaneous change