Skip to content

Commit d955fe4

Browse files
Added test to show astropy#11060 has been fixed
1 parent 40dcca5 commit d955fe4

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎astropy/modeling/tests/test_core.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,40 @@ def test_prepare_outputs_single_entry_vector():
593593
np.testing.assert_array_equal(output, [0.9500411305585278])
594594

595595

596+
def test_prepare_outputs_sparse_grid():
597+
"""
598+
Test to show that #11060 has been solved.
599+
"""
600+
601+
shape = (3, 3)
602+
data = np.arange(np.product(shape)).reshape(shape) * u.m / u.s
603+
604+
points_unit = u.pix
605+
points = [np.arange(size) * points_unit for size in shape]
606+
607+
kwargs = {
608+
'bounds_error': False,
609+
'fill_value': np.nan,
610+
'method': 'nearest',
611+
}
612+
613+
transform = models.Tabular2D(points, data, **kwargs)
614+
615+
points = np.meshgrid(np.arange(3), np.arange(3), indexing='ij', sparse=True)
616+
x = points[0] * u.pix
617+
y = points[1] * u.pix
618+
value = transform(x, y)
619+
truth = np.array([[0.], [4.], [8.]]) * u.m / u.s
620+
assert (value == truth).all()
621+
622+
points = np.meshgrid(np.arange(3), np.arange(3), indexing='ij', sparse=False) * u.pix
623+
value = transform(*points)
624+
truth = np.array([[0., 1., 2.],
625+
[3., 4., 5.],
626+
[6., 7., 8.]]) * u.m / u.s
627+
assert (value == truth).all()
628+
629+
596630
def test_coerce_units():
597631
model = models.Polynomial1D(1, c0=1, c1=2)
598632

0 commit comments

Comments
 (0)