From 5572c7a8f23c882bf050ded69ce4a150218242a4 Mon Sep 17 00:00:00 2001 From: Matteo Pompili Date: Thu, 14 Jul 2022 12:53:47 -0500 Subject: [PATCH] Fix linear StepModel to match documentation. Fix definition and adjust documentation Added Pipenv files to .gitignore typo in docstring Added note to whatsnew.rst remove pipenv files from .gitignore --- .gitignore | 0 doc/whatsnew.rst | 2 +- lmfit/lineshapes.py | 3 ++- lmfit/models.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) mode change 100755 => 100644 .gitignore diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst index 141ed5010..07058d49d 100644 --- a/doc/whatsnew.rst +++ b/doc/whatsnew.rst @@ -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: diff --git a/lmfit/lineshapes.py b/lmfit/lineshapes.py index bee360550..2a3f58b12 100644 --- a/lmfit/lineshapes.py +++ b/lmfit/lineshapes.py @@ -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))] @@ -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: diff --git a/lmfit/models.py b/lmfit/models.py index e37cdea54..3c0e46630 100644 --- a/lmfit/models.py +++ b/lmfit/models.py @@ -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}} ]