Skip to content

Commit

Permalink
Merge pull request #362 from lmfit/prep095
Browse files Browse the repository at this point in the history
Prep095
  • Loading branch information
newville authored Jul 26, 2016
2 parents 7fa2388 + aa741ce commit 76bbe62
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 50 deletions.
15 changes: 3 additions & 12 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ Non-Linear Least-Square Minimization and Curve-Fitting for Python
.. _Levenberg-Marquardt: http://en.wikipedia.org/wiki/Levenberg-Marquardt_algorithm
.. _MINPACK-1: http://en.wikipedia.org/wiki/MINPACK


.. warning::

Upgrading scripts from version 0.8.3 to 0.9.0? See :ref:`whatsnew_090_label`

.. warning::

Support for Python 2.6 and scipy 0.13 will be dropped with version 0.9.5.


Lmfit provides a high-level interface to non-linear optimization and curve
fitting problems for Python. Lmfit builds on and extends many of the
optimization algorithm of :mod:`scipy.optimize`, especially the
Expand Down Expand Up @@ -51,8 +41,8 @@ fitting problems, including:

.. _lmfit github repository: http://github.com/lmfit/lmfit-py

The lmfit package is Free software, using an MIT license. The software and
this document are works in progress. If you are interested in
The lmfit package is Free software, using an Open Source license. The
software and this document are works in progress. If you are interested in
participating in this effort please use the `lmfit github repository`_.


Expand All @@ -70,3 +60,4 @@ participating in this effort please use the `lmfit github repository`_.
confidence
bounds
constraints
whatsnew
10 changes: 4 additions & 6 deletions doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ Prerequisites

The lmfit package requires Python, Numpy, and Scipy.

Lmfit works with Python 2.7, 3.3, 3.4, and 3.5. Lmfit version 0.9.4 works
with Python 2.6, but support for it will dropped in version 0.9.5. Scipy
version 0.13 or higher is required, with 0.17 or higher recommended to be
able to use the latest optimization features from scipy. Support for scipy
0.13 will be dropped in version 0.9.5. Numpy version 1.5 or higher is
required.
Lmfit works with Python 2.7, 3.3, 3.4, and 3.5. Support for Python 2.6
ended with Lmfit version 0.9.4. Scipy version 0.14 or higher is required,
with 0.17 or higher recommended to be able to use the latest optimization
features from scipy. Numpy version 1.5 or higher is required.

In order to run the test suite, the `nose`_ framework is required. Some
parts of lmfit will be able to make use of IPython (version 4 or higher),
Expand Down
39 changes: 39 additions & 0 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,45 @@ changes to the use and behavior of the library. This is not meant to be a
comprehensive list of changes. For such a complete record, consult the
`lmfit github repository`_.

.. _whatsnew_095_label:

Version 0.9.5 Release Notes
==========================================

Support for Python 2.6 and scipy 0.13 has been dropped.

.. _whatsnew_094_label:

Version 0.9.4 Release Notes
==========================================

Some support for the new `least_squares` routine from scipy 0.17 has been
added.


Parameters can now be used directly in floating point or array expressions,
so that the Parameter value does not need `sigma = params['sigma'].value`.
The older, explicit usage still works, but the docs, samples, and tests
have been updated to use the simpler usage.

Support for Python 2.6 and scipy 0.13 is now explicitly deprecated and wil
be dropped in version 0.9.5.

.. _whatsnew_093_label:

Version 0.9.3 Release Notes
==========================================

Models involving complex numbers have been improved.

The `emcee` module can now be used for uncertainty estimation.

Many bug fixes, and an important fix for performance slowdown on getting
parameter values.

ASV benchmarking code added.


.. _whatsnew_090_label:

