-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RectangleModule implements 'linear' incorrectly? #815
Comments
@arunpersaud Thanks! Yep, both code and docs are just plain wrong. I have no explanation other than stupidity ;). I might suggest that code and doc would be best served by changing the block at Line 477 in 86a2bdc
elif form == 'linear':
out = (np.minimum(1, np.maximum(-1, arg1)) +
np.minimum(1, np.maximum(-1, arg2)))/ 2.0 If you're willing to make a Pull Request (including doc change), that would be great. If not, that's fine too and we can make this change. Thanks again! |
Sure, I'll give it a try... |
Fix the linear mode for RectangleModel. Also update the documentation and update the tests. Tests: * Using numpy functions now allows lineshape.rectangle to handle single floats, so the tests needed to be updated * added tests for step and rectangle to make sure we get A/2 at mu1 (and mu2) Docs: * update to reflect code and make brackets in LaTeX equations a bit nicer
Fix the linear mode for RectangleModel. Also update the documentation and update the tests. Tests: * Using numpy functions now allows lineshape.rectangle to handle single floats, so the tests needed to be updated * added tests for step and rectangle to make sure we get A/2 at mu1 (and mu2) Docs: * update to reflect code and make brackets in LaTeX equations a bit nicer Closes: lmfit#815
First Time Issue Code
Yes, I read the instructions and I am sure this is a GitHub Issue.
Description
The RectangleModule linear case seems have a bug in its implementation.
The docs say that for the RectangleModule the fitting function returns A/2 at u1 and u2.
The docs give the following function:
and the code here defines the function slightly different:
It probably should be:
A Minimal, Complete, and Verifiable example
Here is a short code snippet that plots all 3 cases
Which results in the following plot:
Notes
Happy to supply a PR for this if the above is correct. If tests are requried should lineshape.py be tested? if so what should be tested? f(u1,2) = A/2 and integral == 1?
Version information
Code taken from the current (2022-10-23) web page and commit 86a2bdc
The text was updated successfully, but these errors were encountered: