Downloading and Installation — Non-Linear Least-Squares Minimization and Curve-Fitting for Python (2024)

Prerequisites

Lmfit works with Python versions 3.8 and higher. Version0.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 installedautomatically if installing with pip install lmfit.

In order to run the test suite, the pytest, pytest-cov, and flakypackages are required. Some functionality requires the emcee (version 3+),corner, pandas, Jupyter, matplotlib, or numdifftoolspackages. These are not installed automatically, but we highly recommend eachof 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 someLaTex distributions).

Please refer to pyproject.toml under project.optional-dependencies for a list of alldependencies 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 willprovide a shim setup.py file for as long as Python and/or setuptoolsallow the use of this legacy command.

Downloads

The latest stable version of lmfit is 1.3.1 and is available from PyPI. Check the Release Notes fora 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 severalAnaconda 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 buildpip 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 thispurpose, please read CONTRIBUTING.md for more detailed instructions.

Testing

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

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

Acknowledgements

Many people have contributed to lmfit. The attribution of credit in aproject such as this is difficult to get perfect, and there are no doubtimportant contributions that are missing or under-represented here. Pleaseconsider this file as part of the code and documentation that may have bugsthat need fixing.Some of the largest and most important contributions (in approximate orderof 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 FaustinCarter, Christoph Deil, Francois Boulogne, Thomas Caswell, Colin Brosseau,nmearl, Gustavo Pasquevich, Clemens Prescher, LiCode, Ben Gamari, YoavRoam, 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 codein scipy.optimize. Several discussions on the SciPy-user and lmfit mailinglists have also led to improvements in this code.

Copyright, Licensing, and Re-distribution

The LMFIT-py code is distributed under the following license:

BSD-3Copyright 2022 Matthew Newville, The University of Chicago Renee Otten, Brandeis University Till Stensitzki, Freie Universitat Berlin A. R. J. Nelson, Australian Nuclear Science and Technology Organisation Antonino Ingargiola, University of California, Los Angeles Daniel B. Allen, Johns Hopkins University Michal Rawlik, Eidgenossische Technische Hochschule, ZurichRedistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BELIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE.Some code has been taken from the scipy library whose licence is below.Copyright (c) 2001, 2002 Enthought, Inc.All rights reserved.Copyright (c) 2003-2019 SciPy Developers.All rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met: a. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. c. Neither the name of Enthought nor the names of the SciPy Developers may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORSBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OFTHE POSSIBILITY OF SUCH DAMAGE.Some code has been taken from the AMPGO library of Andrea Gavana, which wasreleased under a MIT license.

© Copyright 2024, Matthew Newville, Till Stensitzki, Renee Otten, and others. Created using Sphinx 7.2.6.

Downloading and Installation — Non-Linear Least-Squares Minimization and Curve-Fitting for Python (2024)

References

Top Articles
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 5725

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.