Skip to content
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

Fix linear StepModel, wrong function definition #794

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

matpompili
Copy link
Contributor

@matpompili matpompili commented Jul 14, 2022

Description

lmfit.models.StepModel(form="linear") does not match the definition given in the documentation. The other step functions are centered around center, while linear, as of now, starts at center.
This PR fixes the function definition.

This example code shows the difference:

import lmfit
import numpy as np
import matplotlib.pyplot as plt

model = lmfit.models.StepModel(form="linear")
params = model.make_params()
x = np.linspace(-1, 1)
plt.plot(x, model.eval(params, x=x))
plt.show()

Before the fix:
image

After the fix:
image

Type of Changes
  • Bug fix
  • New feature
  • Refactoring / maintenance
  • Documentation / examples
Tested on

Python: 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0]

lmfit: 1.0.3.post43+g7381cd2, scipy: 1.8.1, numpy: 1.23.1, asteval: 0.9.27, uncertainties: 3.1.7

Verification

Have you

  • included docstrings that follow PEP 257? --> Updated previous docstring
  • referenced existing Issue and/or provided relevant link to mailing list?
  • verified that existing tests pass locally?
  • verified that the documentation builds locally?
  • squashed/minimized your commits and written descriptive commit messages?
  • added or updated existing tests to cover the changes?
  • updated the documentation and/or added an entry to the release notes (doc/whatsnew.rst)?
  • added an example?

@matpompili matpompili changed the title Fix definition and adjust documentation Fix linear StepModel, wrong function definition Jul 14, 2022
@newville
Copy link
Member

@matpompili Oh, that's sort of embarrassing -- thanks very much! I think the main change to the code looks fine, and would be willing to merge.

Compared to that, this is a minor point, but I don't quite understand why Pipfile and Pipfile.lock need to be added to .gitignore. Those aren't currently part of the lmfit codebase. I believe (but could be wrong!) that they only come about in certain kinds of environments... I'm not sure why we should care about them. Do we need these?

@matpompili
Copy link
Contributor Author

@newville they are not needed, but they are files used by environment management programs (like pipenv). I can remove them, but the same argument could go for .idea and .vscode, only used by a fraction of the users.

I'm okay with either option, let me know what you prefer!

@newville
Copy link
Member

@matpompili I would say to remove them so that this PR was only about the math of the step function.

@matpompili
Copy link
Contributor Author

Done! Should be ready now.

@reneeotten
Copy link
Contributor

@matpompili @newville change looks good. Please squash the commits and add an entry in the "whatsnew.rst" file; then it should be good to go.

Fix definition and adjust documentation

Added Pipenv files to .gitignore

typo in docstring

Added note to whatsnew.rst

remove pipenv files from .gitignore
@matpompili matpompili force-pushed the fix_linear_stepmodel branch from c85ddb8 to 5572c7a Compare July 18, 2022 20:34
@matpompili
Copy link
Contributor Author

@reneeotten @newville Squashed and added to whatsnew.rst

@newville
Copy link
Member

@matpompili @reneeotten OK, great, I'll merge. Thanks very much!

@newville newville merged commit d456c88 into lmfit:master Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants