From 809f464d93bcccdfc464d7c804c95ca1ed30d4dc Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Sat, 9 Mar 2024 23:43:39 -0500 Subject: [PATCH] Transition from setup.py to pyproject.toml * Move static package configuration from setup.py to pyproject.toml - Minimal changes were made to the configuration, so it still lists Python 2.7 as the minimum version, though it hasn't been tested what the minimum version of Python is that can install the package with a pyproject.toml file and no setup.py. - The `future` dependency was restricted to `python < 3.1'` since it is not needed with Python 3 and is not actively maintained. * Merge long description content in setup.py into README.rst * Capture development dependencies listed in setup.py in requirements-dev.txt * Save change log which was in long description in setup.py in its own file, CHANGES.rst. --- setup.py => CHANGES.rst | 211 +--------------------------------------- README.rst | 102 ++++++++++++++++--- pyproject.toml | 59 +++++++++++ requirements-dev.txt | 4 + 4 files changed, 153 insertions(+), 223 deletions(-) rename setup.py => CHANGES.rst (54%) mode change 100755 => 100644 create mode 100644 pyproject.toml create mode 100644 requirements-dev.txt diff --git a/setup.py b/CHANGES.rst old mode 100755 new mode 100644 similarity index 54% rename from setup.py rename to CHANGES.rst index 974bcc80..9d11bd4f --- a/setup.py +++ b/CHANGES.rst @@ -1,118 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import sys - -# Common options for distutils/setuptools's setup(): -setup_options = dict( - name='uncertainties', - version='3.1.7', - author='Eric O. LEBIGOT (EOL)', - author_email='eric.lebigot@normalesup.org', - url='http://uncertainties-python-package.readthedocs.io/', - license='Revised BSD License', - description=('Transparent calculations with uncertainties on the' - ' quantities involved (aka error propagation);' - ' fast calculation of derivatives'), - long_description='''\ -Overview -======== - -``uncertainties`` allows **calculations** such as (2 +/- 0.1)*2 = 4 +/- -0.2 to be **performed transparently**. Much more complex mathematical -expressions involving numbers with uncertainties can also be evaluated -directly. - -The ``uncertainties`` package **takes the pain and complexity out** -of uncertainty calculations. - -**Detailed information** about this package can be found on its `main -website`_. - -Basic examples -============== - -.. code-block:: python - - >>> from uncertainties import ufloat - - >>> x = ufloat(2, 0.25) - >>> x - 2.0+/-0.25 - - >>> square = x**2 # Transparent calculations - >>> square - 4.0+/-1.0 - >>> square.nominal_value - 4.0 - >>> square.std_dev # Standard deviation - 1.0 - - >>> square - x*x - 0.0 # Exactly 0: correlations taken into account - - >>> from uncertainties.umath import * # sin(), etc. - >>> sin(1+x**2) - -0.95892427466313845+/-0.2836621854632263 - - >>> print (2*x+1000).derivatives[x] # Automatic calculation of derivatives - 2.0 - - >>> from uncertainties import unumpy # Array manipulation - >>> random_vars = unumpy.uarray([1, 2], [0.1, 0.2]) - >>> print random_vars - [1.0+/-0.1 2.0+/-0.2] - >>> print random_vars.mean() - 1.50+/-0.11 - >>> print unumpy.cos(random_vars) - [0.540302305868+/-0.0841470984808 -0.416146836547+/-0.181859485365] - -Main features -============= - -- **Transparent calculations with uncertainties**: **no or little - modification of existing code** is needed. Similarly, the Python_ (or - IPython_) shell can be used as **a powerful calculator** that - handles quantities with uncertainties (``print`` statements are - optional, which is convenient). - -- **Correlations** between expressions are correctly taken into - account. Thus, ``x-x`` is exactly zero, for instance (most - implementations found on the web yield a non-zero uncertainty for - ``x-x``, which is incorrect). - -- **Almost all mathematical operations** are supported, including most - functions from the standard math_ module (sin,...). Comparison - operators (``>``, ``==``, etc.) are supported too. - -- Many **fast operations on arrays and matrices** of numbers with - uncertainties are supported. - -- **Extensive support for printing** numbers with uncertainties - (including LaTeX support and pretty-printing). - -- Most uncertainty calculations are performed **analytically**. - -- This module also gives access to the **derivatives** of any - mathematical expression (they are used by error - propagation theory, and are thus automatically calculated by this - module). - - -Installation or upgrade -======================= - -Installation instructions are available on the `main web site -`_ -for this package. - -Contact -======= - -Please send **feature requests, bug reports, or feedback** to -`Eric O. LEBIGOT (EOL)`_. - Version history =============== @@ -247,102 +132,8 @@ - 1.0.9: ``correlations()`` renamed more appropriately as ``covariance_matrix()``. -.. _Python: http://docs.python.org/tutorial/interpreter.html -.. _IPython: http://ipython.readthedocs.io/en/stable/ -.. _NumPy: http://numpy.scipy.org/ .. _math: http://docs.python.org/library/math.html .. _PEP 8: http://www.python.org/dev/peps/pep-0008/ -.. _error propagation theory: http://en.wikipedia.org/wiki/Propagation_of_uncertainty -.. _Eric O. LEBIGOT (EOL): mailto:eric.lebigot@normalesup.org -.. _PayPal: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4TK7KNDTEDT4S -.. _main website: http://uncertainties-python-package.readthedocs.io/ .. _code updater: http://uncertainties-python-package.readthedocs.io/en/latest/index.html#migration-from-version-1-to-version-2 -.. _formatting: http://uncertainties-python-package.readthedocs.io/en/latest/user_guide.html#printing''', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Other Audience', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: Implementation :: Jython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Education', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Physics', - 'Topic :: Software Development', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Utilities' - ], - - keywords=[ - 'error propagation', 'uncertainties', 'uncertainty calculations', - 'standard deviation', 'derivatives', 'partial derivatives', - 'differentiation' - ], - - # Files are defined in MANIFEST (which is automatically created by - # python setup.py sdist bdist_wheel): - packages=[ - 'uncertainties', 'uncertainties.unumpy', 'uncertainties.lib1to2', - 'uncertainties.lib1to2.fixes' - ], - - # The code runs with both Python 2 and Python 3: - options={"bdist_wheel": {"universal": True}} - ) - -# The best available setup() is used (some users do not have -# setuptools): -try: - from setuptools import setup - - # Some setuptools-specific options can be added: - - addtl_setup_options = dict( - - project_urls={ - 'Documentation': - 'https://uncertainties-python-package.readthedocs.io/', - 'Source': 'https://github.com/lebigot/uncertainties' - }, - - install_requires=['future'], - - tests_require=['nose', 'numpy'], - - # Optional dependencies install using: - # `easy_install uncertainties[optional]` - extras_require={ - 'optional': ['numpy'], - 'docs': ['sphinx'], - } - ) - - # easy_install uncertainties[tests] option: - addtl_setup_options['extras_require']['tests'] = ( - addtl_setup_options['tests_require']) - - # easy_install uncertainties[all] option: all dependencies are - # gathered - addtl_setup_options['extras_require']['all'] = set( - sum(addtl_setup_options['extras_require'].values(), [])) - - setup_options.update(addtl_setup_options) - -except ImportError: - from distutils.core import setup - -# End of setup definition +.. _formatting: http://uncertainties-python-package.readthedocs.io/en/latest/user_guide.html#printing -setup(**setup_options) diff --git a/README.rst b/README.rst index d2deeebd..d8d30df2 100644 --- a/README.rst +++ b/README.rst @@ -15,31 +15,101 @@ uncertainties **Call for maintainers**: if you want this project to keep living and are ready to maintain it (pull requests management, issue resolution…), please contact me! I am ready to share my knowledge of the code logic by participating in discussions (notably around pull requests and issues). -This is the ``uncertainties`` Python package, which performs **transparent -calculations with uncertainties** (aka "error propagation"): +``uncertainties`` allows **calculations** such as (2 +/- 0.1)*2 = 4 +/- +0.2 to be **performed transparently**. Much more complex mathematical +expressions involving numbers with uncertainties can also be evaluated +directly. + +The ``uncertainties`` package **takes the pain and complexity out** +of uncertainty calculations. + +**Detailed information** about this package can be found on its `main +website`_. + +Basic examples +-------------- + +.. code-block:: python >>> from uncertainties import ufloat - >>> from uncertainties.umath import * # sin(), etc. - >>> x = ufloat(1, 0.1) # x = 1+/-0.1 - >>> print(2*x) - 2.00+/-0.20 - >>> sin(2*x) # In a Python shell, "print" is optional - 0.9092974268256817+/-0.08322936730942848 -This package also **automatically calculates derivatives of arbitrary functions**: + >>> x = ufloat(2, 0.25) + >>> x + 2.0+/-0.25 + + >>> square = x**2 # Transparent calculations + >>> square + 4.0+/-1.0 + >>> square.nominal_value + 4.0 + >>> square.std_dev # Standard deviation + 1.0 - >>> (2*x+1000).derivatives[x] + >>> square - x*x + 0.0 # Exactly 0: correlations taken into account + + >>> from uncertainties.umath import * # sin(), etc. + >>> sin(1+x**2) + -0.95892427466313845+/-0.2836621854632263 + + >>> print (2*x+1000).derivatives[x] # Automatic calculation of derivatives 2.0 -The main documentation is available at -https://uncertainties.readthedocs.io/. + >>> from uncertainties import unumpy # Array manipulation + >>> random_vars = unumpy.uarray([1, 2], [0.1, 0.2]) + >>> print random_vars + [1.0+/-0.1 2.0+/-0.2] + >>> print random_vars.mean() + 1.50+/-0.11 + >>> print unumpy.cos(random_vars) + [0.540302305868+/-0.0841470984808 -0.416146836547+/-0.181859485365] + +Main features +------------- + +- **Transparent calculations with uncertainties**: **no or little + modification of existing code** is needed. Similarly, the Python_ (or + IPython_) shell can be used as **a powerful calculator** that + handles quantities with uncertainties (``print`` statements are + optional, which is convenient). + +- **Correlations** between expressions are correctly taken into + account. Thus, ``x-x`` is exactly zero, for instance (most + implementations found on the web yield a non-zero uncertainty for + ``x-x``, which is incorrect). + +- **Almost all mathematical operations** are supported, including most + functions from the standard math_ module (sin,...). Comparison + operators (``>``, ``==``, etc.) are supported too. + +- Many **fast operations on arrays and matrices** of numbers with + uncertainties are supported. + +- **Extensive support for printing** numbers with uncertainties + (including LaTeX support and pretty-printing). + +- Most uncertainty calculations are performed **analytically**. + +- This module also gives access to the **derivatives** of any + mathematical expression (they are used by `error + propagation theory`_, and are thus automatically calculated by this + module). + + +Installation or upgrade +----------------------- + +Installation instructions are available on the `main web site +`_ +for this package. + + Git branches ------------ The ``release`` branch is the latest stable release. It should pass the tests. - ``master*`` branches in the Github repository are bleeding-edge, and do not necessarily pass the tests. The ``master`` branch is the latest, relatively stable versions (while other ``master*`` branches are more experimental). @@ -69,3 +139,9 @@ History This package was created back around 2009 by `Eric O. LEBIGOT `_. Ownership of the package was taken over by the `lmfit GitHub organization `_ in 2024. + +.. _Python: http://docs.python.org/tutorial/interpreter.html +.. _IPython: http://ipython.readthedocs.io/en/stable/ +.. _math: http://docs.python.org/library/math.html +.. _error propagation theory: http://en.wikipedia.org/wiki/Propagation_of_uncertainty +.. _main website: http://uncertainties-python-package.readthedocs.io/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..35609e42 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "uncertainties" +version = "3.1.7" +authors = [ + {name = "Eric O. LEBIGOT (EOL)", email = "eric.lebigot@normalesup.org"}, +] +description = """\ + Transparent calculations with uncertainties on the \ + quantities involved (aka error propagation); \ + fast calculation of derivatives').\ + """ +readme = "README.rst" +requires-python = ">=3.1" +keywords = [ + "error propagation", "uncertainties", "uncertainty calculations", + "standard deviation", "derivatives", "partial derivatives", + "differentiation" +] +license = {text = "Revised BSD License"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Other Audience", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: Jython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Education", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Physics", + "Topic :: Software Development", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Utilities" +] +dependencies = ["future; python_version < '3.1'"] + +[project.urls] +Documentation = "http://uncertainties-python-package.readthedocs.io/" +Repository = "https://github.com/lmfit/uncertainties" +Issues = "https://github.com/lmfit/uncertainties/issues" +Changelog = "https://github.com/lmfit/uncertainties/blob/master/CHANGES.rst" + +[project.optional-dependencies] +optional = ["numpy"] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..3cfcc7af --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +numpy +pytest +pytest-cov +sphinx