Skip to content

Commit 9d86e49

Browse files
authored
Merge pull request #640 from reneeotten/prepare_for_release
prepare for release
2 parents 3482869 + a5f816f commit 9d86e49

8 files changed

+190
-56
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exclude: 'versioneer.py|lmfit/_version|doc/conf.py'
22

33
repos:
44
- repo: https://github.com/asottile/pyupgrade
5-
rev: v2.1.0
5+
rev: v2.3.0
66
hooks:
77
- id: pyupgrade
88
# for now don't force to change from %-operator to {}

INSTALL

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ To install the lmfit Python module, use::
66
python setup.py build
77
python setup.py install
88

9-
For lmfit 1.0, the following versions are required:
9+
For lmfit 1.0.1, the following versions are required:
1010
Python: 3.5 or higher
1111
NumPy: 1.16 or higher
1212
SciPy: 1.2 or higher
1313
asteval: 0.9.16 or higher
1414
uncertainties: 3.0.1 or higher
1515

1616
Matt Newville <[email protected]>
17-
Last Update: 2019-December-4
17+
Last Update: 2020-April-29

THANKS.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Additional patches, bug fixes, and suggestions have come from Faustin
5252
Carter, Christoph Deil, Francois Boulogne, Thomas Caswell, Colin Brosseau,
5353
nmearl, Gustavo Pasquevich, Clemens Prescher, LiCode, Ben Gamari, Yoav
5454
Roam, Alexander Stark, Alexandre Beelen, Andrey Aristov, Nicholas Zobrist,
55-
Ethan Welty, Julius Zimmermann, and many others.
55+
Ethan Welty, Julius Zimmermann, Mark Dean, Arun Persaud, and many others.
5656

5757
The lmfit code obviously depends on, and owes a very large debt to the code
5858
in scipy.optimize. Several discussions on the SciPy-user and lmfit mailing

doc/whatsnew.rst

+34
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@ to be a comprehensive list of changes. For such a complete record,
1212
consult the `lmfit GitHub repository`_.
1313

1414

