[Debian-astro-maintainers] Bug#1001238: astropy breaks gwcs autopkgtest: module 'astropy.modeling.utils' has no attribute '_BoundingBox'
Paul Gevers
elbrus at debian.org
Mon Dec 6 20:19:06 GMT 2021
Source: astropy, gwcs
Control: found -1 astropy/5.0-1
Control: found -1 gwcs/0.16.1-1
Severity: serious
Tags: sid bookworm
X-Debbugs-CC: debian-ci at lists.debian.org
User: debian-ci at lists.debian.org
Usertags: breaks needs-update
Dear maintainer(s),
With a recent upload of astropy the autopkgtest of gwcs fails in testing
when that autopkgtest is run with the binary packages of astropy from
unstable. It passes when run with only packages from testing. In tabular
form:
pass fail
astropy from testing 5.0-1
gwcs from testing 0.16.1-1
all others from testing from testing
I copied some of the output at the bottom of this report.
Currently this regression is blocking the migration of astropy to
testing [1]. Due to the nature of this issue, I filed this bug report
against both packages. Can you please investigate the situation and
reassign the bug to the right package?
More information about this bug and the reason for filing it can be found on
https://wiki.debian.org/ContinuousIntegration/RegressionEmailInformation
Paul
[1] https://qa.debian.org/excuses.php?package=astropy
https://ci.debian.net/data/autopkgtest/testing/amd64/g/gwcs/17333475/log.gz
=================================== FAILURES
===================================
___________________ test_pixel_bounds[gwcs_2d_spatial_shift]
___________________
wcsobj = <WCS(output_frame=CelestialFrame, input_frame=detector,
forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1')
Ou...ffset=1.)>
[1]: <Shift(offset=2.)>
Parameters:
offset_0 offset_1
-------- --------
1.0 2.0)>
@wcs_objs
def test_pixel_bounds(wcsobj):
assert wcsobj.pixel_bounds is None
> wcsobj.bounding_box = ((-0.5, 2039.5), (-0.5, 1019.5))
/usr/lib/python3/dist-packages/gwcs/tests/test_api.py:314: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WCS(output_frame=CelestialFrame, input_frame=detector,
forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1')
Ou...ffset=1.)>
[1]: <Shift(offset=2.)>
Parameters:
offset_0 offset_1
-------- --------
1.0 2.0)>
value = ((-0.5, 2039.5), (-0.5, 1019.5))
@bounding_box.setter
def bounding_box(self, value):
"""
Set the range of acceptable values for each input axis.
The order of the axes is
`~gwcs.coordinate_frames.CoordinateFrame.axes_order`.
For two inputs and axes_order(0, 1) the bounding box is ((xlow,
xhigh), (ylow, yhigh)).
Parameters
----------
value : tuple or None
Tuple of tuples with ("low", high") values for the range.
"""
frames = self.available_frames
transform_0 = self.get_transform(frames[0], frames[1])
if value is None:
transform_0.bounding_box = value
else:
try:
# Make sure the dimensions of the new bbox are correct.
> mutils._BoundingBox.validate(transform_0, value)
E AttributeError: module 'astropy.modeling.utils' has no
attribute '_BoundingBox'
/usr/lib/python3/dist-packages/gwcs/wcs.py:1296: AttributeError
________________________________ test_ellipsis
_________________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_ellipsis(gwcs_3d_galactic_spectral):
wcs = SlicedLowLevelWCS(gwcs_3d_galactic_spectral, Ellipsis)
assert wcs.pixel_n_dim == 3
assert wcs.world_n_dim == 3
assert wcs.array_shape == (30, 20, 10)
assert wcs.pixel_shape == (10, 20, 30)
assert wcs.world_axis_physical_types == ['pos.galactic.lat',
'em.freq', 'pos.galactic.lon']
assert wcs.world_axis_units == ['deg', 'Hz', 'deg']
assert_equal(wcs.axis_correlation_matrix, [[True, False,
True], [False, True, False], [True, False, True]])
assert wcs.world_axis_object_components == [('celestial',
1, 'spherical.lat'),
('spectral', 0,
'value'),
('celestial', 0,
'spherical.lon')]
assert wcs.world_axis_object_classes['celestial'][0] is
SkyCoord
assert wcs.world_axis_object_classes['celestial'][1] == ()
assert
isinstance(wcs.world_axis_object_classes['celestial'][2]['frame'], Galactic)
assert wcs.world_axis_object_classes['celestial'][2]['unit'] ==
(u.deg, u.deg)
assert wcs.world_axis_object_classes['spectral'][0] is Quantity
assert wcs.world_axis_object_classes['spectral'][1] == ()
assert wcs.world_axis_object_classes['spectral'][2] == {'unit':
'Hz'}
> assert_allclose(wcs.pixel_to_world_values(29, 39, 44), (10,
20, 25))
/usr/lib/python3/dist-packages/gwcs/tests/test_api_slicing.py:60: _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:230:
in pixel_to_world_values
world_arrays = self._pixel_to_world_values_all(*pixel_arrays)
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:227:
in _pixel_to_world_values_all
return self._wcs.pixel_to_world_values(*pixel_arrays_new)
/usr/lib/python3/dist-packages/gwcs/api.py:108: in pixel_to_world_values
result = self(*pixel_arrays, with_units=False)
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
_____________________________ test_spectral_slice
______________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_spectral_slice(gwcs_3d_galactic_spectral):
wcs = SlicedLowLevelWCS(gwcs_3d_galactic_spectral,
[slice(None), 10])
assert wcs.pixel_n_dim == 2
assert wcs.world_n_dim == 2
assert wcs.array_shape == (30, 10)
assert wcs.pixel_shape == (10, 30)
assert wcs.world_axis_physical_types == ['pos.galactic.lat',
'pos.galactic.lon']
assert wcs.world_axis_units == ['deg', 'deg']
assert_equal(wcs.axis_correlation_matrix, [[True, True],
[True, True]])
assert wcs.world_axis_object_components == [('celestial',
1, 'spherical.lat'),
('celestial', 0,
'spherical.lon')]
assert wcs.world_axis_object_classes['celestial'][0] is
SkyCoord
assert wcs.world_axis_object_classes['celestial'][1] == ()
assert
isinstance(wcs.world_axis_object_classes['celestial'][2]['frame'], Galactic)
assert wcs.world_axis_object_classes['celestial'][2]['unit'] ==
(u.deg, u.deg)
> assert_allclose(wcs.pixel_to_world_values(29, 44), (10, 25))
/usr/lib/python3/dist-packages/gwcs/tests/test_api_slicing.py:117: _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:230:
in pixel_to_world_values
world_arrays = self._pixel_to_world_values_all(*pixel_arrays)
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:227:
in _pixel_to_world_values_all
return self._wcs.pixel_to_world_values(*pixel_arrays_new)
/usr/lib/python3/dist-packages/gwcs/api.py:108: in pixel_to_world_values
result = self(*pixel_arrays, with_units=False)
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
_____________________________ test_spectral_range
______________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_spectral_range(gwcs_3d_galactic_spectral):
wcs = SlicedLowLevelWCS(gwcs_3d_galactic_spectral,
[slice(None), slice(4, 10)])
assert wcs.pixel_n_dim == 3
assert wcs.world_n_dim == 3
assert wcs.array_shape == (30, 6, 10)
assert wcs.pixel_shape == (10, 6, 30)
assert wcs.world_axis_physical_types == ['pos.galactic.lat',
'em.freq', 'pos.galactic.lon']
assert wcs.world_axis_units == ['deg', 'Hz', 'deg']
assert_equal(wcs.axis_correlation_matrix, [[True, False,
True], [False, True, False], [True, False, True]])
assert wcs.world_axis_object_components == [('celestial',
1, 'spherical.lat'),
('spectral', 0,
'value'),
('celestial', 0,
'spherical.lon')]
assert wcs.world_axis_object_classes['celestial'][0] is
SkyCoord
assert wcs.world_axis_object_classes['celestial'][1] == ()
assert
isinstance(wcs.world_axis_object_classes['celestial'][2]['frame'], Galactic)
assert wcs.world_axis_object_classes['celestial'][2]['unit'] ==
(u.deg, u.deg)
assert wcs.world_axis_object_classes['spectral'][0] is Quantity
assert wcs.world_axis_object_classes['spectral'][1] == ()
assert wcs.world_axis_object_classes['spectral'][2] == {'unit':
'Hz'}
> assert_allclose(wcs.pixel_to_world_values(29, 35, 44), (10,
20, 25))
/usr/lib/python3/dist-packages/gwcs/tests/test_api_slicing.py:182: _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:230:
in pixel_to_world_values
world_arrays = self._pixel_to_world_values_all(*pixel_arrays)
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:227:
in _pixel_to_world_values_all
return self._wcs.pixel_to_world_values(*pixel_arrays_new)
/usr/lib/python3/dist-packages/gwcs/api.py:108: in pixel_to_world_values
result = self(*pixel_arrays, with_units=False)
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
_____________________________ test_celestial_slice
_____________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_celestial_slice(gwcs_3d_galactic_spectral):
wcs = SlicedLowLevelWCS(gwcs_3d_galactic_spectral,
[Ellipsis, 5])
assert wcs.pixel_n_dim == 2
assert wcs.world_n_dim == 3
assert wcs.array_shape == (30, 20)
assert wcs.pixel_shape == (20, 30)
assert wcs.world_axis_physical_types == ['pos.galactic.lat',
'em.freq', 'pos.galactic.lon']
assert wcs.world_axis_units == ['deg', 'Hz', 'deg']
assert_equal(wcs.axis_correlation_matrix, [[False, True],
[True, False], [False, True]])
assert wcs.world_axis_object_components == [('celestial',
1, 'spherical.lat'),
('spectral', 0,
'value'),
('celestial', 0,
'spherical.lon')]
assert wcs.world_axis_object_classes['celestial'][0] is
SkyCoord
assert wcs.world_axis_object_classes['celestial'][1] == ()
assert
isinstance(wcs.world_axis_object_classes['celestial'][2]['frame'], Galactic)
assert wcs.world_axis_object_classes['celestial'][2]['unit'] ==
(u.deg, u.deg)
assert wcs.world_axis_object_classes['spectral'][0] is Quantity
assert wcs.world_axis_object_classes['spectral'][1] == ()
assert wcs.world_axis_object_classes['spectral'][2] == {'unit':
'Hz'}
> assert_allclose(wcs.pixel_to_world_values(39, 44), (12.4,
20, 25))
/usr/lib/python3/dist-packages/gwcs/tests/test_api_slicing.py:246: _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:230:
in pixel_to_world_values
world_arrays = self._pixel_to_world_values_all(*pixel_arrays)
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:227:
in _pixel_to_world_values_all
return self._wcs.pixel_to_world_values(*pixel_arrays_new)
/usr/lib/python3/dist-packages/gwcs/api.py:108: in pixel_to_world_values
result = self(*pixel_arrays, with_units=False)
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
_____________________________ test_celestial_range
_____________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_celestial_range(gwcs_3d_galactic_spectral):
wcs = SlicedLowLevelWCS(gwcs_3d_galactic_spectral,
[Ellipsis, slice(5, 10)])
assert wcs.pixel_n_dim == 3
assert wcs.world_n_dim == 3
assert wcs.array_shape == (30, 20, 5)
assert wcs.pixel_shape == (5, 20, 30)
assert wcs.world_axis_physical_types == ['pos.galactic.lat',
'em.freq', 'pos.galactic.lon']
assert wcs.world_axis_units == ['deg', 'Hz', 'deg']
assert_equal(wcs.axis_correlation_matrix, [[True, False,
True], [False, True, False], [True, False, True]])
assert wcs.world_axis_object_components == [('celestial',
1, 'spherical.lat'),
('spectral', 0,
'value'),
('celestial', 0,
'spherical.lon')]
assert wcs.world_axis_object_classes['celestial'][0] is
SkyCoord
assert wcs.world_axis_object_classes['celestial'][1] == ()
assert
isinstance(wcs.world_axis_object_classes['celestial'][2]['frame'], Galactic)
assert wcs.world_axis_object_classes['celestial'][2]['unit'] ==
(u.deg, u.deg)
assert wcs.world_axis_object_classes['spectral'][0] is Quantity
assert wcs.world_axis_object_classes['spectral'][1] == ()
assert wcs.world_axis_object_classes['spectral'][2] == {'unit':
'Hz'}
> assert_allclose(wcs.pixel_to_world_values(24, 39, 44), (10,
20, 25))
/usr/lib/python3/dist-packages/gwcs/tests/test_api_slicing.py:311: _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:230:
in pixel_to_world_values
world_arrays = self._pixel_to_world_values_all(*pixel_arrays)
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:227:
in _pixel_to_world_values_all
return self._wcs.pixel_to_world_values(*pixel_arrays_new)
/usr/lib/python3/dist-packages/gwcs/api.py:108: in pixel_to_world_values
result = self(*pixel_arrays, with_units=False)
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
___________________________ test_ellipsis_none_types
___________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_ellipsis_none_types(gwcs_3d_galactic_spectral):
pht =
list(gwcs_3d_galactic_spectral.output_frame._axis_physical_types)
pht[1] = None
gwcs_3d_galactic_spectral.output_frame._axis_physical_types =
tuple(pht)
wcs = SlicedLowLevelWCS(gwcs_3d_galactic_spectral, Ellipsis)
assert wcs.pixel_n_dim == 3
assert wcs.world_n_dim == 3
assert wcs.array_shape == (30, 20, 10)
assert wcs.pixel_shape == (10, 20, 30)
assert wcs.world_axis_physical_types == ['pos.galactic.lat',
None, 'pos.galactic.lon']
assert wcs.world_axis_units == ['deg', 'Hz', 'deg']
assert_equal(wcs.axis_correlation_matrix, [[True, False, True],
[False, True,
False], [True, False, True]])
assert wcs.world_axis_object_components == [('celestial',
1, 'spherical.lat'),
('spectral', 0,
'value'),
('celestial', 0,
'spherical.lon')]
assert wcs.world_axis_object_classes['celestial'][0] is
SkyCoord
assert wcs.world_axis_object_classes['celestial'][1] == ()
assert
isinstance(wcs.world_axis_object_classes['celestial'][2]['frame'], Galactic)
assert wcs.world_axis_object_classes['celestial'][2]['unit'] ==
(u.deg, u.deg)
> assert_allclose(wcs.pixel_to_world_values(29, 39, 44), (10,
20, 25))
/usr/lib/python3/dist-packages/gwcs/tests/test_api_slicing.py:443: _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:230:
in pixel_to_world_values
world_arrays = self._pixel_to_world_values_all(*pixel_arrays)
/usr/lib/python3/dist-packages/astropy/wcs/wcsapi/wrappers/sliced_wcs.py:227:
in _pixel_to_world_values_all
return self._wcs.pixel_to_world_values(*pixel_arrays_new)
/usr/lib/python3/dist-packages/gwcs/api.py:108: in pixel_to_world_values
result = self(*pixel_arrays, with_units=False)
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
______________________________ test_bounding_box
_______________________________
def test_bounding_box():
trans3 = models.Shift(10) & models.Scale(2) & models.Shift(-1)
pipeline = [('detector', trans3), ('sky', None)]
w = wcs.WCS(pipeline)
bb = ((-1, 10), (6, 15))
with pytest.raises(ValueError):
> w.bounding_box = bb
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:258: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WCS(output_frame=None, input_frame=None,
forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x')
Outputs: ('...offset=-1.)>
Parameters:
offset_0 factor_1 offset_2
-------- -------- --------
10.0 2.0 -1.0)>
value = ((-1, 10), (6, 15))
@bounding_box.setter
def bounding_box(self, value):
"""
Set the range of acceptable values for each input axis.
The order of the axes is
`~gwcs.coordinate_frames.CoordinateFrame.axes_order`.
For two inputs and axes_order(0, 1) the bounding box is ((xlow,
xhigh), (ylow, yhigh)).
Parameters
----------
value : tuple or None
Tuple of tuples with ("low", high") values for the range.
"""
frames = self.available_frames
transform_0 = self.get_transform(frames[0], frames[1])
if value is None:
transform_0.bounding_box = value
else:
try:
# Make sure the dimensions of the new bbox are correct.
> mutils._BoundingBox.validate(transform_0, value)
E AttributeError: module 'astropy.modeling.utils' has no
attribute '_BoundingBox'
/usr/lib/python3/dist-packages/gwcs/wcs.py:1296: AttributeError
____________________________ test_bounding_box_eval
____________________________
def test_bounding_box_eval():
"""
Tests evaluation with and without respecting the bounding_box.
"""
trans3 = models.Shift(10) & models.Scale(2) & models.Shift(-1)
pipeline = [('detector', trans3), ('sky', None)]
w = wcs.WCS(pipeline)
> w.bounding_box = ((-1, 10), (6, 15), (4.3, 6.9))
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:353: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WCS(output_frame=None, input_frame=None,
forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x')
Outputs: ('...offset=-1.)>
Parameters:
offset_0 factor_1 offset_2
-------- -------- --------
10.0 2.0 -1.0)>
value = ((-1, 10), (6, 15), (4.3, 6.9))
@bounding_box.setter
def bounding_box(self, value):
"""
Set the range of acceptable values for each input axis.
The order of the axes is
`~gwcs.coordinate_frames.CoordinateFrame.axes_order`.
For two inputs and axes_order(0, 1) the bounding box is ((xlow,
xhigh), (ylow, yhigh)).
Parameters
----------
value : tuple or None
Tuple of tuples with ("low", high") values for the range.
"""
frames = self.available_frames
transform_0 = self.get_transform(frames[0], frames[1])
if value is None:
transform_0.bounding_box = value
else:
try:
# Make sure the dimensions of the new bbox are correct.
> mutils._BoundingBox.validate(transform_0, value)
E AttributeError: module 'astropy.modeling.utils' has no
attribute '_BoundingBox'
/usr/lib/python3/dist-packages/gwcs/wcs.py:1296: AttributeError
________________________________ test_footprint
________________________________
def test_footprint():
icrs = cf.CelestialFrame(name='icrs', reference_frame=coord.ICRS(),
axes_order=(0, 1))
spec = cf.SpectralFrame(name='freq', unit=[u.Hz, ],
axes_order=(2, ))
world = cf.CompositeFrame([icrs, spec])
transform = (models.Shift(10) & models.Shift(-1)) & models.Scale(2)
pipe = [('det', transform), (world, None)]
w = wcs.WCS(pipe)
with pytest.raises(TypeError):
w.footprint()
> w.bounding_box = ((1,5), (1,3), (1, 6))
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:397: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WCS(output_frame=CompositeFrame, input_frame=None,
forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x')
O...(factor=2.)>
Parameters:
offset_0 offset_1 factor_2
-------- -------- --------
10.0 -1.0 2.0)>
value = ((1, 5), (1, 3), (1, 6))
@bounding_box.setter
def bounding_box(self, value):
"""
Set the range of acceptable values for each input axis.
The order of the axes is
`~gwcs.coordinate_frames.CoordinateFrame.axes_order`.
For two inputs and axes_order(0, 1) the bounding box is ((xlow,
xhigh), (ylow, yhigh)).
Parameters
----------
value : tuple or None
Tuple of tuples with ("low", high") values for the range.
"""
frames = self.available_frames
transform_0 = self.get_transform(frames[0], frames[1])
if value is None:
transform_0.bounding_box = value
else:
try:
# Make sure the dimensions of the new bbox are correct.
> mutils._BoundingBox.validate(transform_0, value)
E AttributeError: module 'astropy.modeling.utils' has no
attribute '_BoundingBox'
/usr/lib/python3/dist-packages/gwcs/wcs.py:1296: AttributeError
_______________________________ test_to_fits_sip
_______________________________
def test_to_fits_sip():
y, x = np.mgrid[:1024:10, :1024:10]
xflat = np.ravel(x[1:-1, 1:-1])
yflat = np.ravel(y[1:-1, 1:-1])
af = asdf.open(get_pkg_data_filename('data/miriwcs.asdf'))
miriwcs = af.tree['wcs']
bounding_box = ((0, 1024), (0, 1024))
mirisip = miriwcs.to_fits_sip(bounding_box, max_inv_pix_error=0.1)
fitssip = astwcs.WCS(mirisip)
fitsvalx, fitsvaly = fitssip.all_pix2world(xflat+1, yflat+1, 1)
> gwcsvalx, gwcsvaly = miriwcs(xflat, yflat)
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:566: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_0=0.15, offset_1=-0.59, offset_2=-4.,
c0_4=-12.7875, c1_4=0.025, c0_5=-12.7875, c1_5=0.025, c0_0...38,
c0_0_10=-375.39, c1_0_10=0.99684849, c0_1_10=0.07932904,
c0_0_11=-434.08, c1_0_11=0.07932904, c0_1_11=-0.99684849)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
____________________________ test_to_fits_tab_cube
_____________________________
gwcs_3d_galactic_spectral = <WCS(output_frame=CompositeFrame,
input_frame=detector, forward_transform=Model: CompoundModel
Inputs: ('x0', 'x1', 'x...-------- -------- -------- --------
-44.0 -29.0 0.1 -0.1 ... 180.0 -39.0
0.5 20.0)>
def test_to_fits_tab_cube(gwcs_3d_galactic_spectral):
# gWCS:
w = gwcs_3d_galactic_spectral
# FITS WCS -TAB:
> hdr, bt = w.to_fits_tab()
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:599: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/gwcs/wcs.py:1695: in to_fits_tab
if self.bounding_box is None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-44., offset_2=-29., factor_3=0.1,
factor_4=-0.1, lon_6=25., lat_6=100., lon_pole_6=180., offset_7=-39.,
factor_8=0.5, offset_9=20.)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
_________________________ test_to_fits_tab_miri_image
__________________________
def test_to_fits_tab_miri_image():
# gWCS:
af = asdf.open(get_pkg_data_filename('data/miriwcs.asdf'))
w = af.tree['wcs']
# FITS WCS -TAB:
> hdr, bt = w.to_fits_tab(sampling=0.5)
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:632: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/gwcs/wcs.py:1695: in to_fits_tab
if self.bounding_box is None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_0=0.15, offset_1=-0.59, offset_2=-4.,
c0_4=-12.7875, c1_4=0.025, c0_5=-12.7875, c1_5=0.025, c0_0...38,
c0_0_10=-375.39, c1_0_10=0.99684849, c0_1_10=0.07932904,
c0_0_11=-434.08, c1_0_11=0.07932904, c0_1_11=-0.99684849)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
__________________________ test_to_fits_tab_miri_lrs
___________________________
def test_to_fits_tab_miri_lrs():
af = asdf.open(get_pkg_data_filename('data/miri_lrs_wcs.asdf'))
w = af.tree['wcs']
# FITS WCS -TAB:
> hdr, bt = w.to_fits_tab(sampling=0.25)
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:654: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/gwcs/wcs.py:1695: in to_fits_tab
if self.bounding_box is None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_1=-325.13, offset_2=-299.7,
angle_3=0.24155757, offset_4=325.13, offset_5=299.7,
amplitude_7=299...4, c0_0_17=-434.08, c1_0_17=0.07932904,
c0_1_17=-0.99684849, offset_20=-325.13, offset_21=-299.7,
angle_22=0.24155757)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
________________________________ test_in_image
_________________________________
def test_in_image():
# create a 1-dim WCS:
w1 = wcs.WCS(
[
(cf.SpectralFrame(name='input', axes_names=('x',),
unit=(u.pix,)), models.Scale(2)),
(cf.SpectralFrame(name='output', axes_names=('x'),
unit=(u.pix,)), None)
]
)
> w1.bounding_box = (1, 5)
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:681: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WCS(output_frame=output, input_frame=input,
forward_transform=Model: Scale
Inputs: ('x',)
Outputs: ('y',)
Model set size: 1
Parameters:
factor
------
2.0)>
value = (1, 5)
@bounding_box.setter
def bounding_box(self, value):
"""
Set the range of acceptable values for each input axis.
The order of the axes is
`~gwcs.coordinate_frames.CoordinateFrame.axes_order`.
For two inputs and axes_order(0, 1) the bounding box is ((xlow,
xhigh), (ylow, yhigh)).
Parameters
----------
value : tuple or None
Tuple of tuples with ("low", high") values for the range.
"""
frames = self.available_frames
transform_0 = self.get_transform(frames[0], frames[1])
if value is None:
transform_0.bounding_box = value
else:
try:
# Make sure the dimensions of the new bbox are correct.
> mutils._BoundingBox.validate(transform_0, value)
E AttributeError: module 'astropy.modeling.utils' has no
attribute '_BoundingBox'
/usr/lib/python3/dist-packages/gwcs/wcs.py:1296: AttributeError
________________________________ test_iter_inv
_________________________________
def test_iter_inv():
w =
asdf.open(get_pkg_data_filename('data/nircamwcs.asdf')).tree['wcs']
# remove analytic/user-supplied inverse:
w.pipeline[0].transform.inverse = None
w.bounding_box = None
# test single point
assert np.allclose((1, 2), w.invert(*w(1, 2)))
assert np.allclose(
(np.nan, np.nan),
w.numerical_inverse(*w(np.nan, 2)),
equal_nan=True
)
# prepare to test a vector of points:
np.random.seed(10)
x, y = 2047 * np.random.random((2, 10000)) # "truth"
# test adaptive:
xp, yp = w.invert(
*w(x, y),
adaptive=True,
detect_divergence=True,
quiet=False
)
assert np.allclose((x, y), (xp, yp))
w =
asdf.open(get_pkg_data_filename('data/nircamwcs.asdf')).tree['wcs']
# test single point
> assert np.allclose((1, 2), w.numerical_inverse(*w(1, 2)))
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:741: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/gwcs/wcs.py:314: in __call__
if self.bounding_box is not None:
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <CompoundModel(offset_0=1., offset_1=1., offset_2=-1024.5,
offset_3=-1024.5, c0_0_5=-0., c1_0_5=0.06277675, c2_0_5=0.0...917,
c0_1_8=-0.00128895, c0_0_9=0., c1_0_9=-0.00128895, c0_1_9=0.99999917,
offset_10=86.039011, offset_11=-493.385704)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
___________________________ test_tabular_2d_quantity
___________________________
def test_tabular_2d_quantity():
shape = (3, 3)
data = np.arange(np.product(shape)).reshape(shape) * u.m / u.s
# The integer location is at the centre of the pixel.
points_unit = u.pix
points = [(np.arange(size) - 0) * points_unit for size in shape]
kwargs = {
'bounds_error': False,
'fill_value': np.nan,
'method': 'nearest',
}
forward = models.Tabular2D(points, data, **kwargs)
input_frame = cf.CoordinateFrame(2, ("PIXEL", "PIXEL"), (0,1),
unit=(u.pix, u.pix), name="detector")
output_frame = cf.CoordinateFrame(1, "CUSTOM", (0,),
unit=(u.m/u.s,))
w = wcs.WCS(forward_transform=forward, input_frame=input_frame,
output_frame=output_frame)
> bb = w.bounding_box
/usr/lib/python3/dist-packages/gwcs/tests/test_wcs.py:829: _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in bounding_box
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/gwcs/wcs.py:1274: in <genexpr>
return tuple(bb[::-1][i] for i in axes_order)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:638: in
__getitem__
index = self._get_index(key)
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:616: in
_get_index
return get_index(self._model, key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
model = <Tabular2D(points=[<Quantity [0., 1., 2.] pix>, <Quantity [0.,
1., 2.] pix>], lookup_table=[[0. 1. 2.]
[3. 4. 5.]
[6. 7. 8.]] m / s)>
key = slice(None, None, -1)
def get_index(model, key) -> int:
"""
Get the input index corresponding to the given key.
Can pass in either:
the string name of the input or
the input index itself.
"""
if isinstance(key, str):
if key in model.inputs:
index = model.inputs.index(key)
else:
raise ValueError(f"'{key}' is not one of the inputs:
{model.inputs}.")
elif np.issubdtype(type(key), np.integer):
if 0 <= key < len(model.inputs):
index = key
else:
raise IndexError(f"Integer key: {key} must be
non-negative and < {len(model.inputs)}.")
else:
> raise ValueError(f"Key value: {key} must be string or integer.")
E ValueError: Key value: slice(None, None, -1) must be string
or integer.
/usr/lib/python3/dist-packages/astropy/modeling/bounding_box.py:500:
ValueError
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/debian-astro-maintainers/attachments/20211206/f9de0f8e/attachment-0001.sig>
More information about the Debian-astro-maintainers
mailing list