Skip to content

Commit d3e5a91

Browse files
committed
Add more tests
1 parent 32a5abd commit d3e5a91

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

tests/test_morphshift.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,36 @@ def test_morphshift_extrapolate(user_filesystem, capsys, hshift, wmsg_gen):
105105
)
106106
with pytest.warns(UserWarning, match=expected_wmsg):
107107
single_morph(parser, opts, pargs, stdout_flag=False)
108+
109+
110+
def test_morphshift_no_warning(user_filesystem):
111+
# Apply a shift with no extrapolation
112+
# There should be no warning or errors produced
113+
x_morph = numpy.linspace(0, 10, 101)
114+
y_morph = numpy.sin(x_morph)
115+
x_target = x_morph.copy()
116+
y_target = y_morph.copy()
117+
morphpy.morph_arrays(
118+
numpy.array([x_morph, y_morph]).T,
119+
numpy.array([x_target, y_target]).T,
120+
hshift=0,
121+
apply=True,
122+
)
123+
124+
# CLI test
125+
morph_file, target_file = create_morph_data_file(
126+
user_filesystem / "cwd_dir", x_morph, y_morph, x_target, y_target
127+
)
128+
129+
parser = create_option_parser()
130+
(opts, pargs) = parser.parse_args(
131+
[
132+
"--scale=1",
133+
"--hshift=0",
134+
f"{morph_file.as_posix()}",
135+
f"{target_file.as_posix()}",
136+
"--apply",
137+
"-n",
138+
]
139+
)
140+
single_morph(parser, opts, pargs, stdout_flag=False)

tests/test_morphsqueeze.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,44 @@ def test_morphsqueeze_extrapolate(user_filesystem, squeeze_coeffs, wmsg_gen):
174174
single_morph(parser, opts, pargs, stdout_flag=False)
175175

176176

177+
def test_morphsqueeze_no_warning(user_filesystem):
178+
# Apply a squeeze with no extrapolation
179+
# There should be no warning or errors produced
180+
squeeze_coeffs = {"a0": 0, "a1": 0}
181+
x_morph = np.linspace(0, 10, 101)
182+
y_morph = np.sin(x_morph)
183+
x_target = x_morph.copy()
184+
y_target = y_morph.copy()
185+
morph = MorphSqueeze()
186+
morph.squeeze = squeeze_coeffs
187+
coeffs = [squeeze_coeffs[f"a{i}"] for i in range(len(squeeze_coeffs))]
188+
morphpy.morph_arrays(
189+
np.array([x_morph, y_morph]).T,
190+
np.array([x_target, y_target]).T,
191+
squeeze=coeffs,
192+
apply=True,
193+
)
194+
195+
# CLI test
196+
morph_file, target_file = create_morph_data_file(
197+
user_filesystem / "cwd_dir", x_morph, y_morph, x_target, y_target
198+
)
199+
200+
parser = create_option_parser()
201+
(opts, pargs) = parser.parse_args(
202+
[
203+
"--scale=1",
204+
"--squeeze",
205+
",".join(map(str, coeffs)),
206+
f"{morph_file.as_posix()}",
207+
f"{target_file.as_posix()}",
208+
"--apply",
209+
"-n",
210+
]
211+
)
212+
single_morph(parser, opts, pargs, stdout_flag=False)
213+
214+
177215
def test_non_unique_grid():
178216
# Test giving morphsqueeze a non-unique grid
179217
# Expect it to return a unique grid

tests/test_morphstretch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def test_morphshift_no_warning(user_filesystem):
155155
parser = create_option_parser()
156156
(opts, pargs) = parser.parse_args(
157157
[
158+
"--scale=1",
158159
"--stretch=0",
159160
f"{morph_file.as_posix()}",
160161
f"{target_file.as_posix()}",

0 commit comments

Comments
 (0)