15+
.. _whatsnew_101_label:
16+
17+
Version 1.0.1 Release Notes
18+
============================
19+
20+
**Version 1.0.1 is the last release that supports Python 3.5**. All newer version will
21+
require 3.6+ so that we can use formatting-strings and rely on dictionaries being ordered.
22+
23+
New features:
24+
25+
- added thermal distribution model and lineshape (PR #620; @mpmdean)
26+
- introduced a new argument ``max_nfev`` to uniformly specify the maximum number of function evalutions (PR #610)
27+
**Please note: all other arguments (e.g., ``maxfev``, ``maxiter``, ...) will no longer be passed to the underlying
28+
solver. A warning will be emitted stating that one should use ``max_nfev``.**
29+
- the attribute ``call_kws`` was added to the ``MinimizerResult`` class and contains the keyword arguments that are
30+
supplied to the solver in SciPy.
31+
32+
Bug fixes:
33+
34+
- fixes to the ``load`` and ``__setstate__`` methods of the Parameter class
35+
- fixed failure of ModelResult.dump() due to missing attributes (Issue #611, PR #623; @mpmdean)
36+
- ``guess_from_peak`` function now also works correctly with decreasing x-values or when using
37+
pandas (PRs #627 and #629; @mpmdean)
38+
- the ``Parameter.set()`` method now correctly first updates the boundaries and then the value (Issue #636, PR #637; @arunpersaud)
39+
40+
Various:
41+
42+
- fixed typo for the use of expressions in the documentation (Issue #610; @jkrogager)
43+
- removal of PY2-compatibility and unused code and improved test coverage (PRs #619, #631, and #633)
44+
- removed deprecated ``isParameter`` function and automatic conversion of an ``uncertainties`` object (PR #626)
45+
- inaccurate FWHM calculations were removed from built-in models, others labeled as estimates (Issue #616 and PR #630)
46+
- corrected spelling mistake for the Doniach lineshape and model (Issue #634; @rayosborn)
47+
48+
1549
.. _whatsnew_100_label:
1650

1751
Version 1.0.0 Release Notes

lmfit/minimizer.py

+40-37
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"""
1515
from collections import namedtuple
1616
from copy import deepcopy
17+
import inspect
1718
import multiprocessing
1819
import numbers
1920
import warnings
20-
import inspect
2121

2222
import numpy as np
2323
from numpy import ndarray, ones_like, sqrt
@@ -77,11 +77,11 @@
7777
# define the namedtuple here so pickle will work with the MinimizerResult
7878
Candidate = namedtuple('Candidate', ['params', 'score'])
7979

80-
MAXEVAL_Warning = """ignoring `%s` argument to `%s()`. Use `max_nfev` instead."""
80+
MAXEVAL_Warning = "ignoring `%s` argument to `%s()`. Use `max_nfev` instead."
8181

8282

8383
def thisfuncname():
84-
"""Return name of calling function"""
84+
"""Return the name of calling function."""
8585
try:
8686
return inspect.stack()[1].function
8787
except AttributeError:
@@ -268,7 +268,7 @@ class MinimizerResult:
268268
message : str
269269
Message about fit success.
270270
call_kws : dict
271-
Dict of keyword arguments sent to underlying solver method.
271+
Keyword arguments sent to underlying solver.
272272
ier : int
273273
Integer error value from :scipydoc:`optimize.leastsq` (`leastsq` only).
274274
lmdif_message : str
@@ -380,9 +380,9 @@ def _repr_html_(self, show_correl=True, min_correl=0.1):
380380
class Minimizer:
381381
"""A general minimizer for curve fitting and optimization."""
382382

383-
_err_nonparam = ("params must be a minimizer.Parameters() instance or list "
384-
"of Parameters()")
385-
_err_max_evals = ("Too many function calls (max set to %i)! Use:"
383+
_err_nonparam = ("params must be a minimizer.Parameters() instance or"
384+
" list of Parameters()")
385+
_err_max_evals = ("Too many function calls (max set to %i)! Use:"
386386
" minimize(func, params, ..., max_nfev=NNN)"
387387
" to increase this maximum.")
388388

@@ -405,9 +405,9 @@ def __init__(self, userfcn, params, fcn_args=None, fcn_kws=None,
405405
Positional arguments to pass to `userfcn`.
406406
fcn_kws : dict, optional
407407
Keyword arguments to pass to `userfcn`.
408-
max_nfev: int or None
409-
Maximum number of function evaluations. The default value will
410-
change with fitting method.
408+
max_nfev: int or None, optional
409+
Maximum number of function evaluations (default is None). The
410+
default value depends on the fitting method.
411411
iter_cb : callable, optional
412412
Function to be called at each fit iteration. This function should
413413
have the signature::
@@ -509,11 +509,12 @@ def __init__(self, userfcn, params, fcn_args=None, fcn_kws=None,
509509
self.nan_policy = nan_policy
510510

511511
def set_max_nfev(self, max_nfev=None, default_value=100000):
512-
"""
513-
Set maximum number of function evaluations, possibly setting
514-
to the provided default_value
512+
"""Set maximum number of function evaluations.
513+
514+
If `max_nfev` is None, use the provided `default_value`.
515515
516516
>>> self.set_max_nfev(max_nfev, 1000*(result.nvarys+1))
517+
517518
"""
518519
if max_nfev is not None:
519520
self.max_nfev = max_nfev
@@ -889,10 +890,10 @@ def scalar_minimize(self, method='Nelder-Mead', params=None, max_nfev=None,
889890
- 'differential_evolution'
890891
891892
params : :class:`~lmfit.parameter.Parameters`, optional
892-
Parameters to use as starting point.
893-
max_nfev: int or None
894-
Maximum number of function evaluations. Defaults to 1000*(nvars+1)
895-
where nvars is the number of variable parameters.
893+
Parameters to use as starting point.
894+
max_nfev: int or None, optional
895+
Maximum number of function evaluations. Defaults to 1000*(nvars+1),
896+
where nvars is the number of variable parameters.
896897
**kws : dict, optional
897898
Minimizer options pass to :scipydoc:`optimize.minimize`.
898899
@@ -904,7 +905,7 @@ def scalar_minimize(self, method='Nelder-Mead', params=None, max_nfev=None,
904905
905906
906907
.. versionchanged:: 0.9.0
907-
Return value changed to :class:`MinimizerResult`.
908+
Return value changed to :class:`MinimizerResult`.
908909
909910
Notes
910911
-----
@@ -1490,10 +1491,10 @@ def least_squares(self, params=None, max_nfev=None, **kws):
14901491
Parameters
14911492
----------
14921493
params : :class:`~lmfit.parameter.Parameters`, optional
1493-
Parameters to use as starting point.
1494-
max_nfev: int or None
1495-
Maximum number of function evaluations. Defaults to 1000*(nvars+1)
1496-
where nvars is the number of variable parameters.
1494+
Parameters to use as starting point.
1495+
max_nfev: int or None, optional
1496+
Maximum number of function evaluations. Defaults to 1000*(nvars+1),
1497+
where nvars is the number of variable parameters.
14971498
**kws : dict, optional
14981499
Minimizer options to pass to :scipydoc:`optimize.least_squares`.
14991500
@@ -1505,7 +1506,7 @@ def least_squares(self, params=None, max_nfev=None, **kws):
15051506
15061507
15071508
.. versionchanged:: 0.9.0
1508-
Return value changed to :class:`MinimizerResult`.
1509+
Return value changed to :class:`MinimizerResult`.
15091510
15101511
"""
15111512
result = self.prepare_fit(params)
@@ -1595,10 +1596,10 @@ def leastsq(self, params=None, max_nfev=None, **kws):
15951596
Parameters
15961597
----------
15971598
params : :class:`~lmfit.parameter.Parameters`, optional
1598-
Parameters to use as starting point.
1599-
max_nfev: int or None
1600-
Maximum number of function evaluations. Defaults to 2000*(nvars+1)
1601-
where nvars is the number of variable parameters.
1599+
Parameters to use as starting point.
1600+
max_nfev: int or None, optional
1601+
Maximum number of function evaluations. Defaults to 2000*(nvars+1),
1602+
where nvars is the number of variable parameters.
16021603
**kws : dict, optional
16031604
Minimizer options to pass to :scipydoc:`optimize.leastsq`.
16041605
@@ -1610,7 +1611,7 @@ def leastsq(self, params=None, max_nfev=None, **kws):
16101611
16111612
16121613
.. versionchanged:: 0.9.0
1613-
Return value changed to :class:`MinimizerResult`.
1614+
Return value changed to :class:`MinimizerResult`.
16141615
16151616
"""
16161617
result = self.prepare_fit(params=params)
@@ -1986,7 +1987,7 @@ def ampgo(self, params=None, max_nfev=None, **kws):
19861987
19871988
19881989
Notes
1989-
----
1990+
-----
19901991
The Python implementation was written by Andrea Gavana in 2014
19911992
(http://infinity77.net/global_optimization/index.html).
19921993
@@ -2051,8 +2052,10 @@ def shgo(self, params=None, max_nfev=None, **kws):
20512052
params : :class:`~lmfit.parameter.Parameters`, optional
20522053
Contains the Parameters for the model. If None, then the
20532054
Parameters used to initialize the Minimizer object are used.
2054-
max_nfev: int (default is None)
2055-
Maximum number of total function evaluations.
2055+
max_nfev: int or None, optional
2056+
Maximum number of function evaluations. Defaults to
2057+
1e6*(result.nvarys+1), where nvars is the number of variable
2058+
parameters.
20562059
**kws : dict, optional
20572060
Minimizer options to pass to the SHGO algorithm.
20582061
@@ -2121,8 +2124,8 @@ def dual_annealing(self, params=None, max_nfev=None, **kws):
21212124
params : :class:`~lmfit.parameter.Parameters`, optional
21222125
Contains the Parameters for the model. If None, then the
21232126
Parameters used to initialize the Minimizer object are used.
2124-
max_nfev: int or None
2125-
Maximum number of function evaluations. Default is 1e7.
2127+
max_nfev: int or None, optional
2128+
Maximum number of function evaluations. Defaults to 1e7.
21262129
**kws : dict, optional
21272130
Minimizer options to pass to the dual_annealing algorithm.
21282131
@@ -2242,7 +2245,7 @@ def minimize(self, method='leastsq', params=None, **kws):
22422245
22432246
22442247
.. versionchanged:: 0.9.0
2245-
Return value changed to :class:`MinimizerResult`.
2248+
Return value changed to :class:`MinimizerResult`.
22462249
22472250
"""
22482251
function = self.leastsq
@@ -2449,9 +2452,9 @@ def minimize(fcn, params, method='leastsq', args=None, kws=None, iter_cb=None,
24492452
Whether to calculate the covariance matrix (default is True) for
24502453
solvers other than `leastsq` and `least_squares`. Requires the
24512454
`numdifftools` package to be installed.
2452-
max_nfev: int or None
2453-
Maximum number of function evaluations. Default is different for each
2454-
fitting method.
2455+
max_nfev: int or None, optional
2456+
Maximum number of function evaluations (default is None). The
2457+
default value depends on the fitting method.
24552458
**fit_kws : dict, optional
24562459
Options to pass to the minimizer being used.
24572460

lmfit/model.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,9 @@ def fit(self, data, params=None, weights=None, method='leastsq',
894894
Whether to calculate the covariance matrix (default is True) for
895895
solvers other than `leastsq` and `least_squares`. Requires the
896896
`numdifftools` package to be installed.
897-
max_nfev: int or None
898-
Maximum number of function evaluations. Default varies with solver.
897+
max_nfev: int or None, optional
898+
Maximum number of function evaluations (default is None). The
899+
default value depends on the fitting method.
899900
**kwargs: optional
900901
Arguments to pass to the model function, possibly overriding
901902
params.
@@ -1307,8 +1308,9 @@ def __init__(self, model, params, data=None, weights=None,
13071308
Whether to calculate the covariance matrix (default is True) for
13081309
solvers other than `leastsq` and `least_squares`. Requires the
13091310
`numdifftools` package to be installed.
1310-
max_nfev: int or None
1311-
Maximum number of function evaluations. Default varies with solver.
1311+
max_nfev: int or None, optional
1312+
Maximum number of function evaluations (default is None). The
1313+
default value depends on the fitting method.
13121314
**fit_kws : optional
13131315
Keyword arguments to send to minimization routine.
13141316

tests/test_itercb.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the Iteration Callback Function."""
2+
23
import numpy as np
34
import pytest
45

@@ -47,14 +48,3 @@ def test_itercb(method, calc_covar):
4748
assert out.aborted
4849
assert not out.errorbars
4950
assert not out.success
50-
51-
@pytest.mark.parametrize("method", ['leastsq', 'least_squares', 'nelder',
52-
'brute', 'ampgo', 'basinopping', 'differential_evolution'])
53-
def test_max_nfev(method):
54-
"""Test the iteration callback for all solvers."""
55-
out = mod.fit(y, pars, x=x, method=method, max_nfev=10)
56-
57-
assert out.nfev < 15
58-
assert out.aborted
59-
assert not out.errorbars
60-
assert not out.success

0 commit comments

Comments
 (0)