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
23 changes: 23 additions & 0 deletions news/enough-regression-points.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Raise ``ValueError`` if the number of shared grid points between morphed and target functions is less than the number of parameters.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
11 changes: 10 additions & 1 deletion src/diffpy/morph/refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ def _residual(self, pvals):
self.x_morph, self.y_morph, self.x_target, self.y_target
)
rvec = _y_target - _y_morph

if len(rvec) < len(pvals):
raise ValueError(
"Not enough shared grid points between morphed function "
"and target function to fit the chosen parameters. "
"Please adjust the functions or "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done. Is there a way to give guidance on how the to "adjust the functions"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current error message is: "Please make sure the overlapping domain between the morphed function and the target function is sufficiently large, or reduce the number of parameters."

"reduce the number of parameters."
)
# If first time computing residual
if self.res_length is None:
self.res_length = len(rvec)
Expand Down Expand Up @@ -145,6 +151,9 @@ def refine(self, *args, **kw):
------
ValueError
Exception raised if a minimum cannot be found.
ValueError
If the number of shared grid points between morphed function and
target function is smaller than the number of parameters.
"""

self.pars = args or self.chain.config.keys()
Expand Down
Loading