Skip to content

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

@chris-simpson

Description

@chris-simpson

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions