def test_wcs_setter(wcs_1d_l, wave_lut): ec = ExtraCoords(wcs=wcs_1d_l, mapping=(0, )) with pytest.raises(AttributeError): ec.wcs = None ec = ExtraCoords() ec.mapping = (1, ) with pytest.raises(ValueError): ec.wcs = wcs_1d_l ec = ExtraCoords() ec.add_coordinate("wave", (0, ), wave_lut) with pytest.raises(AttributeError): ec.wcs = None
def test_empty_ec(wcs_1d_l): ec = ExtraCoords() # Test slice of an empty EC assert ec[0].wcs is None assert ec.mapping == tuple() assert ec.wcs is None assert ec.keys() == tuple() ec.wcs = wcs_1d_l assert ec.wcs is wcs_1d_l ec.mapping = (0, ) assert ec.mapping == (0, )
def test_exceptions(wcs_1d_l): # Test unable to specify inconsistent dimensions and tables with pytest.raises(ValueError): ExtraCoords.from_lookup_tables(None, (0,), (0, 0)) # Test unable to add to WCS EC ec = ExtraCoords() ec.wcs = wcs_1d_l ec.mapping = (0,) with pytest.raises(ValueError): ec.add(None, 0, None) with pytest.raises(KeyError): ExtraCoords()['empty']
def test_wcs_1d(wcs_1d_l): ec = ExtraCoords() ec.wcs = wcs_1d_l ec.mapping = (0,) assert ec.keys() == ('spectral',) assert ec.mapping == (0,) assert ec.wcs is wcs_1d_l subec = ec[1:] assert ec.keys() == ('spectral',) assert ec.mapping == (0,) assert np.allclose(ec.wcs.pixel_to_world_values(1), subec.wcs.pixel_to_world_values(1)) subec = ec[0] assert subec.wcs is None