Skip to content

Commit 11a9386

Browse files
Added tests for astropy#11360 fixes.
1 parent cf12b18 commit 11a9386

1 file changed

Lines changed: 48 additions & 9 deletions

File tree

‎astropy/modeling/tests/test_core.py‎

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,54 @@ def test_prepare_outputs_mixed_broadcast():
530530

531531
model = models.Gaussian2D(1, 2, 3 ,4, 5)
532532

533-
output0 = model([1, 2], 3)
534-
assert output0.shape == (2,)
535-
assert output0[0] == 0.9692332344763441
536-
assert output0[1] == 1.0
537-
538-
output1 = model(4, [5, 6])
539-
assert output1.shape == (2,)
540-
assert output1[0] == 0.8146473164114145
541-
assert output1[1] == 0.7371233743916278
533+
output = model([1, 2], 3)
534+
assert output.shape == (2,)
535+
np.testing.assert_array_equal(output, [0.9692332344763441, 1.0])
536+
537+
output = model(4, [5, 6])
538+
assert output.shape == (2,)
539+
np.testing.assert_array_equal(output, [0.8146473164114145, 0.7371233743916278])
540+
541+
542+
def test_prepare_outputs_complex_reshape():
543+
x = np.array([[1, 2, 3, 4, 5],
544+
[6, 7, 8, 9, 10],
545+
[11, 12, 13, 14, 15]])
546+
y = np.array([[16, 17, 18, 19, 20],
547+
[21, 22, 23, 24, 25],
548+
[26, 27, 28, 29, 30]])
549+
550+
m = models.Identity(3) | models.Mapping((2, 1, 0))
551+
m.bounding_box = ((0, 100), (0, 200), (0, 50))
552+
mf = models.fix_inputs(m, {2: 22})
553+
t = mf | models.Mapping((2, 1), n_inputs=3)
554+
555+
output = mf(1, 2)
556+
assert output == (22, 2, 1)
557+
558+
output = t(1, 2)
559+
assert output == (1, 2)
560+
561+
output = t(x, y)
562+
assert len(output) == 2
563+
np.testing.assert_array_equal(output[0], x)
564+
np.testing.assert_array_equal(output[1], y)
565+
566+
m = models.Identity(3) | models.Mapping((0, 1, 2))
567+
m.bounding_box = ((0, 100), (0, 200), (0, 50))
568+
mf = models.fix_inputs(m, {2: 22})
569+
t = mf | models.Mapping((0, 1), n_inputs=3)
570+
571+
output = mf(1, 2)
572+
assert output == (1, 2, 22)
573+
574+
output = t(1, 2)
575+
assert output == (1, 2)
576+
577+
output = t(x, y)
578+
assert len(output) == 2
579+
np.testing.assert_array_equal(output[0], x)
580+
np.testing.assert_array_equal(output[1], y)
542581

543582

544583
def test_coerce_units():

0 commit comments

Comments
 (0)