Skip to content

Commit

Permalink
Merge pull request #794 from matpompili/fix_linear_stepmodel
Browse files Browse the repository at this point in the history
Fix linear StepModel, wrong function definition
  • Loading branch information
newville authored Jul 18, 2022
2 parents 6bea572 + 5572c7a commit d456c88
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
Empty file modified .gitignore
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Bug fixes/enhancements:
- always initialize the variables ``success`` and ``covar`` the ``MinimizerResult`` (reported by Marc W. Pound; PR #771)
- build package following PEP517/PEP518; use ``pyproject.toml`` and ``setup.cfg``; leave ``setup.py`` for now (PR #777)
- components used to create a ``CompositeModel`` can now have different independent variables (@Julian-Hochhaus; Discussion #787; PR #788))

- fixed function definition for ``StepModel(form='linear')``, was not consistent with the other ones. (@matpompili; PR #794)

Deprecations:

Expand Down
3 changes: 2 additions & 1 deletion lmfit/lineshapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def step(x, amplitude=1.0, center=0.0, sigma=1.0, form='linear'):
Starts at 0.0, ends at `amplitude`, with half-max at `center`, and
rising with `form`:
- `'linear'` (default) = amplitude * min(1, max(0, arg))
- `'linear'` (default) = amplitude * min(1, max(0, arg + 0.5))
- `'atan'`, `'arctan'` = amplitude * (0.5 + atan(arg)/pi)
- `'erf'` = amplitude * (1 + erf(arg))/2.0
- `'logistic'` = amplitude * [1 - 1/(1 + exp(arg))]
Expand All @@ -413,6 +413,7 @@ def step(x, amplitude=1.0, center=0.0, sigma=1.0, form='linear'):
elif form in ('atan', 'arctan'):
out = 0.5 + arctan(out)/pi
elif form == 'linear':
out = out + 0.5
out[where(out < 0)] = 0.0
out[where(out > 1)] = 1.0
else:
Expand Down
2 changes: 1 addition & 1 deletion lmfit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ class StepModel(Model):
:nowrap:
\begin{eqnarray*}
& f(x; A, \mu, \sigma, {\mathrm{form={}'linear{}'}}) & = A \min{[1, \max{(0, \alpha)}]} \\
& f(x; A, \mu, \sigma, {\mathrm{form={}'linear{}'}}) & = A \min{[1, \max{(0, \alpha + 1/2)}]} \\
& f(x; A, \mu, \sigma, {\mathrm{form={}'arctan{}'}}) & = A [1/2 + \arctan{(\alpha)}/{\pi}] \\
& f(x; A, \mu, \sigma, {\mathrm{form={}'erf{}'}}) & = A [1 + {\operatorname{erf}}(\alpha)]/2 \\
& f(x; A, \mu, \sigma, {\mathrm{form={}'logistic{}'}})& = A [1 - \frac{1}{1 + e^{\alpha}} ]
Expand Down

0 comments on commit d456c88

Please sign in to comment.