Skip to content

Commit 99afb15

Browse files
committed
chore: update error message
1 parent c9ce954 commit 99afb15

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/diffpy/morph/morphs/morphsqueeze.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,26 @@ def _set_squeeze_info(self, x, x_sorted):
7878
if list(x) != list(x_sorted):
7979
if self.check_increase:
8080
raise ValueError(
81-
"Squeezed grid is not strictly increasing."
82-
"Please (1) decrease the order of your polynomial and "
83-
"(2) ensure that the initial polynomial morph result in "
84-
"good agreement between your reference and "
85-
"objective functions."
81+
"Error: The polynomial applied by the squeeze morph has "
82+
"resulted in a grid that is no longer strictly increasing"
83+
", likely due to a convergence issue. A strictly "
84+
"increasing grid is required for diffpy.morph to compute "
85+
"the morphed function through cubic spline interpolation. "
86+
"Here are some suggested methods to resolve this:\n"
87+
"(1) Please decrease the order of your polynomial and "
88+
"try again.\n"
89+
"(2) If you are using initial guesses of all 0, please "
90+
"ensure your objective function only requires a small "
91+
"polynomial squeeze to match your reference. (In other "
92+
"words, there is good agreement between the two functions"
93+
".)\n"
94+
"(3) If you expect a large polynomial squeeze to be needed"
95+
", please ensure your initial parameters for the "
96+
"polynomial morph result in good agreement between your "
97+
"reference and objective functions. One way to obtain "
98+
"such parameters is to first apply a --hshift and "
99+
"--stretch morph. Then, use the hshift parameter for a0 "
100+
"and stretch parameter for a1."
86101
)
87102
else:
88103
overlapping_regions = self._get_overlapping_regions(x)

tests/test_morphsqueeze.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ def test_sort_squeeze_bad(user_filesystem, squeeze_coeffs, x_morph):
215215
apply=True,
216216
)
217217
actual_emsg = str(excinfo.value)
218-
expected_emsg = "Squeezed grid is not strictly increasing."
218+
expected_emsg = (
219+
"Error: The polynomial applied by the squeeze morph has "
220+
"resulted in a grid that is no longer strictly increasing"
221+
)
219222
assert expected_emsg in actual_emsg
220223

221224
# call in CLI without --check-increase

0 commit comments

Comments
 (0)