Skip to content

Commit 71f10e5

Browse files
committed
chore: more concise error message
1 parent 9832900 commit 71f10e5

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/diffpy/morph/refine.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ def _residual(self, pvals):
8585
rvec = _y_target - _y_morph
8686
if len(rvec) < len(pvals):
8787
raise ValueError(
88-
f"\nNumber of shared grid points: {len(rvec)}\n"
89-
f"Number of parameters: {len(pvals)}\n"
90-
"Not enough shared grid points "
91-
"between the morphed function and the target function to fit "
92-
"the chosen parameters.\n"
93-
"Please make sure the overlapping domain between the morphed "
94-
"function and the target function is sufficiently large, or "
95-
"reduce the number of parameters."
88+
f"\nNumber of parameters (currently {len(pvals)}) cannot "
89+
"exceed the number of shared grid points "
90+
f"(currently {len(rvec)}). "
91+
"Please reduce the number of morphing parameters or "
92+
"provide new morphing and target functions with more "
93+
"shared grid points."
9694
)
9795
# If first time computing residual
9896
if self.res_length is None:

tests/test_refine.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,12 @@ def test_refine_grid_bad(self, user_filesystem):
194194
refiner = Refiner(chain, grid1, func1, grid2, func2)
195195
refpars = ["stretch", "scale", "smear"]
196196
expected_error_message = (
197-
"\nNumber of shared grid points: 2\n"
198-
"Number of parameters: 3\n"
199-
"Not enough shared grid points "
200-
"between the morphed function and the target function to fit "
201-
"the chosen parameters.\n"
202-
"Please make sure the overlapping domain between the morphed "
203-
"function and the target function is sufficiently large, or "
204-
"reduce the number of parameters."
197+
f"\nNumber of parameters (currently 3) cannot "
198+
"exceed the number of shared grid points "
199+
f"(currently 2). "
200+
"Please reduce the number of morphing parameters or "
201+
"provide new morphing and target functions with more "
202+
"shared grid points."
205203
)
206204
with pytest.raises(
207205
ValueError,

0 commit comments

Comments
 (0)