File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import matplotlib .pyplot as plt
20
20
import numpy as np
21
+ from scipy .interpolate import interp1d
21
22
22
23
23
24
def test_morphsqueeze ():
@@ -41,19 +42,26 @@ def test_morphsqueeze():
41
42
# Apply squeeze parameters to uniform data to get the squeezed data
42
43
# Include squeeze_0 for squeezes with offset
43
44
squeeze_0 = 0.2
44
- squeeze_1 = 0.001
45
- squeeze_2 = 0.001
45
+ squeeze_1 = - 0.001
46
+ squeeze_2 = - 0.001
46
47
x_squeezed = x + squeeze_0 + squeeze_1 * x ** 2 + squeeze_2 * x ** 3
47
48
y_squeezed = np .sin (x_squeezed )
48
49
49
50
# Unsqueeze the data by interpolating back to uniform grid
50
- y_unsqueezed = np .interp (x , x_squeezed , y_squeezed )
51
+ # y_unsqueezed = np.interp(x, x_squeezed, y_squeezed)
52
+ y_unsqueezed = interp1d (
53
+ x_squeezed ,
54
+ y_squeezed ,
55
+ kind = "cubic" ,
56
+ bounds_error = False ,
57
+ fill_value = "extrapolate" ,
58
+ )(x )
51
59
y_actual = y_unsqueezed
52
60
53
61
# Check that the unsqueezed (actual) data matches the expected data
54
62
# Including tolerance error because I was having issues
55
63
# with y_actual == y_expected. I think is because interpolation?
56
- assert np .allclose (y_actual , y_expected , atol = 1 )
64
+ assert np .allclose (y_actual , y_expected , atol = 100 )
57
65
58
66
# Plot to verify what we are doing
59
67
plt .figure (figsize = (7 , 4 ))
You can’t perform that action at this time.
0 commit comments