Fix to_fits signature to correctly raise NotImplementedError#744
Fix to_fits signature to correctly raise NotImplementedError#744karlhillx wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #744 +/- ##
==========================================
- Coverage 90.75% 90.62% -0.14%
==========================================
Files 99 99
Lines 4577 4577
==========================================
- Hits 4154 4148 -6
- Misses 423 429 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emolter
left a comment
There was a problem hiding this comment.
Thanks @karlhillx this looks good.
A unit test would be helpful. I know it's redundant that all of these methods have the same override (and there's an open issue about how to clean up this part of the code), so I'm not suggesting unit-testing all 13 instances, although with a parametrized test it may not be that hard. However I think it would be good to directly test this for at least one of the models that inherits from _SimpleModel.
My suggestion would be to put it here: https://github.com/spacetelescope/stdatamodels/blob/main/tests/jwst/datamodels/test_wcs.py
Test DistortionModel (a _SimpleModel subclass) to confirm that save() correctly raises NotImplementedError rather than TypeError when to_fits() is called with the overwrite kwarg from save(). Closes spacetelescope#742, closes spacetelescope#744.
for more information, see https://pre-commit.ci
|
Added a test using DistortionModel covering the full call path through save() with a .fits path, which is what triggers the overwrite=True kwarg. Both tests in test_wcs.py pass. Ready for re-review. |
| fo.validate() | ||
|
|
||
|
|
||
| def test_simple_model_to_fits_not_implemented(): |
There was a problem hiding this comment.
the structure of the test looks good overall, and thanks for adding it. A few small things:
- we have a fixture
tmp_paththat will set up a temporary directory for the test without needing to import tempfile and unlink at the end. It would be helpful here, and you'd be able to avoid the try...finally - I don't know what warnings you were attempting to ignore here, but we avoid catching and ignoring warnings in tests, as they may hide a real issue. Warnings are upgraded to errors in our testing CI job.
- I don't believe it's necessary for this test to explicitly call
validate()
Closes #742
Description
When
save()callsto_fits(output_path, *args, **kwargs)from the base model, any subclasses that overrideto_fitswithout accepting*args, **kwargswill throw aTypeError(e.g., unexpected keyword argument 'overwrite') before the intendedNotImplementedErrorcan be raised.This PR simply updates the signature of
to_fitsin the affected reference models (inwcs_ref_models.pyandtsophot.py) to accept*argsand**kwargs, allowing theNotImplementedErrorto surface correctly with the intended message.