Uh oh!
There was an error while loading. Please reload this page.
raise ValueError if the the number of regression points is less than the number of parameters in _residual - #249
Conversation
…n the number of parameters in `_residual`
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## main #249 +/- ##
==========================================
+ Coverage 99.22% 99.92% +0.70%
==========================================
Files 23 23 Lines 1285 1318 +33 ==========================================
+ Hits 1275 1317 +42 + Misses 10 1 -9
🚀 New features to boost your workflow:
|
ycexiao
commented
Aug 18, 2025
@sbillinge, it's ready for review. |
Make sure that the argument parser captures the error in I would also like it if there was a test that this error is indeed being captured? Maybe one test for the CLI side and one for the morphpy side? |
sbillinge
commented
Aug 20, 2025
@ycexiao@Sparks29032 I don't really mind where the error is caught in python or in CLI as long as the help message helps the user as much as possible to come up with a fix. Saying "adjust somethihng" is not so helpful because what do I adjust it to? or how do I figure out what to adjust it to? @Sparks29032 is there a way to know and suggest what adjustment will fix this? If it is trial and error to try and fix it, or the user can plot the polynomial and see where it goes negative or some such thing, this is helpful information to help them debug. We don't want to write a book, but some brief and hdlpful explanation would be good. Yes, we need a test for this. If we implement it as a check in the CLI we could test that there too. As a rule we have not been doing much validation at all in the CLI. The main reason is just not enough time in the day. So I would not really prioritize that that atm unless it is quick and painless. |
Sparks29032
commented
Aug 20, 2025
What I am saying is that the error is not going to display to a CLI user if we do not exit. We want a wrapper around the refine call in the |
sbillinge
commented
Aug 20, 2025
aren't we raising an exception? Are saying the exception gets caught and handled somewhere higher up in the code stack? If not then it will crash with the exception (which would be the desired behavior)? |
ycexiao
commented
Aug 20, 2025
How about "Please make sure the overlapping domain between the morphed function and the target function is sufficiently large, or reduce the number of parameters?"
I will make sure both the CLI user and the scripts user will see the error message.
Yes, I will add a test for it. |
Sparks29032
commented
Aug 20, 2025
Sounds good for the adjustment. Would also be helpful to mention the size of the function and number of parameters you are optimizing to the user so they can see exactly how many more parameters they must reduce by. |
ycexiao
left a comment
There was a problem hiding this comment.
@sbillinge@Sparks29032, it's ready for review.
| if len(rvec) < len(pvals): | ||
| raise ValueError( | ||
| f"\nNumber of shared grid points: {len(rvec)}\n" |
There was a problem hiding this comment.
Print the size of the function and the number of parameters.
Uh oh!
There was an error while loading. Please reload this page.
| raise ValueError( | ||
| "Not enough shared grid points between morphed function " | ||
| "and target function to fit the chosen parameters. " | ||
| "Please adjust the functions or " |
There was a problem hiding this comment.
Nicely done. Is there a way to give guidance on how the to "adjust the functions"?
There was a problem hiding this comment.
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."
| "Not enough shared grid points between morphed function " | ||
| "and target function to fit the chosen parameters. " | ||
| "Please adjust the functions or " | ||
| "between morphed function and target function to fit " |
There was a problem hiding this comment.
please check, is "between morphed function" repeated here?
There was a problem hiding this comment.
Yes, it is a typo. It is fixed in a newer commit.
Uh oh!
There was an error while loading. Please reload this page.
ycexiao
left a comment
There was a problem hiding this comment.
@sbillinge@Sparks29032, it's ready for review.
I'm not sure the following lines are being run in the test (see CodeCov). When the error is thrown and Pytest catches it, the lines below where the error is thrown are not run. You will need some other way to check the error message is correct. Otherwise, I have no other comments, seems good. |
ycexiao
left a comment
There was a problem hiding this comment.
@sbillinge@Sparks29032, it's ready for review.
| ValueError, | ||
| ) as error: | ||
| refiner.refine(*refpars) | ||
| actual_error_message = str(error.value) |
There was a problem hiding this comment.
These two lines were skipped because of the wrong indentation. It is fixed now.
sbillinge
left a comment
There was a problem hiding this comment.
I am not sure I like this. Why are we doing this? Lot's of extra complicated code to maintain, but what benefit does it get us exactly? Let's discuss a bit. I am happy to be convinced, but in general, simpler is better for a research group like ours.....
Sparks29032
commented
Aug 22, 2025
Two main reasons why I'd like this PR: |
ycexiao
commented
Aug 22, 2025
@sbillinge, are you referring to the commit "use a custom error to stop leatsq"? Actually, it is not a good fix and it is reverted. The actual modification is from chore: fix the code indentation. where only the code indentation is changed so it is not complicated. |
Uh oh!
There was an error while loading. Please reload this page.
sbillinge
commented
Aug 23, 2025
ok, sounds good all around |
What problem does this PR address?
Address the second item in #241.
What should the reviewer(s) do?
Please check the modifications.