From ad5c6cd039a0a46f628d9459d49cbf6da9ad26fe Mon Sep 17 00:00:00 2001 From: mmckerns Date: Sat, 7 May 2022 15:34:22 -0400 Subject: [PATCH 01/10] enable support for develop and pep517 --- .travis.yml | 2 +- MANIFEST.in | 2 + README.md | 41 ++++ mystic/__init__.py | 361 ++++++++++++++++++++++++++--- pyproject.toml | 9 + setup.cfg | 7 +- setup.py | 560 +++++++++++---------------------------------- tox.ini | 3 +- 8 files changed, 519 insertions(+), 466 deletions(-) create mode 100644 pyproject.toml diff --git a/.travis.yml b/.travis.yml index ed541fa4..1f87322d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ before_install: - if [[ $CYTHON == "true" ]]; then pip install "cython<0.29.25"; fi #FIXME install: - - python setup.py build && python setup.py install + - python -m pip install . script: - for test in tests/__init__.py; do echo $test ; if [[ $COVERAGE == "true" ]]; then coverage run -a $test > /dev/null; else python $test > /dev/null; fi ; done diff --git a/MANIFEST.in b/MANIFEST.in index 541ac3fe..476639e7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,7 @@ include LICENSE include README* +include MANIFEST.in +include pyproject.toml include tox.ini recursive-include docs * recursive-include examples * diff --git a/README.md b/README.md index 10f6ffaf..e3eef865 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,47 @@ You can get the latest development version with all the shiny new features at: If you have a new contribution, please submit a pull request. +Installation +------------ +``mystic`` can be installed with ``pip``:: + + $ pip install mystic + +To include optional scientific python support, with ``scipy``, install:: + + $ pip install mystic[math] + +To include optional plotting support with ``matplotlib``, install:: + + $ pip install mystic[plotting] + +To include optional parallel computing support, with ``pathos``, install:: + + $ pip install mystic[parallel] + + +Requirements +------------ +``mystic`` requires: + +* ``python`` (or ``pypy``), **==2.7** or **>=3.7** +* ``setuptools``, **>=42** +* ``wheel``, **>=0.1** +* ``cython``, **>=0.29.22** +* ``numpy``, **>=1.0** +* ``sympy``, **>=0.6.7** +* ``mpmath``, **>=0.19** +* ``dill``, **>=0.3.4** +* ``klepto``, **>=0.2.1** + +Optional requirements: + +* ``matplotlib``, **>=0.91** +* ``scipy``, **>=0.6.0** +* ``pathos``, **>=0.2.8** +* ``pyina``, **>=0.2.5** + + More Information ---------------- Probably the best way to get started is to look at the documentation at diff --git a/mystic/__init__.py b/mystic/__init__.py index 26da81d3..2c328a32 100644 --- a/mystic/__init__.py +++ b/mystic/__init__.py @@ -8,50 +8,347 @@ # License: 3-clause BSD. The full license text is available at: # - https://github.com/uqfoundation/mystic/blob/master/LICENSE -# get version numbers, license, and long description -try: - from mystic.info import this_version as __version__ - from mystic.info import readme as __doc__, license as __license__ -except ImportError: - msg = """First run 'python setup.py build' to build mystic.""" - raise ImportError(msg) - +# author, version, license, and long description +__version__ = '0.3.9.dev0' __author__ = 'Mike McKerns' __doc__ = """ -""" + __doc__ +--------------------------------------------------------------------------------- +mystic: highly-constrained non-convex optimization and uncertainty quantification +--------------------------------------------------------------------------------- + +About Mystic +============ + +The ``mystic`` framework provides a collection of optimization algorithms +and tools that allows the user to more robustly (and easily) solve hard +optimization problems. All optimization algorithms included in ``mystic`` +provide workflow at the fitting layer, not just access to the algorithms +as function calls. ``mystic`` gives the user fine-grained power to both +monitor and steer optimizations as the fit processes are running. +Optimizers can advance one iteration with ``Step``, or run to completion +with ``Solve``. Users can customize optimizer stop conditions, where both +compound and user-provided conditions may be used. Optimizers can save +state, can be reconfigured dynamically, and can be restarted from a +saved solver or from a results file. All solvers can also leverage +parallel computing, either within each iteration or as an ensemble of +solvers. + +Where possible, ``mystic`` optimizers share a common interface, and thus can +be easily swapped without the user having to write any new code. ``mystic`` +solvers all conform to a solver API, thus also have common method calls +to configure and launch an optimization job. For more details, see +``mystic.abstract_solver``. The API also makes it easy to bind a favorite +3rd party solver into the ``mystic`` framework. + +Optimization algorithms in ``mystic`` can accept parameter constraints, +either in the form of penaties (which "penalize" regions of solution +space that violate the constraints), or as constraints (which "constrain" +the solver to only search in regions of solution space where the +constraints are respected), or both. ``mystic`` provides a large +selection of constraints, including probabistic and dimensionally +reducing constraints. By providing a robust interface designed to +enable the user to easily configure and control solvers, ``mystic`` +greatly reduces the barrier to solving hard optimization problems. + +``mystic`` is in active development, so any user feedback, bug reports, comments, +or suggestions are highly appreciated. list of issues is located at https://github.com/uqfoundation/mystic/issues, with a legacy list maintained at https://uqfoundation.github.io/project/mystic/query. + + +Major Features +============== + +``mystic`` provides a stock set of configurable, controllable solvers with: + + - a common interface + - a control handler with: pause, continue, exit, and callback + - ease in selecting initial population conditions: guess, random, etc + - ease in checkpointing and restarting from a log or saved state + - the ability to leverage parallel & distributed computing + - the ability to apply a selection of logging and/or verbose monitors + - the ability to configure solver-independent termination conditions + - the ability to impose custom and user-defined penalties and constraints + +To get up and running quickly, ``mystic`` also provides infrastructure to: + + - easily generate a model (several standard test models are included) + - configure and auto-generate a cost function from a model + - configure an ensemble of solvers to perform a specific task + + +Current Release +=============== + +The latest released version of ``mystic`` is available from: + + https://pypi.org/project/mystic + +``mystic`` is distributed under a 3-clause BSD license. + + +Development Version +=================== + +You can get the latest development version with all the shiny new features at: + + https://github.com/uqfoundation + +If you have a new contribution, please submit a pull request. + + +Installation +============ + +``mystic`` can be installed with ``pip``:: + + $ pip install mystic + +To include optional scientific python support, with ``scipy``, install:: + + $ pip install mystic[math] + +To include optional plotting support with ``matplotlib``, install:: + + $ pip install mystic[plotting] + +To include optional parallel computing support, with ``pathos``, install:: + + $ pip install mystic[parallel] + + +Requirements +============ + +``mystic`` requires: + + - ``python`` (or ``pypy``), **==2.7** or **>=3.7** + - ``setuptools``, **>=42** + - ``wheel``, **>=0.1** + - ``cython``, **>=0.29.22** + - ``numpy``, **>=1.0** + - ``sympy``, **>=0.6.7** + - ``mpmath``, **>=0.19** + - ``dill``, **>=0.3.4** + - ``klepto``, **>=0.2.1** + +Optional requirements: + + - ``matplotlib``, **>=0.91** + - ``scipy``, **>=0.6.0** + - ``pathos``, **>=0.2.8** + - ``pyina``, **>=0.2.5** + + +More Information +================ + +Probably the best way to get started is to look at the documentation at +http://mystic.rtfd.io. Also see ``mystic.tests`` for a set of scripts that +demonstrate several of the many features of the ``mystic`` framework. +You can run the test suite with ``python -m mystic.tests``. There are +several plotting scripts that are installed with ``mystic``, primary of which +are `mystic_log_reader`` (also available with ``python -m mystic``) and the +``mystic_model_plotter`` (also available with ``python -m mystic.models``). +There are several other plotting scripts that come with ``mystic``, and they +are detailed elsewhere in the documentation. See ``mystic.examples`` for +examples that demonstrate the basic use cases for configuration and launching +of optimization jobs using one of the sample models provided in +``mystic.models``. Many of the included examples are standard optimization +test problems. The use of constraints and penalties are detailed in +``mystic.examples2``, while more advanced features leveraging ensemble solvers +and dimensional collapse are found in ``mystic.examples3``. The scripts in +``mystic.examples4`` demonstrate leveraging ``pathos`` for parallel computing, +as well as demonstrate some auto-partitioning schemes. ``mystic`` has the +ability to work in product measure space, and the scripts in +``mystic.examples5`` show to work with product measures. The source code is +generally well documented, so further questions may be resolved by inspecting +the code itself. Please feel free to submit a ticket on github, or ask a +question on stackoverflow (**@Mike McKerns**). +If you would like to share how you use ``mystic`` in your work, please send an +email (to **mmckerns at uqfoundation dot org**). + +Instructions on building a new model are in ``mystic.models.abstract_model``. +``mystic`` provides base classes for two types of models: + + - ``AbstractFunction`` [evaluates ``f(x)`` for given evaluation points ``x``] + - ``AbstractModel`` [generates ``f(x,p)`` for given coefficients ``p``] + +``mystic`` also provides some convienence functions to help you build a +model instance and a cost function instance on-the-fly. For more +information, see ``mystic.forward_model``. It is, however, not necessary +to use base classes or the model builder in building your own model or +cost function, as any standard python function can be used as long as it +meets the basic ``AbstractFunction`` interface of ``cost = f(x)``. + +All ``mystic`` solvers are highly configurable, and provide a robust set of +methods to help customize the solver for your particular optimization +problem. For each solver, a minimal (``scipy.optimize``) interface is also +provided for users who prefer to configure and launch their solvers as a +single function call. For more information, see ``mystic.abstract_solver`` +for the solver API, and each of the individual solvers for their minimal +functional interface. + +``mystic`` enables solvers to use parallel computing whenever the user provides +a replacement for the (serial) python ``map`` function. ``mystic`` includes a +sample ``map`` in ``mystic.python_map`` that mirrors the behavior of the +built-in python ``map``, and a ``pool`` in ``mystic.pools`` that provides ``map`` +functions using the ``pathos`` (i.e. ``multiprocessing``) interface. ``mystic`` +solvers are designed to utilize distributed and parallel tools provided by +the ``pathos`` package. For more information, see ``mystic.abstract_map_solver``, +``mystic.abstract_ensemble_solver``, and the ``pathos`` documentation at +http://pathos.rtfd.io. + +Important classes and functions are found here: + + - ``mystic.solvers`` [solver optimization algorithms] + - ``mystic.termination`` [solver termination conditions] + - ``mystic.strategy`` [solver population mutation strategies] + - ``mystic.monitors`` [optimization monitors] + - ``mystic.symbolic`` [symbolic math in constaints] + - ``mystic.constraints`` [constraints functions] + - ``mystic.penalty`` [penalty functions] + - ``mystic.collapse`` [checks for dimensional collapse] + - ``mystic.coupler`` [decorators for function coupling] + - ``mystic.pools`` [parallel worker pool interface] + - ``mystic.munge`` [file readers and writers] + - ``mystic.scripts`` [model and convergence plotting] + - ``mystic.samplers`` [optimizer-guided sampling] + - ``mystic.support`` [hypercube measure support plotting] + - ``mystic.forward_model`` [cost function generator] + - ``mystic.tools`` [constraints, wrappers, and other tools] + - ``mystic.cache`` [results caching and archiving] + - ``mystic.models`` [models and test functions] + - ``mystic.math`` [mathematical functions and tools] + +Important functions within ``mystic.math`` are found here: + + - ``mystic.math.Distribution`` [a sampling distribution object] + - ``mystic.math.legacydata`` [classes for legacy data observations] + - ``mystic.math.discrete`` [classes for discrete measures] + - ``mystic.math.measures`` [tools to support discrete measures] + - ``mystic.math.approx`` [tools for measuring equality] + - ``mystic.math.grid`` [tools for generating points on a grid] + - ``mystic.math.distance`` [tools for measuring distance and norms] + - ``mystic.math.poly`` [tools for polynomial functions] + - ``mystic.math.samples`` [tools related to sampling] + - ``mystic.math.integrate`` [tools related to integration] + - ``mystic.math.interpolate`` [tools related to interpolation] + - ``mystic.math.stats`` [tools related to distributions] + +Solver, Sampler, and model API definitions are found here: + + - ``mystic.abstract_sampler`` [the sampler API definition] + - ``mystic.abstract_solver`` [the solver API definition] + - ``mystic.abstract_map_solver`` [the parallel solver API] + - ``mystic.abstract_ensemble_solver`` [the ensemble solver API] + - ``mystic.models.abstract_model`` [the model API definition] + +``mystic`` also provides several convience scripts that are used to visualize +models, convergence, and support on the hypercube. These scripts are installed +to a directory on the user's ``$PATH``, and thus can be run from anywhere: + + - ``mystic_log_reader`` [parameter and cost convergence] + - ``mystic_collapse_plotter`` [convergence and dimensional collapse] + - ``mystic_model_plotter`` [model surfaces and solver trajectory] + - ``support_convergence`` [convergence plots for measures] + - ``support_hypercube`` [parameter support on the hypercube] + - ``support_hypercube_measures`` [measure support on the hypercube] + - ``support_hypercube_scenario`` [scenario support on the hypercube] + +Typing ``--help`` as an argument to any of the above scripts will print out an +instructive help message. + + +Citation +======== + +If you use ``mystic`` to do research that leads to publication, we ask that you +acknowledge use of ``mystic`` by citing the following in your publication:: + + M.M. McKerns, L. Strand, T. Sullivan, A. Fang, M.A.G. Aivazis, + "Building a framework for predictive science", Proceedings of + the 10th Python in Science Conference, 2011; + http://arxiv.org/pdf/1202.1056 + + Michael McKerns, Patrick Hung, and Michael Aivazis, + "mystic: highly-constrained non-convex optimization and UQ", 2009- ; + https://uqfoundation.github.io/project/mystic + +Please see https://uqfoundation.github.io/project/mystic or +http://arxiv.org/pdf/1202.1056 for further information. + +""" __license__ = """ -""" + __license__ +Copyright (c) 2004-2016 California Institute of Technology. +Copyright (c) 2016-2022 The Uncertainty Quantification Foundation. +All rights reserved. -__all__ = ['solvers','termination','strategy','munge','tools','support', \ - 'constraints','penalty','coupler','symbolic','monitors','license', \ - 'citation','model_plotter','log_reader','collapse_plotter'] +This software is available subject to the conditions and terms laid +out below. By downloading and using this software you are agreeing +to the following conditions. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met:: + + - Redistribution of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistribution in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentations and/or other materials provided with the distribution. + + - Neither the names of the copyright holders nor the names of any of + the 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, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" + +try: + # This is a hack to import a minimal package for the build process + __MYSTIC_SETUP__ +except NameError: + __all__ = ['solvers','termination','strategy','munge','tools','support', \ + 'penalty','coupler','symbolic','monitors','license','citation', \ + 'constraints','model_plotter','log_reader','collapse_plotter'] -# solvers -import mystic.solvers as solvers + # solvers + import mystic.solvers as solvers -# strategies, termination conditions -import mystic.termination as termination -import mystic.strategy as strategy + # strategies, termination conditions + import mystic.termination as termination + import mystic.strategy as strategy -# constraints and penalties -import mystic.constraints as constraints -import mystic.penalty as penalty -import mystic.coupler as coupler -import mystic.symbolic as symbolic + # constraints and penalties + import mystic.constraints as constraints + import mystic.penalty as penalty + import mystic.coupler as coupler + import mystic.symbolic as symbolic -# monitors, function wrappers, and other tools -import mystic.monitors as monitors -import mystic.munge as munge -import mystic.tools as tools + # monitors, function wrappers, and other tools + import mystic.monitors as monitors + import mystic.munge as munge + import mystic.tools as tools -# scripts -from mystic.scripts import model_plotter, log_reader, collapse_plotter -import mystic.support as support + # scripts + from mystic.scripts import model_plotter, log_reader, collapse_plotter + import mystic.support as support -# backward compatibility -from mystic.tools import * + # backward compatibility + from mystic.tools import * def license(): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..d8e97872 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[build-system] +# Further build requirements come from setup.py via the PEP 517 interface +requires = [ + "setuptools>=42", + "wheel", + "Cython>=0.29.22", #XXX: required to build numpy from source + #"oldest-supported-numpy>=1.0", #XXX: oldest supported numpy with wheels +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index 46edaabe..01378d84 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,7 @@ [egg_info] tag_build = .dev0 -#tag_svn_revision = yes -#tag_date = yes + +[bdist_wheel] +#universal = 1 +#python-tag = py3 +#plat-name = manylinux1_x86_64 diff --git a/setup.py b/setup.py index bdb671fc..711a6845 100644 --- a/setup.py +++ b/setup.py @@ -17,380 +17,89 @@ if unsupported: raise ValueError(unsupported) -# set version numbers -stable_version = '0.3.8' -target_version = '0.3.9' -is_release = stable_version == target_version +try: + import builtins +except ImportError: + import __builtin__ as builtins + +# This is a hack to import a minimal package for the build process +builtins.__MYSTIC_SETUP__ = True +sys.path.append(os.path.abspath(os.path.curdir)) +import mystic -# check if easy_install is available +# get version numbers, long_description, etc +AUTHOR = mystic.__author__ +VERSION = mystic.__version__ +LONG_DOC = mystic.__doc__ #FIXME: near-duplicate of README.md +#LICENSE = mystic.__license__ #FIXME: duplicate of LICENSE +AUTHOR_EMAIL = 'mmckerns@uqfoundation.org' + +# check if setuptools is available try: -# import __force_distutils__ #XXX: uncomment to force use of distutills from setuptools import setup + from setuptools.dist import Distribution has_setuptools = True except ImportError: from distutils.core import setup + Distribution = object has_setuptools = False -# generate version number -if os.path.exists('mystic/info.py'): - # is a source distribution, so use existing version - os.chdir('mystic') - with open('info.py','r') as f: - f.readline() # header - this_version = f.readline().split()[-1].strip("'") - os.chdir('..') -elif stable_version == target_version: - # we are building a stable release - this_version = stable_version -else: - # we are building a distribution - this_version = target_version + '.dev0' - if is_release: - from datetime import date - today = "".join(date.isoformat(date.today()).split('-')) - this_version += "-" + today - -# get the license info -with open('LICENSE') as file: - license_text = file.read() - -# generate the readme text -long_description = \ -"""--------------------------------------------------------------------------------- -mystic: highly-constrained non-convex optimization and uncertainty quantification ---------------------------------------------------------------------------------- - -About Mystic -============ - -The ``mystic`` framework provides a collection of optimization algorithms -and tools that allows the user to more robustly (and easily) solve hard -optimization problems. All optimization algorithms included in ``mystic`` -provide workflow at the fitting layer, not just access to the algorithms -as function calls. ``mystic`` gives the user fine-grained power to both -monitor and steer optimizations as the fit processes are running. -Optimizers can advance one iteration with ``Step``, or run to completion -with ``Solve``. Users can customize optimizer stop conditions, where both -compound and user-provided conditions may be used. Optimizers can save -state, can be reconfigured dynamically, and can be restarted from a -saved solver or from a results file. All solvers can also leverage -parallel computing, either within each iteration or as an ensemble of -solvers. - -Where possible, ``mystic`` optimizers share a common interface, and thus can -be easily swapped without the user having to write any new code. ``mystic`` -solvers all conform to a solver API, thus also have common method calls -to configure and launch an optimization job. For more details, see -``mystic.abstract_solver``. The API also makes it easy to bind a favorite -3rd party solver into the ``mystic`` framework. - -Optimization algorithms in ``mystic`` can accept parameter constraints, -either in the form of penaties (which "penalize" regions of solution -space that violate the constraints), or as constraints (which "constrain" -the solver to only search in regions of solution space where the -constraints are respected), or both. ``mystic`` provides a large -selection of constraints, including probabistic and dimensionally -reducing constraints. By providing a robust interface designed to -enable the user to easily configure and control solvers, ``mystic`` -greatly reduces the barrier to solving hard optimization problems. - -``mystic`` is in active development, so any user feedback, bug reports, comments, -or suggestions are highly appreciated. list of issues is located at https://github.com/uqfoundation/mystic/issues, with a legacy list maintained at https://uqfoundation.github.io/project/mystic/query. - - -Major Features -============== - -``mystic`` provides a stock set of configurable, controllable solvers with: - - - a common interface - - a control handler with: pause, continue, exit, and callback - - ease in selecting initial population conditions: guess, random, etc - - ease in checkpointing and restarting from a log or saved state - - the ability to leverage parallel & distributed computing - - the ability to apply a selection of logging and/or verbose monitors - - the ability to configure solver-independent termination conditions - - the ability to impose custom and user-defined penalties and constraints - -To get up and running quickly, ``mystic`` also provides infrastructure to: - - - easily generate a model (several standard test models are included) - - configure and auto-generate a cost function from a model - - configure an ensemble of solvers to perform a specific task - - -Current Release -=============== - -This documentation is for version ``mystic-%(thisver)s``. - -The latest released version of ``mystic`` is available from: - - https://pypi.org/project/mystic - -``mystic`` is distributed under a 3-clause BSD license. - - >>> import mystic - >>> mystic.license() - - -Development Version -=================== - -You can get the latest development version with all the shiny new features at: - - https://github.com/uqfoundation - -If you have a new contribution, please submit a pull request. - - -Installation -============ - -``mystic`` is packaged to install from source, so you must -download the tarball, unzip, and run the installer:: - - [download] - $ tar -xvzf mystic-%(relver)s.tar.gz - $ cd mystic-%(relver)s - $ python setup py build - $ python setup py install - -You will be warned of any missing dependencies and/or settings -after you run the "build" step above. ``mystic`` depends on ``dill``, ``numpy`` -and ``sympy``, so you should install them first. There are several -functions within ``mystic`` where ``scipy`` is used if it is available; -however, ``scipy`` is an optional dependency. Having ``matplotlib`` installed -is necessary for running several of the examples, and you should -probably go get it even though it's not required. ``matplotlib`` is required -for results visualization available in the scripts packaged with ``mystic``. - -Alternately, ``mystic`` can be installed with ``pip`` or ``easy_install``:: - - $ pip install mystic - - -Requirements -============ - -``mystic`` requires: - - - ``python`` (or ``pypy``), **version == 2.7** or **version >= 3.7** - - ``numpy``, **version >= 1.0** - - ``sympy``, **version >= 0.6.7** - - ``mpmath``, **version >= 0.19** - - ``dill``, **version >= 0.3.4** - - ``klepto``, **version >= 0.2.1** - -Optional requirements: - - - ``setuptools``, **version >= 40.6.0** - - ``cython``, **version >= 0.29.22** - - ``matplotlib``, **version >= 0.91** - - ``scipy``, **version >= 0.6.0** - - ``pathos``, **version >= 0.2.8** - - ``pyina``, **version >= 0.2.5** - - -More Information -================ - -Probably the best way to get started is to look at the documentation at -http://mystic.rtfd.io. Also see ``mystic.tests`` for a set of scripts that -demonstrate several of the many features of the ``mystic`` framework. -You can run the test suite with ``python -m mystic.tests``. There are -several plotting scripts that are installed with ``mystic``, primary of which -are `mystic_log_reader`` (also available with ``python -m mystic``) and the -``mystic_model_plotter`` (also available with ``python -m mystic.models``). -There are several other plotting scripts that come with ``mystic``, and they -are detailed elsewhere in the documentation. See ``mystic.examples`` for -examples that demonstrate the basic use cases for configuration and launching -of optimization jobs using one of the sample models provided in -``mystic.models``. Many of the included examples are standard optimization -test problems. The use of constraints and penalties are detailed in -``mystic.examples2``, while more advanced features leveraging ensemble solvers -and dimensional collapse are found in ``mystic.examples3``. The scripts in -``mystic.examples4`` demonstrate leveraging ``pathos`` for parallel computing, -as well as demonstrate some auto-partitioning schemes. ``mystic`` has the -ability to work in product measure space, and the scripts in -``mystic.examples5`` show to work with product measures. The source code is -generally well documented, so further questions may be resolved by inspecting -the code itself. Please feel free to submit a ticket on github, or ask a -question on stackoverflow (**@Mike McKerns**). -If you would like to share how you use ``mystic`` in your work, please send an -email (to **mmckerns at uqfoundation dot org**). - -Instructions on building a new model are in ``mystic.models.abstract_model``. -``mystic`` provides base classes for two types of models: - - - ``AbstractFunction`` [evaluates ``f(x)`` for given evaluation points ``x``] - - ``AbstractModel`` [generates ``f(x,p)`` for given coefficients ``p``] - -``mystic`` also provides some convienence functions to help you build a -model instance and a cost function instance on-the-fly. For more -information, see ``mystic.forward_model``. It is, however, not necessary -to use base classes or the model builder in building your own model or -cost function, as any standard python function can be used as long as it -meets the basic ``AbstractFunction`` interface of ``cost = f(x)``. - -All ``mystic`` solvers are highly configurable, and provide a robust set of -methods to help customize the solver for your particular optimization -problem. For each solver, a minimal (``scipy.optimize``) interface is also -provided for users who prefer to configure and launch their solvers as a -single function call. For more information, see ``mystic.abstract_solver`` -for the solver API, and each of the individual solvers for their minimal -functional interface. - -``mystic`` enables solvers to use parallel computing whenever the user provides -a replacement for the (serial) python ``map`` function. ``mystic`` includes a -sample ``map`` in ``mystic.python_map`` that mirrors the behavior of the -built-in python ``map``, and a ``pool`` in ``mystic.pools`` that provides ``map`` -functions using the ``pathos`` (i.e. ``multiprocessing``) interface. ``mystic`` -solvers are designed to utilize distributed and parallel tools provided by -the ``pathos`` package. For more information, see ``mystic.abstract_map_solver``, -``mystic.abstract_ensemble_solver``, and the ``pathos`` documentation at -http://pathos.rtfd.io. - -Important classes and functions are found here: - - - ``mystic.solvers`` [solver optimization algorithms] - - ``mystic.termination`` [solver termination conditions] - - ``mystic.strategy`` [solver population mutation strategies] - - ``mystic.monitors`` [optimization monitors] - - ``mystic.symbolic`` [symbolic math in constaints] - - ``mystic.constraints`` [constraints functions] - - ``mystic.penalty`` [penalty functions] - - ``mystic.collapse`` [checks for dimensional collapse] - - ``mystic.coupler`` [decorators for function coupling] - - ``mystic.pools`` [parallel worker pool interface] - - ``mystic.munge`` [file readers and writers] - - ``mystic.scripts`` [model and convergence plotting] - - ``mystic.samplers`` [optimizer-guided sampling] - - ``mystic.support`` [hypercube measure support plotting] - - ``mystic.forward_model`` [cost function generator] - - ``mystic.tools`` [constraints, wrappers, and other tools] - - ``mystic.cache`` [results caching and archiving] - - ``mystic.models`` [models and test functions] - - ``mystic.math`` [mathematical functions and tools] - -Important functions within ``mystic.math`` are found here: - - - ``mystic.math.Distribution`` [a sampling distribution object] - - ``mystic.math.legacydata`` [classes for legacy data observations] - - ``mystic.math.discrete`` [classes for discrete measures] - - ``mystic.math.measures`` [tools to support discrete measures] - - ``mystic.math.approx`` [tools for measuring equality] - - ``mystic.math.grid`` [tools for generating points on a grid] - - ``mystic.math.distance`` [tools for measuring distance and norms] - - ``mystic.math.poly`` [tools for polynomial functions] - - ``mystic.math.samples`` [tools related to sampling] - - ``mystic.math.integrate`` [tools related to integration] - - ``mystic.math.interpolate`` [tools related to interpolation] - - ``mystic.math.stats`` [tools related to distributions] - -Solver, Sampler, and model API definitions are found here: - - - ``mystic.abstract_sampler`` [the sampler API definition] - - ``mystic.abstract_solver`` [the solver API definition] - - ``mystic.abstract_map_solver`` [the parallel solver API] - - ``mystic.abstract_ensemble_solver`` [the ensemble solver API] - - ``mystic.models.abstract_model`` [the model API definition] - -``mystic`` also provides several convience scripts that are used to visualize -models, convergence, and support on the hypercube. These scripts are installed -to a directory on the user's ``$PATH``, and thus can be run from anywhere: - - - ``mystic_log_reader`` [parameter and cost convergence] - - ``mystic_collapse_plotter`` [convergence and dimensional collapse] - - ``mystic_model_plotter`` [model surfaces and solver trajectory] - - ``support_convergence`` [convergence plots for measures] - - ``support_hypercube`` [parameter support on the hypercube] - - ``support_hypercube_measures`` [measure support on the hypercube] - - ``support_hypercube_scenario`` [scenario support on the hypercube] - -Typing ``--help`` as an argument to any of the above scripts will print out an -instructive help message. - - -Citation -======== - -If you use ``mystic`` to do research that leads to publication, we ask that you -acknowledge use of ``mystic`` by citing the following in your publication:: - - M.M. McKerns, L. Strand, T. Sullivan, A. Fang, M.A.G. Aivazis, - "Building a framework for predictive science", Proceedings of - the 10th Python in Science Conference, 2011; - http://arxiv.org/pdf/1202.1056 - - Michael McKerns, Patrick Hung, and Michael Aivazis, - "mystic: highly-constrained non-convex optimization and UQ", 2009- ; - https://uqfoundation.github.io/project/mystic - -Please see https://uqfoundation.github.io/project/mystic or -http://arxiv.org/pdf/1202.1056 for further information. - -""" % {'relver' : stable_version, 'thisver' : this_version} - -# write readme file -with open('README', 'w') as file: - file.write(long_description) - -# generate 'info' file contents -def write_info_py(filename='mystic/info.py'): - contents = """# THIS FILE GENERATED FROM SETUP.PY -this_version = '%(this_version)s' -stable_version = '%(stable_version)s' -readme = '''%(long_description)s''' -license = '''%(license_text)s''' -""" - with open(filename, 'w') as file: - file.write(contents % {'this_version' : this_version, - 'stable_version' : stable_version, - 'long_description' : long_description, - 'license_text' : license_text }) - return - -# write info file -write_info_py() - # build the 'setup' call -setup_code = """ -setup(name='mystic', - version='%s', - description='highly-constrained non-convex optimization and uncertainty quantification', - long_description = '''%s''', - author = 'Mike McKerns', - maintainer = 'Mike McKerns', - license = '3-clause BSD', - platforms = ['Linux', 'Windows', 'Mac'], - url = 'https://github.com/uqfoundation/mystic', - download_url = 'https://github.com/uqfoundation/mystic/releases/download/mystic-%s/mystic-%s.tar.gz', - python_requires = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*', - classifiers = ['Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Scientific/Engineering', - 'Topic :: Software Development'], +setup_kwds = dict( + name='mystic', + version=VERSION, + description='highly-constrained non-convex optimization and uncertainty quantification', + long_description = LONG_DOC, + author = AUTHOR, + author_email = AUTHOR_EMAIL, + maintainer = AUTHOR, + maintainer_email = AUTHOR_EMAIL, + license = '3-clause BSD', + platforms = ['Linux', 'Windows', 'Mac'], + url = 'https://github.com/uqfoundation/mystic', + download_url = 'https://pypi.org/project/mystic/#files', + python_requires = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*', + classifiers = ['Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: Implementation :: PyPy', + 'Topic :: Scientific/Engineering', + 'Topic :: Software Development'], + packages = ['mystic','mystic.models','mystic.math','mystic.cache', + 'mystic.tests'], + package_dir = {'mystic':'mystic','mystic.models':'models', + 'mystic.math':'mystic/math','mystic.cache':'cache', + 'mystic.tests':'tests'}, + scripts=['scripts/mystic_log_reader', + 'scripts/mystic_model_plotter', + 'scripts/mystic_collapse_plotter', + 'scripts/support_convergence', + 'scripts/support_hypercube', + 'scripts/support_hypercube_measures', + 'scripts/support_hypercube_scenario'], +) - packages = ['mystic','mystic.models','mystic.math','mystic.cache', - 'mystic.tests'], - package_dir = {'mystic':'mystic','mystic.models':'models', - 'mystic.math':'mystic/math','mystic.cache':'cache', - 'mystic.tests':'tests'}, -""" % (target_version, long_description, stable_version, stable_version) +# force python-, abi-, and platform-specific naming of bdist_wheel +class BinaryDistribution(Distribution): + """Distribution which forces a binary package with platform name""" + def has_ext_modules(foo): + return True -# add dependencies +# define dependencies sysversion = sys.version_info[:2] +dill_version = 'dill>=0.3.4' +klepto_version = 'klepto>=0.2.1' +pathos_version = 'pathos>=0.2.8' +pyina_version = 'pyina>=0.2.5' +cython_version = 'cython>=0.29.22' #XXX: required to build numpy from source try: import ctypes # if using `pypy`, pythonapi is not found IS_PYPY = not hasattr(ctypes, 'pythonapi') @@ -399,94 +108,87 @@ def write_info_py(filename='mystic/info.py'): IS_PYPY = False IS_PYPY2 = False if sysversion < (2,6) or sysversion == (3,0) or sysversion == (3,1): - numpy_version = '>=1.0, <1.8.0' - sympy_version = '>=0.6.7, <1.1' - scipy_version = '>=0.6.0, <0.17.0' - mpmath_version = '>=0.19, <1.0.0' - matplotlib_version = '>=0.91, <2.0.0' + numpy_version = 'numpy>=1.0, <1.8.0' + sympy_version = 'sympy>=0.6.7, <1.1' + scipy_version = 'scipy>=0.6.0, <0.17.0' + mpmath_version = 'mpmath>=0.19, <1.0.0' + matplotlib_version = 'matplotlib>=0.91, <2.0.0' elif sysversion == (2,6) or sysversion == (3,2) or sysversion == (3,3): - numpy_version = '>=1.0, <1.12.0' - sympy_version = '>=0.6.7, <1.1' - scipy_version = '>=0.6.0, <1.0.0' - mpmath_version = '>=0.19, <1.0.0' - matplotlib_version = '>=0.91, <2.0.0' + numpy_version = 'numpy>=1.0, <1.12.0' + sympy_version = 'sympy>=0.6.7, <1.1' + scipy_version = 'scipy>=0.6.0, <1.0.0' + mpmath_version = 'mpmath>=0.19, <1.0.0' + matplotlib_version = 'matplotlib>=0.91, <2.0.0' elif IS_PYPY2: - numpy_version = '>=1.0, <1.16.0' - sympy_version = '>=0.6.7, <1.1' - scipy_version = '>=0.6.0, <1.3.0' - mpmath_version = '>=0.19, <1.2.1' #XXX: != 1.2.1 - matplotlib_version = '>=0.91, <3.0.0' + numpy_version = 'numpy>=1.0, <1.16.0' + sympy_version = 'sympy>=0.6.7, <1.1' + scipy_version = 'scipy>=0.6.0, <1.3.0' + mpmath_version = 'mpmath>=0.19, <1.2.1' #XXX: != 1.2.1 + matplotlib_version = 'matplotlib>=0.91, <3.0.0' elif sysversion == (2,7) or sysversion == (3,4): - numpy_version = '>=1.0, <1.17.0' - sympy_version = '>=0.6.7, <1.1' - scipy_version = '>=0.6.0, <1.3.0' - mpmath_version = '>=0.19' - matplotlib_version = '>=0.91, <3.0.0' + numpy_version = 'numpy>=1.0, <1.17.0' + sympy_version = 'sympy>=0.6.7, <1.1' + scipy_version = 'scipy>=0.6.0, <1.3.0' + mpmath_version = 'mpmath>=0.19' + matplotlib_version = 'matplotlib>=0.91, <3.0.0' elif sysversion == (3,5): - numpy_version = '>=1.0, <1.19.0' - sympy_version = '>=0.6.7, <1.7' - scipy_version = '>=0.6.0, <1.5.0' - mpmath_version = '>=0.19' - matplotlib_version = '>=0.91, <3.1.0' + numpy_version = 'numpy>=1.0, <1.19.0' + sympy_version = 'sympy>=0.6.7, <1.7' + scipy_version = 'scipy>=0.6.0, <1.5.0' + mpmath_version = 'mpmath>=0.19' + matplotlib_version = 'matplotlib>=0.91, <3.1.0' elif sysversion == (3,6):# or IS_PYPY - numpy_version = '>=1.0, <1.20.0' - sympy_version = '>=0.6.7'#, <0.7.4' - scipy_version = '>=0.6.0, <1.6.0' - mpmath_version = '>=0.19' - matplotlib_version = '>=0.91, <3.4.0' + numpy_version = 'numpy>=1.0, <1.20.0' + sympy_version = 'sympy>=0.6.7'#, <0.7.4' + scipy_version = 'scipy>=0.6.0, <1.6.0' + mpmath_version = 'mpmath>=0.19' + matplotlib_version = 'matplotlib>=0.91, <3.4.0' else: - numpy_version = '>=1.0' - sympy_version = '>=0.6.7'#, <0.7.4' - scipy_version = '>=0.6.0' - mpmath_version = '>=0.19' - matplotlib_version = '>=0.91' #XXX: kiwisolver-1.3.0 -dill_version = '>=0.3.4' -klepto_version = '>=0.2.1' -pathos_version = '>=0.2.8' -pyina_version = '>=0.2.5' -cython_version = '>=0.29.22' #XXX: required to build numpy from source + numpy_version = 'numpy>=1.0' + sympy_version = 'sympy>=0.6.7'#, <0.7.4' + scipy_version = 'scipy>=0.6.0' + mpmath_version = 'mpmath>=0.19' + matplotlib_version = 'matplotlib>=0.91' #XXX: kiwisolver-1.3.0 +# add dependencies +depend = [dill_version, klepto_version, numpy_version, sympy_version, mpmath_version] +extras = {'math': [scipy_version], 'parallel': [pathos_version, pyina_version], 'plotting': [matplotlib_version]} +# update setup kwds if has_setuptools: - setup_code += """ - zip_safe=False, - install_requires = ('numpy%s', 'mpmath%s', 'sympy%s', 'klepto%s', 'dill%s'), - extras_require = {'math': ['scipy%s'], 'parallel': ['pathos%s','pyina%s'], 'plotting': ['matplotlib%s']}, -""" % (numpy_version, mpmath_version, sympy_version, klepto_version, dill_version, scipy_version, pathos_version, pyina_version, matplotlib_version) + setup_kwds.update( + zip_safe=False, + # distclass=BinaryDistribution, + install_requires=depend, + extras_require=extras, + ) -# add the scripts, and close 'setup' call -setup_code += """ - scripts=['scripts/mystic_log_reader', - 'scripts/mystic_model_plotter', - 'scripts/mystic_collapse_plotter', - 'scripts/support_convergence', - 'scripts/support_hypercube', - 'scripts/support_hypercube_measures', - 'scripts/support_hypercube_scenario']) -""" - -# exec the 'setup' code -exec(setup_code) +# call setup +setup(**setup_kwds) # if dependencies are missing, print a warning try: import numpy import sympy import mpmath - import klepto import dill + import klepto #import cython #import scipy #import matplotlib #XXX: has issues being zip_safe + #import pathos + #import pyina except ImportError: print("\n***********************************************************") print("WARNING: One of the following dependencies is unresolved:") - print(" numpy %s" % numpy_version) - print(" sympy %s" % sympy_version) - print(" mpmath %s" % mpmath_version) - print(" klepto %s" % klepto_version) - print(" dill %s" % dill_version) - print(" cython %s (optional)" % cython_version) - print(" scipy %s (optional)" % scipy_version) - print(" matplotlib %s (optional)" % matplotlib_version) + print(" %s" % numpy_version) + print(" %s" % sympy_version) + print(" %s" % mpmath_version) + print(" %s" % dill_version) + print(" %s" % klepto_version) + #print(" %s" % cython_version) + print(" %s (optional)" % scipy_version) + print(" %s (optional)" % matplotlib_version) + print(" %s (optional)" % pathos_version) + print(" %s (optional)" % pyina_version) print("***********************************************************\n") diff --git a/tox.ini b/tox.ini index d76a82d3..9c1369e0 100644 --- a/tox.ini +++ b/tox.ini @@ -50,7 +50,6 @@ deps = whitelist_externals = bash commands = - {envpython} setup.py build - {envpython} setup.py install + {envpython} -m pip install . bash -c "failed=0; for test in tests/__main__.py; do echo $test; \ {envpython} $test || failed=1; done; exit $failed" From 96471d292df73bd6873b0dae7fe4f91ba2005d9b Mon Sep 17 00:00:00 2001 From: mmckerns Date: Sat, 7 May 2022 16:07:41 -0400 Subject: [PATCH 02/10] 3.11 use klepto master --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1f87322d..d543892f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ matrix: - python: '3.11-dev' env: - CYTHON="true" # numpy source build + - KLEPTO="master" - python: 'pypy2.7-7.3.1' # most recent dist: xenial @@ -53,6 +54,8 @@ before_install: - if [[ $SYMPY == "true" ]]; then pip install sympy; fi - if [[ $SCIPY == "true" ]]; then pip install scipy; fi - if [[ $CYTHON == "true" ]]; then pip install "cython<0.29.25"; fi #FIXME + - if [[ $KLEPTO == "master" ]]; then pip install "https://github.com/uqfoundation/klepto/archive/master.tar.gz"; fi + install: - python -m pip install . From ed4f9dafefb9f9aa2575b487e707bd6eb27d449c Mon Sep 17 00:00:00 2001 From: mmckerns Date: Sat, 7 May 2022 16:18:48 -0400 Subject: [PATCH 03/10] remove unnecessary import --- mystic/forward_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mystic/forward_model.py b/mystic/forward_model.py index 7924699f..4143eb07 100755 --- a/mystic/forward_model.py +++ b/mystic/forward_model.py @@ -63,7 +63,7 @@ from mystic.filters import identity, component from mystic.filters import null_check -from inspect import getargspec +#from inspect import getargspec from numpy import pi, sqrt, array, mgrid, random, real, conjugate, arange, sum __all__ = ['CostFactory'] From 967440a5f278a7272605b529d4e248ea15618f70 Mon Sep 17 00:00:00 2001 From: mmckerns Date: Sat, 7 May 2022 16:31:45 -0400 Subject: [PATCH 04/10] 3.11 use dill master --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d543892f..4293f3e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ matrix: - python: '3.11-dev' env: - CYTHON="true" # numpy source build + - DILL="master" - KLEPTO="master" - python: 'pypy2.7-7.3.1' # most recent @@ -54,6 +55,7 @@ before_install: - if [[ $SYMPY == "true" ]]; then pip install sympy; fi - if [[ $SCIPY == "true" ]]; then pip install scipy; fi - if [[ $CYTHON == "true" ]]; then pip install "cython<0.29.25"; fi #FIXME + - if [[ $DILL == "master" ]]; then pip install "https://github.com/uqfoundation/dill/archive/master.tar.gz"; fi - if [[ $KLEPTO == "master" ]]; then pip install "https://github.com/uqfoundation/klepto/archive/master.tar.gz"; fi From 1a3623fb3eb3edf3b54fcf73020225784330d841 Mon Sep 17 00:00:00 2001 From: mmckerns Date: Thu, 12 May 2022 11:37:34 -0400 Subject: [PATCH 05/10] cleanup scripts after docs build --- docs/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Makefile b/docs/Makefile index 5917e641..74d47210 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -24,4 +24,5 @@ html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) -rm -f $(BUILDDIR)/../../scripts/_*py -rm -f $(BUILDDIR)/../../scripts/_*pyc + -rm -f $(BUILDDIR)/../../scripts/__pycache__ From 403f05c1ee84579b8651d382674075c8c952d442 Mon Sep 17 00:00:00 2001 From: mmckerns Date: Thu, 12 May 2022 16:42:51 -0400 Subject: [PATCH 06/10] rtfd and travis env options to 3.9 --- .readthedocs.yml | 2 +- .travis.yml | 8 ++++---- docs/Makefile | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 80edfea3..62006eae 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,7 +8,7 @@ sphinx: # build python: - version: "3.7" + version: "3.9" install: - method: pip path: . diff --git a/.travis.yml b/.travis.yml index 4293f3e9..a7335e30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,16 +10,16 @@ matrix: - python: '3.7' env: - - COVERAGE="true" - - MATPLOTLIB="true" - - SYMPY="true" - - SCIPY="true" - python: '3.8' env: - python: '3.9' env: + - COVERAGE="true" + - MATPLOTLIB="true" + - SYMPY="true" + - SCIPY="true" - python: '3.10' env: diff --git a/docs/Makefile b/docs/Makefile index 74d47210..50222f83 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -24,5 +24,5 @@ html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) -rm -f $(BUILDDIR)/../../scripts/_*py -rm -f $(BUILDDIR)/../../scripts/_*pyc - -rm -f $(BUILDDIR)/../../scripts/__pycache__ + -rm -rf $(BUILDDIR)/../../scripts/__pycache__ From 19f455ce5eb105d7c5da2a8986601dd773eed1c4 Mon Sep 17 00:00:00 2001 From: mmckerns Date: Sun, 15 May 2022 12:05:17 -0400 Subject: [PATCH 07/10] coverage paths and report for travis --- .coveragerc | 12 ++++++++---- .travis.yml | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.coveragerc b/.coveragerc index adc51587..c1509c33 100644 --- a/.coveragerc +++ b/.coveragerc @@ -31,10 +31,14 @@ source = cache models mystic/math - */site-packages/mystic*/mystic - */site-packages/mystic*/mystic/cache - */site-packages/mystic*/mystic/math - */site-packages/mystic*/mystic/models + */site-packages/mystic + */site-packages/mystic/cache + */site-packages/mystic/math + */site-packages/mystic/models + */site-packages/mystic-*/mystic + */site-packages/mystic-*/mystic/cache + */site-packages/mystic-*/mystic/math + */site-packages/mystic-*/mystic/models [report] include = diff --git a/.travis.yml b/.travis.yml index a7335e30..4d1840d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,3 +68,4 @@ script: after_success: - if [[ $COVERAGE == "true" ]]; then bash <(curl -s https://codecov.io/bash); else echo ''; fi + - if [[ $COVERAGE == "true" ]]; then coverage report; fi From 7271fc265b3e391cef8ade3b55be0caa35db448d Mon Sep 17 00:00:00 2001 From: mmckerns Date: Sun, 15 May 2022 16:55:05 -0400 Subject: [PATCH 08/10] path fixes for coverage --- .codecov.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index 2f730021..5c71bb63 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -20,3 +20,9 @@ coverage: target: auto threshold: 1% +fixes: + # reduces pip-installed path to git root and + # remove dist-name from setup-installed path + - "*/site-packages/::" + - "*/site-packages/mystic-*::" + From 3611f032292a0b6604da55b8568c41919fdb24dc Mon Sep 17 00:00:00 2001 From: mmckerns Date: Mon, 16 May 2022 16:00:23 -0400 Subject: [PATCH 09/10] parse init file for dist meta --- mystic/__init__.py | 60 ++++++++++++++++++++++------------------------ setup.py | 45 ++++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/mystic/__init__.py b/mystic/__init__.py index 2c328a32..5a9bda4d 100644 --- a/mystic/__init__.py +++ b/mystic/__init__.py @@ -317,38 +317,34 @@ """ -try: - # This is a hack to import a minimal package for the build process - __MYSTIC_SETUP__ -except NameError: - __all__ = ['solvers','termination','strategy','munge','tools','support', \ - 'penalty','coupler','symbolic','monitors','license','citation', \ - 'constraints','model_plotter','log_reader','collapse_plotter'] - - # solvers - import mystic.solvers as solvers - - # strategies, termination conditions - import mystic.termination as termination - import mystic.strategy as strategy - - # constraints and penalties - import mystic.constraints as constraints - import mystic.penalty as penalty - import mystic.coupler as coupler - import mystic.symbolic as symbolic - - # monitors, function wrappers, and other tools - import mystic.monitors as monitors - import mystic.munge as munge - import mystic.tools as tools - - # scripts - from mystic.scripts import model_plotter, log_reader, collapse_plotter - import mystic.support as support - - # backward compatibility - from mystic.tools import * +__all__ = ['solvers','termination','strategy','munge','tools','support', \ + 'penalty','coupler','symbolic','monitors','license','citation', \ + 'constraints','model_plotter','log_reader','collapse_plotter'] + +# solvers +import mystic.solvers as solvers + +# strategies, termination conditions +import mystic.termination as termination +import mystic.strategy as strategy + +# constraints and penalties +import mystic.constraints as constraints +import mystic.penalty as penalty +import mystic.coupler as coupler +import mystic.symbolic as symbolic + +# monitors, function wrappers, and other tools +import mystic.monitors as monitors +import mystic.munge as munge +import mystic.tools as tools + +# scripts +from mystic.scripts import model_plotter, log_reader, collapse_plotter +import mystic.support as support + +# backward compatibility +from mystic.tools import * def license(): diff --git a/setup.py b/setup.py index 711a6845..d417a39a 100644 --- a/setup.py +++ b/setup.py @@ -17,21 +17,42 @@ if unsupported: raise ValueError(unsupported) +# get distribution meta info +here = os.path.abspath(os.path.dirname(__file__)) +meta_fh = open(os.path.join(here, 'mystic/__init__.py')) try: - import builtins -except ImportError: - import __builtin__ as builtins - -# This is a hack to import a minimal package for the build process -builtins.__MYSTIC_SETUP__ = True -sys.path.append(os.path.abspath(os.path.curdir)) -import mystic + meta = {} + for line in meta_fh: + if line.startswith('__version__'): + VERSION = line.split()[-1].strip("'").strip('"') + break + meta['VERSION'] = VERSION + for line in meta_fh: + if line.startswith('__author__'): + AUTHOR = line.split(' = ')[-1].strip().strip("'").strip('"') + break + meta['AUTHOR'] = AUTHOR + LONG_DOC = "" + DOC_STOP = "FAKE_STOP_12345" + for line in meta_fh: + if LONG_DOC: + if line.startswith(DOC_STOP): + LONG_DOC += DOC_STOP.rstrip() + break + else: + LONG_DOC += line + elif line.startswith('__doc__'): + DOC_STOP = line.split(' = ')[-1] + LONG_DOC += DOC_STOP + meta['LONG_DOC'] = LONG_DOC +finally: + meta_fh.close() # get version numbers, long_description, etc -AUTHOR = mystic.__author__ -VERSION = mystic.__version__ -LONG_DOC = mystic.__doc__ #FIXME: near-duplicate of README.md -#LICENSE = mystic.__license__ #FIXME: duplicate of LICENSE +AUTHOR = meta['AUTHOR'] +VERSION = meta['VERSION'] +LONG_DOC = meta['LONG_DOC'] #FIXME: near-duplicate of README.md +#LICENSE = meta['LICENSE'] #FIXME: duplicate of LICENSE AUTHOR_EMAIL = 'mmckerns@uqfoundation.org' # check if setuptools is available From ad97a09b20f998e344fc6905982e3d34742fb87b Mon Sep 17 00:00:00 2001 From: mmckerns Date: Mon, 16 May 2022 18:58:24 -0400 Subject: [PATCH 10/10] drop rtfd build to 3.8 --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 62006eae..1541a7f3 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,7 +8,7 @@ sphinx: # build python: - version: "3.9" + version: "3.8" install: - method: pip path: .