Skip to content
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

Use the APE 14 specified API in some of the tests #1195

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

WilliamJamieson
Copy link
Contributor

spacetelescope/gwcs#457 corrects an oversight in the APE 14 related API, where "low-level" inputs were accepted by the "high-level" api. This PR simply swaps the usage in specutils from using the "high-level" with "low-level" inputs to using the proper "low-level" API.

Also, I updated the tests so that files generated by the tests get cleaned up by pytest.

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clean up!

@pllim pllim added the no-changelog-entry-needed changelog bot directive label Nov 19, 2024
@@ -318,15 +318,15 @@ def test_wcs_transformations():
spec = Spectrum1D(spectral_axis=np.arange(1, 50) * u.nm,
flux=np.ones(49) * u.Jy)

pix_axis = spec.wcs.world_to_pixel(np.arange(20, 30) * u.nm)
pix_axis = spec.wcs.world_to_pixel_values(np.arange(20, 30) * u.nm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FAILED ../../specutils/tests/test_spectrum1d.py::test_wcs_transformations - AttributeError: 'numpy.ndarray' object has no attribute 'to_value'

I don't think this patch is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll have to adjust things. It's because units have been passed in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacetelescope/gwcs#457 also corrects things so that the *_values can accept quantity inputs. GWCS was inconsistent about this. For now its better to just wrap it in a SpectralCoord object like it should be for the function as it is used in the test.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.92%. Comparing base (170d70f) to head (d5dc722).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1195   +/-   ##
=======================================
  Coverage   86.92%   86.92%           
=======================================
  Files          63       63           
  Lines        4572     4572           
=======================================
  Hits         3974     3974           
  Misses        598      598           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@pllim
Copy link
Member

pllim commented Nov 19, 2024

Remote data failure is unrelated.

pix_axis = spec.wcs.world_to_pixel(np.arange(20, 30) * u.nm)
# After spacetelescope/gwcs#457 is merged and released, this can be changed to
# pix_axis = spec.wcs.world_to_pixel_values(np.arange(20, 30) * u.nm)
pix_axis = spec.wcs.world_to_pixel(SpectralCoord(np.arange(20, 30) * u.nm))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. I think it makes sense for specutils to use high level API.

@pllim pllim merged commit f8a8d6a into astropy:main Nov 19, 2024
12 of 13 checks passed
@WilliamJamieson WilliamJamieson deleted the bugfix/gwcs branch November 19, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-entry-needed changelog bot directive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants