@@ -107,22 +107,22 @@ def test_squeeze_with_morph_func():
107107 squeeze_init = [0 , - 0.001 , - 0.0001 , 0.0001 ]
108108 x_morph = np .linspace (0 , 10 , 101 )
109109 y_morph = 2 * np .sin (
110- x_morph + x_morph * ( - 0.01 ) - 0.0001 * x_morph ** 2 + 0.0002 * x_morph ** 3
110+ x_morph + x_morph * 0.01 + 0.0001 * x_morph ** 2 + 0.001 * x_morph ** 3
111111 )
112- expected_squeeze = [0 , - 0.01 , - 0.0001 , 0.0002 ]
112+ expected_squeeze = [0 , 0.01 , 0.0001 , 0.001 ]
113113 expected_scale = 1 / 2
114- x_target = x_morph . copy ( )
114+ x_target = np . linspace ( 0 , 10 , 101 )
115115 y_target = np .sin (x_target )
116- cfg = morph_default_config (scale = 1.1 , squeeze = squeeze_init ) # off init
116+ cfg = morph_default_config (scale = 1.1 , squeeze = squeeze_init )
117117 morph_rv = morph (x_morph , y_morph , x_target , y_target , ** cfg )
118118 morphed_cfg = morph_rv ["morphed_config" ]
119- # verified they are morphable
120- x1 , y1 , x0 , y0 = morph_rv [ "morph_chain" ]. xyallout
121- assert np . allclose ( x0 , x1 )
122- assert np .allclose (y0 , y1 , atol = 1e-3 ) # numerical error -> 1e-4
123- # verify morphed param
124- assert np .allclose (expected_squeeze , morphed_cfg ["squeeze" ], atol = 1e-4 )
125- assert np .allclose (expected_scale , morphed_cfg ["scale" ], atol = 1e-4 )
119+ x_morph_out , y_morph_out , x_target_out , y_target_out = morph_rv [
120+ "morph_chain"
121+ ]. xyallout
122+ assert np .allclose (x_morph_out , x_target_out )
123+ assert np . allclose ( y_morph_out , y_target_out , atol = 1e-6 )
124+ assert np .allclose (expected_squeeze , morphed_cfg ["squeeze" ], atol = 1e-6 )
125+ assert np .allclose (expected_scale , morphed_cfg ["scale" ], atol = 1e-6 )
126126
127127
128128def test_funcy_with_morph_func ():
@@ -137,9 +137,11 @@ def linear_function(x, y, scale, offset):
137137 cfg ["function" ] = linear_function
138138 morph_rv = morph (x_morph , y_morph , x_target , y_target , ** cfg )
139139 morphed_cfg = morph_rv ["morphed_config" ]
140- x1 , y1 , x0 , y0 = morph_rv ["morph_chain" ].xyallout
141- assert np .allclose (x0 , x1 )
142- assert np .allclose (y0 , y1 , atol = 1e-6 )
140+ x_morph_out , y_morph_out , x_target_out , y_target_out = morph_rv [
141+ "morph_chain"
142+ ].xyallout
143+ assert np .allclose (x_morph_out , x_target_out )
144+ assert np .allclose (y_morph_out , y_target_out , atol = 1e-6 )
143145 fitted_parameters = morphed_cfg ["parameters" ]
144146 assert np .allclose (fitted_parameters ["scale" ], 2 , atol = 1e-6 )
145147 assert np .allclose (fitted_parameters ["offset" ], 0.4 , atol = 1e-6 )
0 commit comments