Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add more tests
  • Loading branch information
Sparks29032 committed Dec 19, 2025
commit d3e5a91e947ff4c764ee580631dd19f270d033eb
33 changes: 33 additions & 0 deletions tests/test_morphshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,36 @@ def test_morphshift_extrapolate(user_filesystem, capsys, hshift, wmsg_gen):
)
with pytest.warns(UserWarning, match=expected_wmsg):
single_morph(parser, opts, pargs, stdout_flag=False)


def test_morphshift_no_warning(user_filesystem):
# Apply a shift with no extrapolation
# There should be no warning or errors produced
x_morph = numpy.linspace(0, 10, 101)
y_morph = numpy.sin(x_morph)
x_target = x_morph.copy()
y_target = y_morph.copy()
morphpy.morph_arrays(
numpy.array([x_morph, y_morph]).T,
numpy.array([x_target, y_target]).T,
hshift=0,
apply=True,
)

# CLI test
morph_file, target_file = create_morph_data_file(
user_filesystem / "cwd_dir", x_morph, y_morph, x_target, y_target
)

parser = create_option_parser()
(opts, pargs) = parser.parse_args(
[
"--scale=1",
"--hshift=0",
f"{morph_file.as_posix()}",
f"{target_file.as_posix()}",
"--apply",
"-n",
]
)
single_morph(parser, opts, pargs, stdout_flag=False)
38 changes: 38 additions & 0 deletions tests/test_morphsqueeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,44 @@ def test_morphsqueeze_extrapolate(user_filesystem, squeeze_coeffs, wmsg_gen):
single_morph(parser, opts, pargs, stdout_flag=False)


def test_morphsqueeze_no_warning(user_filesystem):
# Apply a squeeze with no extrapolation
# There should be no warning or errors produced
squeeze_coeffs = {"a0": 0, "a1": 0}
x_morph = np.linspace(0, 10, 101)
y_morph = np.sin(x_morph)
x_target = x_morph.copy()
y_target = y_morph.copy()
morph = MorphSqueeze()
morph.squeeze = squeeze_coeffs
coeffs = [squeeze_coeffs[f"a{i}"] for i in range(len(squeeze_coeffs))]
morphpy.morph_arrays(
np.array([x_morph, y_morph]).T,
np.array([x_target, y_target]).T,
squeeze=coeffs,
apply=True,
)

# CLI test
morph_file, target_file = create_morph_data_file(
user_filesystem / "cwd_dir", x_morph, y_morph, x_target, y_target
)

parser = create_option_parser()
(opts, pargs) = parser.parse_args(
[
"--scale=1",
"--squeeze",
",".join(map(str, coeffs)),
f"{morph_file.as_posix()}",
f"{target_file.as_posix()}",
"--apply",
"-n",
]
)
single_morph(parser, opts, pargs, stdout_flag=False)


def test_non_unique_grid():
# Test giving morphsqueeze a non-unique grid
# Expect it to return a unique grid
Expand Down
1 change: 1 addition & 0 deletions tests/test_morphstretch.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test_morphshift_no_warning(user_filesystem):
parser = create_option_parser()
(opts, pargs) = parser.parse_args(
[
"--scale=1",
"--stretch=0",
f"{morph_file.as_posix()}",
f"{target_file.as_posix()}",
Expand Down
Loading