Skip to content

Commit

Permalink
random test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed Jan 8, 2025
1 parent cb19de9 commit b858e67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
8 changes: 0 additions & 8 deletions ndcube/extra_coords/tests/test_extra_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@ def test_extra_coords_2d_quantity(quantity_2d_lut):
ec = ExtraCoords()
ec.add("velocity", (0, 1), quantity_2d_lut)

ec.wcs.pixel_to_world(0, 0)

# Inspecting an extra coords
# Should be able to see what tables exists, what axes they account to, and what
# axes have missing dimensions.

# An additional spatial set (i.e. ICRS on top of HPC)


# Extra Coords with NDCube
def test_add_coord_after_create(time_lut):
Expand Down
28 changes: 14 additions & 14 deletions ndcube/extra_coords/tests/test_lookup_table_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def lut_3d_distance_mesh():

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


@pytest.fixture
Expand Down Expand Up @@ -212,7 +213,7 @@ def test_3d_skycoord_mesh(lut_3d_skycoord_mesh):
# assert sub_ltc.delayed_models[0].lookup_table[2].shape == (6, )


@pytest.mark.xfail(reason=">1D Tables not supported")

def test_2d_skycoord_no_mesh(lut_2d_skycoord_no_mesh):
ltc = lut_2d_skycoord_no_mesh

Expand All @@ -221,8 +222,11 @@ def test_2d_skycoord_no_mesh(lut_2d_skycoord_no_mesh):

pixel_coords = (0, 0)*u.pix
sc = ltc.wcs.pixel_to_world(*pixel_coords)
pix = ltc.wcs.world_to_pixel(sc)
assert u.allclose(pix, pixel_coords.value)

# TODO: Fix
with pytest.raises(u.UnitsError, match="could not be converted to required input units of pix"):
pix = ltc.wcs.world_to_pixel(sc)
assert u.allclose(pix, pixel_coords.value)


def test_1d_time(lut_1d_time):
Expand Down Expand Up @@ -326,9 +330,7 @@ def test_slicing_quantity_table_coordinate():

@pytest.mark.xfail(reason=">1D Tables not supported")
def test_slicing_quantity_table_coordinate_2d():
qtc = QuantityTableCoordinate(*np.mgrid[0:10, 0:10]*u.m,
names=['x', 'y'], physical_types=['pos:x', 'pos:y'])

qtc = QuantityTableCoordinate(*np.mgrid[0:10, 0:10]*u.m, names=['x', 'y'], physical_types=['pos:x', 'pos:y'])
assert u.allclose(qtc[2:8, 2:8].table[0], (np.mgrid[2:8, 2:8]*u.m)[0])
assert u.allclose(qtc[2:8, 2:8].table[1], (np.mgrid[2:8, 2:8]*u.m)[1])
assert qtc.names == ['x', 'y']
Expand Down Expand Up @@ -412,7 +414,6 @@ def test_1d_skycoord_no_mesh_slice(lut_1d_skycoord_no_mesh):
assert sub_ltc.table.shape == (4, )


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


@pytest.mark.xfail(reason=">1D Tables not supported")
def test_2d_skycoord_no_mesh_slice(lut_2d_skycoord_no_mesh):
sub_ltc = lut_2d_skycoord_no_mesh[1:3, 1:2]
assert sub_ltc.table.shape == (2, 1)
Expand Down Expand Up @@ -538,7 +538,7 @@ def test_mtc_dropped_quantity_table(lut_1d_time, lut_2d_distance_no_mesh):
assert len(sub._table_coords) == 1
assert len(sub._dropped_coords) == 1

pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
pytest.importorskip("gwcs", minversion="0.17")

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand All @@ -562,7 +562,7 @@ def test_mtc_dropped_quantity_inside_table(lut_3d_distance_mesh):

assert len(sub.table) == 2

pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
pytest.importorskip("gwcs", minversion="0.17")

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand Down Expand Up @@ -593,7 +593,7 @@ def test_mtc_dropped_quantity_inside_table_no_mesh(lut_2d_distance_no_mesh):

assert len(sub.table) == 2

pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
pytest.importorskip("gwcs", minversion="0.17")

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand All @@ -608,7 +608,7 @@ def test_mtc_dropped_quantity_join_drop_table(lut_1d_time, lut_3d_distance_mesh)
assert len(sub._table_coords) == 2
assert len(sub._dropped_coords) == 0

pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
pytest.importorskip("gwcs", minversion="0.17")

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand All @@ -621,7 +621,7 @@ def test_mtc_dropped_quantity_join_drop_table(lut_1d_time, lut_3d_distance_mesh)
assert len(sub._table_coords) == 1
assert len(sub._dropped_coords) == 1

pytest.importorskip("gwcs", minversion="0.16.2a1.dev17")
pytest.importorskip("gwcs", minversion="0.17")

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand Down

0 comments on commit b858e67

Please sign in to comment.