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
Next Next commit
chore: more concise error message
  • Loading branch information
ycexiao committed Aug 21, 2025
commit 71f10e585617be3b09aa79023756ed338b558a41
14 changes: 6 additions & 8 deletions src/diffpy/morph/refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@ def _residual(self, pvals):
rvec = _y_target - _y_morph
if len(rvec) < len(pvals):
raise ValueError(
f"\nNumber of shared grid points: {len(rvec)}\n"
f"Number of parameters: {len(pvals)}\n"
"Not enough shared grid points "
"between the morphed function and the target function to fit "
"the chosen parameters.\n"
"Please make sure the overlapping domain between the morphed "
"function and the target function is sufficiently large, or "
"reduce the number of parameters."
f"\nNumber of parameters (currently {len(pvals)}) cannot "
Comment thread
sbillinge marked this conversation as resolved.
"exceed the number of shared grid points "
f"(currently {len(rvec)}). "
"Please reduce the number of morphing parameters or "
"provide new morphing and target functions with more "
"shared grid points."
)
# If first time computing residual
if self.res_length is None:
Expand Down
14 changes: 6 additions & 8 deletions tests/test_refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,12 @@ def test_refine_grid_bad(self, user_filesystem):
refiner = Refiner(chain, grid1, func1, grid2, func2)
refpars = ["stretch", "scale", "smear"]
expected_error_message = (
"\nNumber of shared grid points: 2\n"
"Number of parameters: 3\n"
"Not enough shared grid points "
"between the morphed function and the target function to fit "
"the chosen parameters.\n"
"Please make sure the overlapping domain between the morphed "
"function and the target function is sufficiently large, or "
"reduce the number of parameters."
f"\nNumber of parameters (currently 3) cannot "
"exceed the number of shared grid points "
f"(currently 2). "
"Please reduce the number of morphing parameters or "
"provide new morphing and target functions with more "
"shared grid points."
)
with pytest.raises(
ValueError,
Expand Down