Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions ndcube/extra_coords/tests/test_extra_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,7 @@
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)
assert ec.wcs.pixel_to_world(0, 0)

Check warning on line 290 in ndcube/extra_coords/tests/test_extra_coords.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_extra_coords.py#L290

Added line #L290 was not covered by tests


# Extra Coords with NDCube
Expand Down
49 changes: 24 additions & 25 deletions ndcube/extra_coords/tests/test_lookup_table_coord.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gwcs
import gwcs.coordinate_frames as cf
import numpy as np
import pytest
Expand Down Expand Up @@ -31,8 +32,9 @@

@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 @@ -191,28 +193,26 @@
assert u.allclose(pix, pixel_coords.value)


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

assert ltc.model.n_inputs == 3
assert ltc.model.n_outputs == 3

# Known failure due to gwcs#120
pixel_coords = (0, 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)

Check warning on line 206 in ndcube/extra_coords/tests/test_lookup_table_coord.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_lookup_table_coord.py#L205-L206

Added lines #L205 - L206 were not covered by tests

# pixel_coords = (0, 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)
assert isinstance(ltc.wcs, gwcs.WCS)

Check warning on line 208 in ndcube/extra_coords/tests/test_lookup_table_coord.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_lookup_table_coord.py#L208

Added line #L208 was not covered by tests

# assert isinstance(ltc.wcs, gwcs.WCS)
#
# sub_ltc = ltc[0:4, 0:5, 0:6]
# assert sub_ltc.delayed_models[0].lookup_table[0].shape == (4, )
# assert sub_ltc.delayed_models[0].lookup_table[1].shape == (5, )
# assert sub_ltc.delayed_models[0].lookup_table[2].shape == (6, )
sub_ltc = ltc[0:4, 0:5, 0:6]
assert sub_ltc.delayed_models[0].lookup_table[0].shape == (4, )
assert sub_ltc.delayed_models[0].lookup_table[1].shape == (5, )
assert sub_ltc.delayed_models[0].lookup_table[2].shape == (6, )

Check warning on line 213 in ndcube/extra_coords/tests/test_lookup_table_coord.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_lookup_table_coord.py#L210-L213

Added lines #L210 - L213 were not covered by tests


@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 +221,11 @@

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)

Check warning on line 228 in ndcube/extra_coords/tests/test_lookup_table_coord.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_lookup_table_coord.py#L228

Added line #L228 was not covered by tests


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

@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 +413,6 @@
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 +422,6 @@
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 +537,7 @@
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")

Check warning on line 540 in ndcube/extra_coords/tests/test_lookup_table_coord.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_lookup_table_coord.py#L540

Added line #L540 was not covered by tests

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand All @@ -562,7 +561,7 @@

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 +592,7 @@

assert len(sub.table) == 2

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

Check warning on line 595 in ndcube/extra_coords/tests/test_lookup_table_coord.py

View check run for this annotation

Codecov / codecov/patch

ndcube/extra_coords/tests/test_lookup_table_coord.py#L595

Added line #L595 was not covered by tests

dwd = sub.dropped_world_dimensions
assert isinstance(dwd, dict)
Expand All @@ -608,7 +607,7 @@
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 +620,7 @@
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
Loading