4646@pytest .mark .parametrize ("squeeze_coeffs" , squeeze_coeffs_dic )
4747def test_morphsqueeze (x_morph , x_target , squeeze_coeffs ):
4848 y_target = np .sin (x_target )
49+ y_morph = np .sin (x_morph )
50+ # expected output
4951 coeffs = [squeeze_coeffs [f"a{ i } " ] for i in range (len (squeeze_coeffs ))]
5052 squeeze_polynomial = Polynomial (coeffs )
5153 x_squeezed = x_morph + squeeze_polynomial (x_morph )
52- y_morph = np .sin (x_squeezed )
53- low_extrap = np .where (x_morph < x_squeezed [0 ])[0 ]
54- high_extrap = np .where (x_morph > x_squeezed [- 1 ])[0 ]
55- extrap_index_low_expected = low_extrap [- 1 ] if low_extrap .size else None
56- extrap_index_high_expected = high_extrap [0 ] if high_extrap .size else None
54+ y_morph_expected = y_morph
5755 x_morph_expected = x_morph
58- y_morph_expected = np .sin (x_morph )
56+ x_target_expected = x_target
57+ y_target_expected = y_target
58+ # actual output
5959 morph = MorphSqueeze ()
60+ y_morph = np .sin (x_squeezed )
6061 morph .squeeze = squeeze_coeffs
6162 x_morph_actual , y_morph_actual , x_target_actual , y_target_actual = morph (
6263 x_morph , y_morph , x_target , y_target
6364 )
64- extrap_index_low = morph .extrap_index_low
65- extrap_index_high = morph .extrap_index_high
65+
66+ extrap_low = np .where (x_morph < min (x_squeezed ))[0 ]
67+ extrap_high = np .where (x_morph > max (x_squeezed ))[0 ]
68+ extrap_index_low = extrap_low [- 1 ] if extrap_low .size else None
69+ extrap_index_high = extrap_high [0 ] if extrap_high .size else None
6670 if extrap_index_low is None :
6771 extrap_index_low = 0
6872 elif extrap_index_high is None :
@@ -82,11 +86,9 @@ def test_morphsqueeze(x_morph, x_target, squeeze_coeffs):
8286 y_morph_expected [extrap_index_high :],
8387 atol = 1e-3 ,
8488 )
85- assert morph .extrap_index_low == extrap_index_low_expected
86- assert morph .extrap_index_high == extrap_index_high_expected
8789 assert np .allclose (x_morph_actual , x_morph_expected )
88- assert np .allclose (x_target_actual , x_target )
89- assert np .allclose (y_target_actual , y_target )
90+ assert np .allclose (x_target_actual , x_target_expected )
91+ assert np .allclose (y_target_actual , y_target_expected )
9092
9193
9294@pytest .mark .parametrize (
0 commit comments