Skip to content

Commit 17ec1ec

Browse files
nabobalisCadair
authored andcommitted
random test tweaks
1 parent ff9db90 commit 17ec1ec

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

ndcube/extra_coords/tests/test_extra_coords.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,7 @@ def test_extra_coords_index(skycoord_2d_lut, time_lut):
287287
def test_extra_coords_2d_quantity(quantity_2d_lut):
288288
ec = ExtraCoords()
289289
ec.add("velocity", (0, 1), quantity_2d_lut)
290-
291-
ec.wcs.pixel_to_world(0, 0)
292-
293-
# Inspecting an extra coords
294-
# Should be able to see what tables exists, what axes they account to, and what
295-
# axes have missing dimensions.
296-
297-
# An additional spatial set (i.e. ICRS on top of HPC)
290+
assert ec.wcs.pixel_to_world(0, 0)
298291

299292

300293
# Extra Coords with NDCube

ndcube/extra_coords/tests/test_lookup_table_coord.py

+24-25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gwcs
12
import gwcs.coordinate_frames as cf
23
import numpy as np
34
import pytest
@@ -31,8 +32,9 @@ def lut_3d_distance_mesh():
3132

3233
@pytest.fixture
3334
def lut_2d_distance_no_mesh():
35+
# Fixture is broken and raises: Currently all tables must be 1-D
3436
lookup_table = np.arange(9).reshape(3, 3) * u.km, np.arange(9, 18).reshape(3, 3) * u.km
35-
return QuantityTableCoordinate(*lookup_table, mesh=False)
37+
return QuantityTableCoordinate(*lookup_table)
3638

3739

3840
@pytest.fixture
@@ -191,28 +193,26 @@ def test_2d_skycoord_mesh(lut_2d_skycoord_mesh):
191193
assert u.allclose(pix, pixel_coords.value)
192194

193195

196+
@pytest.mark.xfail(reason="celestial frames assume 2 axes, see https://github.com/spacetelescope/gwcs/issues/120")
194197
def test_3d_skycoord_mesh(lut_3d_skycoord_mesh):
195198
ltc = lut_3d_skycoord_mesh
196199

197200
assert ltc.model.n_inputs == 3
198201
assert ltc.model.n_outputs == 3
199202

200-
# Known failure due to gwcs#120
203+
pixel_coords = (0, 0, 0)*u.pix
204+
sc = ltc.wcs.pixel_to_world(*pixel_coords)
205+
pix = ltc.wcs.world_to_pixel(sc)
206+
assert u.allclose(pix, pixel_coords.value)
201207

202-
# pixel_coords = (0, 0, 0)*u.pix
203-
# sc = ltc.wcs.pixel_to_world(*pixel_coords)
204-
# pix = ltc.wcs.world_to_pixel(sc)
205-
# assert u.allclose(pix, pixel_coords.value)
208+
assert isinstance(ltc.wcs, gwcs.WCS)
206209

207-
# assert isinstance(ltc.wcs, gwcs.WCS)
208-
#
209-
# sub_ltc = ltc[0:4, 0:5, 0:6]
210-
# assert sub_ltc.delayed_models[0].lookup_table[0].shape == (4, )
211-
# assert sub_ltc.delayed_models[0].lookup_table[1].shape == (5, )
212-
# assert sub_ltc.delayed_models[0].lookup_table[2].shape == (6, )
210+
sub_ltc = ltc[0:4, 0:5, 0:6]
211+
assert sub_ltc.delayed_models[0].lookup_table[0].shape == (4, )
212+
assert sub_ltc.delayed_models[0].lookup_table[1].shape == (5, )
213+
assert sub_ltc.delayed_models[0].lookup_table[2].shape == (6, )
213214

214215

215-
@pytest.mark.xfail(reason=">1D Tables not supported")
216216
def test_2d_skycoord_no_mesh(lut_2d_skycoord_no_mesh):
217217
ltc = lut_2d_skycoord_no_mesh
218218

@@ -221,8 +221,11 @@ def test_2d_skycoord_no_mesh(lut_2d_skycoord_no_mesh):
221221

222222
pixel_coords = (0, 0)*u.pix
223223
sc = ltc.wcs.pixel_to_world(*pixel_coords)
224-
pix = ltc.wcs.world_to_pixel(sc)
225-
assert u.allclose(pix, pixel_coords.value)
224+
225+
# TODO: Fix
226+
with pytest.raises(u.UnitsError, match="could not be converted to required input units of pix"):
227+
pix = ltc.wcs.world_to_pixel(sc)
228+
assert u.allclose(pix, pixel_coords.value)
226229

