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

with_units wrongly returning a single SpectralCoord instead of an array in v0.24 #559

Open
chris-simpson opened this issue Feb 7, 2025 · 0 comments · May be fixed by #563
Open

with_units wrongly returning a single SpectralCoord instead of an array in v0.24 #559

chris-simpson opened this issue Feb 7, 2025 · 0 comments · May be fixed by #563

Comments

@chris-simpson
Copy link
Contributor

gWCS v0.24.0 is failing to behave correctly when returning a SpectralCoord object if sent an array of input coordinates.

>>> from gwcs.wcs import WCS as gWCS
>>> from gwcs import coordinate_frames as cf
>>> from astropy.modeling import models
>>> from astropy import units as u
>>> input_frame = cf.CoordinateFrame(naxes=1, axes_type=('SPATIAL',),
...                                  axes_order=(0,), name="pixels",
...                                  unit=(u.pix,), axes_names=('x',))
>>> output_frame = cf.SpectralFrame(unit=(u.nm,), axes_names=('lambda',))
>>> wave_model = models.Scale(0.1) | models.Shift(500)
>>> wcs = gWCS([(input_frame, wave_model),
...             (output_frame, None)])
>>> wcs([0,1,2], with_units=False)
array([500. , 500.1, 500.2])
>>> wcs([0,1,2], with_units=True)
<SpectralCoord 500. nm>

Under v0.22.1, it behaves correctly

>>> wcs([0,1,2], with_units=True)
<SpectralCoord [500. , 500.1, 500.2] nm>
@chris-simpson chris-simpson changed the title with_units wrongly returning a single SpectralCoord instead of an array with_units wrongly returning a single SpectralCoord instead of an array in v0.24 Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant