@@ -107,22 +107,22 @@ def test_squeeze_with_morph_func():
107
107
squeeze_init = [0 , - 0.001 , - 0.0001 , 0.0001 ]
108
108
x_morph = np .linspace (0 , 10 , 101 )
109
109
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
111
111
)
112
- expected_squeeze = [0 , - 0.01 , - 0.0001 , 0.0002 ]
112
+ expected_squeeze = [0 , 0.01 , 0.0001 , 0.001 ]
113
113
expected_scale = 1 / 2
114
- x_target = x_morph . copy ( )
114
+ x_target = np . linspace ( 0 , 10 , 101 )
115
115
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 )
117
117
morph_rv = morph (x_morph , y_morph , x_target , y_target , ** cfg )
118
118
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 )
126
126
127
127
128
128
def test_funcy_with_morph_func ():
@@ -137,9 +137,11 @@ def linear_function(x, y, scale, offset):
137
137
cfg ["function" ] = linear_function
138
138
morph_rv = morph (x_morph , y_morph , x_target , y_target , ** cfg )
139
139
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 )
143
145
fitted_parameters = morphed_cfg ["parameters" ]
144
146
assert np .allclose (fitted_parameters ["scale" ], 2 , atol = 1e-6 )
145
147
assert np .allclose (fitted_parameters ["offset" ], 0.4 , atol = 1e-6 )
0 commit comments