227230

228231
def test_1d_time(lut_1d_time):
@@ -326,9 +329,7 @@ def test_slicing_quantity_table_coordinate():
326329

327330
@pytest.mark.xfail(reason=">1D Tables not supported")
328331
def test_slicing_quantity_table_coordinate_2d():
329-
qtc = QuantityTableCoordinate(*np.mgrid[0:10, 0:10]*u.m,
330-
names=['x', 'y'], physical_types=['pos:x', 'pos:y'])
331-
332+
qtc = QuantityTableCoordinate(*np.mgrid[0:10, 0:10]*u.m, names=['x', 'y'], physical_types=['pos:x', 'pos:y'])
332333
assert u.allclose(qtc[2:8, 2:8].table[0], (np.mgrid[2:8, 2:8]*u.m)[0])
333334
assert u.allclose(qtc[2:8, 2:8].table[1], (np.mgrid[2:8, 2:8]*u.m)[1])
334335
assert qtc.names == ['x', 'y']
@@ -412,7 +413,6 @@ def test_1d_skycoord_no_mesh_slice(lut_1d_skycoord_no_mesh):
412413
assert sub_ltc.table.shape == (4, )
413414

414415

415-
@pytest.mark.xfail(reason=">1D Tables not supported")
416416
def test_2d_skycoord_mesh_slice(lut_2d_skycoord_mesh):
417417
sub_ltc = lut_2d_skycoord_mesh[4:10, 5:10]
418418
assert sub_ltc.table.shape == (10,)
@@ -422,7 +422,6 @@ def test_2d_skycoord_mesh_slice(lut_2d_skycoord_mesh):
422422
assert sub_ltc[1:, 1:].wcs.world_to_pixel(5*u.deg, 6*u.deg) == [0.0, 0.0]
423423

424424

425-
@pytest.mark.xfail(reason=">1D Tables not supported")
426425
def test_2d_skycoord_no_mesh_slice(lut_2d_skycoord_no_mesh):
427426
sub_ltc = lut_2d_skycoord_no_mesh[1:3, 1:2]
428427
assert sub_ltc.table.shape == (2, 1)
@@ -538,7 +537,7 @@ def test_mtc_dropped_quantity_table(lut_1d_time, lut_2d_distance_no_mesh):
538537
assert len(sub._table_coords) == 1
539538
assert len(sub._dropped_coords) == 1
540539

541-
pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
540+
pytest.importorskip("gwcs", minversion="0.17")
542541

543542
dwd = sub.dropped_world_dimensions
544543
assert isinstance(dwd, dict)
@@ -562,7 +561,7 @@ def test_mtc_dropped_quantity_inside_table(lut_3d_distance_mesh):
562561

563562
assert len(sub.table) == 2
564563

565-
pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
564+
pytest.importorskip("gwcs", minversion="0.17")
566565

567566
dwd = sub.dropped_world_dimensions
568567
assert isinstance(dwd, dict)
@@ -593,7 +592,7 @@ def test_mtc_dropped_quantity_inside_table_no_mesh(lut_2d_distance_no_mesh):
593592

594593
assert len(sub.table) == 2
595594

596-
pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
595+
pytest.importorskip("gwcs", minversion="0.17")
597596

598597
dwd = sub.dropped_world_dimensions
599598
assert isinstance(dwd, dict)
@@ -608,7 +607,7 @@ def test_mtc_dropped_quantity_join_drop_table(lut_1d_time, lut_3d_distance_mesh)
608607
assert len(sub._table_coords) == 2
609608
assert len(sub._dropped_coords) == 0
610609

611-
pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
610+
pytest.importorskip("gwcs", minversion="0.17")
612611

613612
dwd = sub.dropped_world_dimensions
614613
assert isinstance(dwd, dict)
@@ -621,7 +620,7 @@ def test_mtc_dropped_quantity_join_drop_table(lut_1d_time, lut_3d_distance_mesh)
621620
assert len(sub._table_coords) == 1
622621
assert len(sub._dropped_coords) == 1
623622

624-
pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
623+
pytest.importorskip("gwcs", minversion="0.17")
625624

626625
dwd = sub.dropped_world_dimensions
627626
assert isinstance(dwd, dict)

0 commit comments

Comments
 (0)