Downloading and Installation

Prerequisites

Lmfit works with Python versions 3.8 and higher. Version 0.9.15 is the final version to support Python 2.7.

Lmfit requires the following Python packages, with versions given:

All of these are readily available on PyPI, and are installed automatically if installing with pip install lmfit.

In order to run the test suite, the pytest, pytest-cov, and flaky packages are required. Some functionality requires the emcee (version 3+), corner, pandas, Jupyter, matplotlib, or numdifftools packages. These are not installed automatically, but we highly recommend each of them.

For building the documentation and generating the examples gallery, matplotlib, emcee (version 3+), corner, Sphinx, sphinx-gallery, jupyter_sphinx, ipykernel, Pillow, and SymPy are required. For generating the PDF documentation, the Python packages sphinxcontrib-svg2pdfconverter and cairosvg are also required, as well as the LaTex package Latexmk (which is included by default in some LaTex distributions).

Please refer to pyproject.toml under project.optional-dependencies for a list of all dependencies that are needed if you want to participate in the development of lmfit. You can install all these dependencies automatically by doing pip install lmfit[all], or select only a subset (e.g., dev`, doc, or test).

Please note: the “original” python setup.py install is deprecated, but we will provide a shim setup.py file for as long as Python and/or setuptools allow the use of this legacy command.

Downloads

The latest stable version of lmfit is 1.3.2 and is available from PyPI. Check the Release Notes for a list of changes compared to earlier releases.

Installation

The easiest way to install lmfit is with:

pip install lmfit

For Anaconda Python, lmfit is not an official package, but several Anaconda channels provide it, allowing installation with (for example):

conda install -c conda-forge lmfit

Development Version

To get the latest development version from the lmfit GitHub repository, use:

git clone https://github.com/lmfit/lmfit-py.git

and install using:

pip install --upgrade build pip setuptools wheel

to install the required build dependencies and then do:

python -m build
pip install ".[all]"

to generate the wheel and install lmfit with all its dependencies.

We welcome all contributions to lmfit! If you cloned the repository for this purpose, please read CONTRIBUTING.md for more detailed instructions.

Testing

A battery of tests scripts that can be run with the pytest testing framework is distributed with lmfit in the tests folder. These are automatically run as part of the development process. For any release or any master branch from the git repository, running pytest should run all of these tests to completion without errors or failures.

Many of the examples in this documentation are distributed with lmfit in the examples folder, and should also run for you. Some of these examples assume that matplotlib has been installed and is working correctly.

Acknowledgements

Many people have contributed to lmfit. The attribution of credit in a
project such as this is difficult to get perfect, and there are no doubt
important contributions that are missing or under-represented here. Please
consider this file as part of the code and documentation that may have bugs
that need fixing.

Some of the largest and most important contributions (in approximate order
of size of the contribution to the existing code) are from:

  Matthew Newville wrote the original version and maintains the project.

  Renee Otten wrote the brute force method, implemented the basin-hopping
  and AMPGO global solvers, implemented uncertainty calculations for scalar
  minimizers and has greatly improved the code, testing, and documentation
  and overall project.

  Till Stensitzki wrote the improved estimates of confidence intervals, and
  contributed many tests, bug fixes, and documentation.

  A. R. J. Nelson added differential_evolution, emcee, and greatly improved
  the code, docstrings, and overall project.

  Antonino Ingargiola wrote much of the high level Model code and has
  provided many bug fixes and improvements.

  Daniel B. Allan wrote much of the original version of the high level Model
  code, and many improvements to the testing and documentation.

  Austen Fox fixed many of the built-in model functions and improved the
  testing and documentation of these.

  Michal Rawlik added plotting capabilities for Models.


  The method used for placing bounds on parameters was derived from the
  clear description in the MINUIT documentation, and adapted from
  J. J. Helmus's Python implementation in leastsqbounds.py.

  E. O. Le Bigot wrote the uncertainties package, a version of which was
  used by lmfit for many years, and is now an external dependency.

  The original AMPGO code came from Andrea Gavana and was adopted for
  lmfit.

  The propagation of parameter uncertainties to uncertainties in a Model
  was adapted from the excellent description at
  https://www.astro.rug.nl/software/kapteyn/kmpfittutorial.html#confidence-and-prediction-intervals,
  which references the original work of: J. Wolberg, Data Analysis Using the
  Method of Least Squares, 2006, Springer.

Additional patches, bug fixes, and suggestions have come from Faustin
Carter, Christoph Deil, Francois Boulogne, Thomas Caswell, Colin Brosseau,
nmearl, Gustavo Pasquevich, Clemens Prescher, LiCode, Ben Gamari, Yoav
Roam, Alexander Stark, Alexandre Beelen, Andrey Aristov, Nicholas Zobrist,
Ethan Welty, Julius Zimmermann, Mark Dean, Arun Persaud, Ray Osborn, @lneuhaus,
Marcel Stimberg, Yoshiera Huang, Leon Foks, Sebastian Weigand, Florian LB,
Michael Hudson-Doyle, Ruben Verweij, @jedzill4, @spalato, Jens Hedegaard Nielsen,
Martin Majli, Kristian Meyer, @azelcer, Ivan Usov, and many others.

The lmfit code obviously depends on, and owes a very large debt to the code
in scipy.optimize. Several discussions on the SciPy-user and lmfit mailing
lists have also led to improvements in this code.