Version 0.9.0 Release Notes
Expand Down
12 changes: 6 additions & 6 deletions lmfit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
* Many pre-built models for common lineshapes are included and ready to use.
version: 0.9.4
last update: 2016-Jul-1
License: MIT
version: 0.9.5
last update: 2016-Jul-26
License: BSD
Authors: Matthew Newville, The University of Chicago
Till Stensitzki, Freie Universitat Berlin
Daniel B. Allen, Johns Hopkins University
Expand Down Expand Up @@ -57,11 +57,11 @@

# PY26 Depreciation Warning
if sys.version_info[:2] == (2, 6):
warnings.warn('Support for Python 2.6.x will be dropped in lmfit 0.9.5')
warnings.warn('Support for Python 2.6.x was dropped with lmfit 0.9.5')

# SCIPY 0.13 Depreciation Warning
import scipy
scipy_major, scipy_minor, scipy_other = scipy.__version__.split('.', 2)

if int(scipy_major) == 0 and int(scipy_minor) < 14:
warnings.warn('Support for Scipy 0.13 will be dropped in lmfit 0.9.5')
if int(scipy_major) == 0 and int(scipy_minor) < 15:
warnings.warn('Support for Scipy 0.14 was dropped with lmfit 0.9.5')
46 changes: 21 additions & 25 deletions lmfit/minimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,39 @@
from copy import deepcopy
import numpy as np
from numpy import (dot, eye, ndarray, ones_like,
sqrt, take, transpose, triu, deprecate)
sqrt, take, transpose, triu)
from numpy.dual import inv
from numpy.linalg import LinAlgError
import multiprocessing
import numbers

##
## scipy version notes:
## currently scipy 0.14 is required.
## feature scipy version added
## minimize 0.11
## OptimizeResult 0.13
## diff_evolution 0.15
## least_squares 0.17
##

from scipy.optimize import leastsq as scipy_leastsq
from scipy.optimize import minimize as scipy_minimize

# differential_evolution is only present in scipy >= 0.15
try:
from scipy.optimize import differential_evolution as scipy_diffev
except ImportError:
from ._differentialevolution import differential_evolution as scipy_diffev

# check for scipy.opitimize.least_squares
HAS_LEAST_SQUARES = False
try:
from scipy.optimize import least_squares
HAS_LEAST_SQUARES = True
except ImportError:
pass

# check for EMCEE
HAS_EMCEE = False
try:
Expand All @@ -44,22 +63,6 @@
except ImportError:
pass

# check for scipy.optimize.minimize
HAS_SCALAR_MIN = False
try:
from scipy.optimize import minimize as scipy_minimize
HAS_SCALAR_MIN = True
except ImportError:
pass

# check for scipy.opitimize.least_squares
HAS_LEAST_SQUARES = False
try:
from scipy.optimize import least_squares
HAS_LEAST_SQUARES = True
except ImportError:
pass

from .parameter import Parameter, Parameters

# use locally modified version of uncertainties package
Expand Down Expand Up @@ -528,8 +531,6 @@ def scalar_minimize(self, method='Nelder-Mead', params=None, **kws):
.. versionchanged:: 0.9.0
return value changed to :class:`MinimizerResult`
"""
if not HAS_SCALAR_MIN:
raise NotImplementedError

result = self.prepare_fit(params=params)
result.method = method
Expand Down Expand Up @@ -1232,17 +1233,12 @@ def minimize(self, method='leastsq', params=None, **kws):
function = self.leastsq
elif user_method.startswith('least_s'):
function = self.least_squares
elif HAS_SCALAR_MIN:
else:
function = self.scalar_minimize
for key, val in SCALAR_METHODS.items():
if (key.lower().startswith(user_method) or
val.lower().startswith(user_method)):
kwargs['method'] = val
elif (user_method.startswith('nelder') or
user_method.startswith('fmin')):
function = self.fmin
elif user_method.startswith('lbfgsb'):
function = self.lbfgsb
return function(**kwargs)


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
numpy>=1.5
scipy>=0.13
scipy>=0.14

0 comments on commit 76bbe62

Please sign in to comment.