Minterpy - Multidimensional interpolation in Python.

Overview

minterpy

to minterpy *sth.* (transitive verb) -- to produce a multivariate polynomial representation of *sth.* .
— The minterpy developers in ["Lifting the curse of dimensionality"](link-to-math-intro)

minterpy is an open-source Python package for a multivariate generalization of the classical Newton and Lagrange interpolation schemes as well as related tasks. It is based on an optimized re-implementation of the multivariate interpolation prototype algorithm (MIP) by Hecht et al.1 and thereby provides software solutions that lift the curse of dimensionality from interpolation tasks. While interpolation occurs as the bottleneck of most computational challenges, minterpy aims to free empirical sciences from their computational limitations.

minterpy is continuously extended and improved by adding further functionality and modules that provide novel digital solutions to a broad field of computational challenges, including but not limited to:

  • multivariate interpolation
  • non-linear polynomial regression
  • numerical integration
  • global (black-box) optimization
  • surface level-set methods
  • non-periodic spectral partial differential equations (PDE) solvers on flat and complex geometries
  • machine learning regularization
  • data reconstruction
  • computational solutions in algebraic geometry

Installation

Since this implementation is a prototype, we currently only provide the installation by self-building from source. We recommend to use git to get the minterpy source:

git clone https://gitlab.hzdr.de/interpol/minterpy.git

Within the source directory, you may use the following package manager to install minterpy.

A best practice is to create a virtual environment for minterpy. You can do this with the help of conda and the environment.yaml by:

conda env create -f environment.yaml

A new conda environment called minterpy is created. Activate the new environment by:

conda activate minterpy

From within the environment, install the minterpy using pip,

pip install [-e] .[all,dev,docs]

where the flag -e means the package is directly linked into the python site-packages of your Python version. The options [all,dev,docs] refer to the requirements defined in the options.extras_require section in setup.cfg.

You must not use the command python setup.py install to install minterpy, as you cannot always assume the files setup.py will always be present in the further development of minterpy.

Finally, if you want to deactivate the conda environment, type:

conda deactivate

Alternative to conda, you can create a new virtual environment via venv, virtualenv, or pyenv-virtualenv. See CONTRIBUTING.md for details.

Quickstart

With minterpy one can easily interpolate a given function. For instance, take the function f(x) = x\sin(10x) in one dimension:

    import numpy as np

    def test_function(x):
        return x * np.sin(10*x)

In order to minterpy the function test_function one can use the top-level function interpolate:

    import minterpy as mp

    interpolant = mp.interpolate(test_function,spatial_dimension=1, poly_degree=64)

Here, interpolant is a callable function, which can be used as a representation of test_function. interpolate takes as arguments the function to interpolate, the number of dimensions (spatial_dimension), and the degree of the underlying polynomial (poly_degree).

You may adjust this parameter in order to get higher accuracy. For the example above, a degree of 64 produces an interpolant which reproduces the test_function almost up to machine precision:

    import matplotlib.pylab as plt

    x = np.linspace(-1,1,100)

    plt.plot(x,interpolant(x),label="interpolant")
    plt.plot(x,test_function(x),"k.",label="test function")
    plt.legend()
    plt.show()

Compare test function with its interpolant For a more comprehensive examples, see the getting started guides section of the minterpy docs.

Testing

After installation, we encourage you to at least run the unit tests of minterpy, where we use pytest to run the tests.

If you want to run all tests, type:

pytest [-vvv]

from within the minterpy source directory.

Contributing to minterpy

Contributions to the minterpy packages are highly welcome. We recommend you to have a look at the CONTRIBUTING.md first. For a more comprehensive contribution guide visit the Contributors section of the documentation.

Credits and contributors

This work was partly funded by the Center for Advanced Systems Understanding (CASUS) that is financed by Germany’s Federal Ministry of Education and Research (BMBF) and by the Saxony Ministry for Science, Culture and Tourism (SMWK) with tax funds on the basis of the budget approved by the Saxony State Parliament.

The minterpy development team

The core development of the minterpy is currently done by a small team at the Center for Advanced Systems Understanding (CASUS), namely

Mathematical foundation

Former Members and Contributions

  • Jannik Michelfeit
  • Nico Hoffman (HZDR)
  • Steve Schmerler (HZDR)
  • Vidya Chandrashekar (TU Dresden)

Acknowledgement

Community

This package would not be possible without many contributions done from the community as well. For that we want to send big thanks to:

  • the guy who will show me how to include a list of contributors on github/gitlab

Citing

🚧 Add here the informations how to cite minterpy.

License

MIT © minterpy development team

🚧 🚧 Useful badges:

[![Actions Status][actions-badge]][actions-link] Documentation Status Code style: black

PyPI version Conda-Forge PyPI platforms

🚧 🚧 Todos

  • insert missing links
  • add sponsor logos (CASUS, HZDR, CSBD?, MPI-CBG?)
  • write shorter installation section
  • write more comprehensive quickstart (maybe higher dimensionality)
  • discuss the License we want to use

Footnotes

  1. arXiv:2010.10824

You might also like...
A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning  Essence.
A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

A python script based on OpenCV-Python, you can automatically hang up the Destiny 2 Throne to get the Dawning Essence.

Run python scripts and pass data between multiple python and node processes using this npm module

Run python scripts and pass data between multiple python and node processes using this npm module. process-communication has a event based architecture for interacting with python data and errors inside nodejs.

inverted pendulum fuzzy control python code (python 2.7.18)
inverted pendulum fuzzy control python code (python 2.7.18)

inverted-pendulum-fuzzy-control- inverted pendulum fuzzy control python code (python 2.7.18) We have 3 general functions for 3 main steps: fuzzificati

Izy - Python functions and classes that make python even easier than it is

izy Python functions and classes that make it even easier! You will wonder why t

Msgpack serialization/deserialization library for Python, written in Rust using PyO3 and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Customizable-menu-python - User customizable menu in Python

Menu personalizável pelo usuário em Python A minha ideia com esse projeto pessoa

PyPIContents is an application that generates a Module Index from the Python Package Index (PyPI) and also from various versions of the Python Standard Library.

PyPIContents is an application that generates a Module Index from the Python Package Index (PyPI) and also from various versions of the Python Standar

Minutaria is a basic educational Python timer used to learn python and software testing libraries.
Minutaria is a basic educational Python timer used to learn python and software testing libraries.

minutaria minutaria is a basic educational Python timer. The project is educational, it aims to teach myself programming, python programming, python's

Python - Aprendendo Python na ByLearn

PYTHON Identação Escopo Pai Escopo filho Escopo neto Variaveis

Comments
  • Documentation does not build due to erroneous getting-started/polynomial-regression.ipynb

    Documentation does not build due to erroneous getting-started/polynomial-regression.ipynb

    After installing the minterpy conda environment and installing minterpy as described in the quickstart, building the documentation with make html in /docs fails with

    reading sources... [ 95%] getting-started/polynomial-regression                                                                                  
    Notebook error:
    CellExecutionError in getting-started/polynomial-regression.ipynb:
    ------------------
    from minterpy.utils import newt_eval
    
    def get_regression_matrix(lag_poly, points):
        """ constructs the regression matrix by evaluating the lagrange monomials on
        all the points.
        :return: (k x N) the value of each Lagrange monomial in Newton form at each point.
        """
    
        coeffs_newton = mp.get_transformation(lag_poly, mp.NewtonPolynomial).transformation_operator.array_repr_full
        exponents = lag_poly.multi_index.exponents
        generating_points = lag_poly.grid.generating_points
        return newt_eval(points, coeffs_newton, exponents,
                         generating_points)
    
    ------------------
    
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    Input In [7], in <cell line: 1>()
    ----> 1 from minterpy.utils import newt_eval
          3 def get_regression_matrix(lag_poly, points):
          4     """ constructs the regression matrix by evaluating the lagrange monomials on
          5     all the points.
          6     :return: (k x N) the value of each Lagrange monomial in Newton form at each point.
          7     """
    
    ImportError: cannot import name 'newt_eval' from 'minterpy.utils' (/home/steinigk/src/minterpy/src/minterpy/utils.py)
    ImportError: cannot import name 'newt_eval' from 'minterpy.utils' (/home/steinigk/src/minterpy/src/minterpy/utils.py)
    

    It seems the function newt_eval has been renamed to eval_newton_polynomials.

    Applying the patch

    diff --git a/docs/getting-started/polynomial-regression.ipynb b/docs/getting-started/polynomial-regression.ipynb
    index e08f7aa..ac31a51 100644
    --- a/docs/getting-started/polynomial-regression.ipynb
    +++ b/docs/getting-started/polynomial-regression.ipynb
    @@ -174,7 +174,7 @@
        "metadata": {},
        "outputs": [],
        "source": [
    -    "from minterpy.utils import newt_eval\n",
    +    "from minterpy.utils import eval_newton_polynomials as newt_eval\n",
         "\n",
         "def get_regression_matrix(lag_poly, points):\n",
         "    \"\"\" constructs the regression matrix by evaluating the lagrange monomials on\n",
    

    allows to build documentation.

    opened by steindev 0
  • interpolant(x) is not defined

    interpolant(x) is not defined

    Hi all,

    Trying to run some of the code from the minterpy documentation and now suddenly interpolate(x) fails to work. As in

    import minterpy as mp plt.plot(x,interpolant(x),label="interpolant")

    The error message shows: NameError: name 'interpolant' is not defined

    This code has worked few weeks ago though. Any thoughts?

    opened by jmor2753 1
  • make this package available on PyPI

    make this package available on PyPI

    It would be great if I could just call pip install minterpy or to specify minterpy of a pinned version as a regular dependency in a requirements file. For that this package needs to be uploaded to PyPI.

    opened by jannikmi 4
Releases(v0.1.0-alpha)
  • v0.1.0-alpha(Nov 30, 2021)

    This is the initial alpha release of minterpy. It contains general structures to perform the polynomial interpolation task in multiple dimensions:

    • Multivariate polynomial bases (ABC + concrete implementations)
    • Base transformations
    • Interpolation schemes

    This code is still highly experimental and there is no issuance, that neither everything works as expected, nor if further releases will break the current API.

    Source code(tar.gz)
    Source code(zip)
Owner
Center for Advanced Systems Understanding
Official Github Organization account of the Center for Advanced Systems Understanding
Center for Advanced Systems Understanding
Todos os exercícios do Curso de Python, do canal Curso em Vídeo, resolvidos em Python, Javascript, Java, C++, C# e mais...

Exercícios - CeV Oferecido por Linguagens utilizadas atualmente O que vai encontrar aqui? ?? Esse repositório é dedicado a armazenar todos os enunciad

Coding in Community 43 Nov 10, 2022
PyDy, short for Python Dynamics, is a tool kit written in the Python

PyDy, short for Python Dynamics, is a tool kit written in the Python programming language that utilizes an array of scientific programs to enable the study of multibody dynamics. The goal is to have a modular framework and eventually a physics abstraction layer which utilizes a variety of backends that can provide the user with their desired workflow

PyDy 307 Jan 1, 2023
A Python script made for the Python Discord Pixels event.

Python Discord Pixels A Python script made for the Python Discord Pixels event. Usage Create an image.png RGBA image with your pattern. Transparent pi

Stanisław Jelnicki 4 Mar 23, 2022
this is a basic python project that I made using python

this is a basic python project that I made using python. This project is only for practice because my python skills are still newbie.

Elvira Firmansyah 2 Dec 14, 2022
Analisador de strings feito em Python // String parser made in Python

Este é um analisador feito em Python, neste programa, estou estudando funções e a sua junção com "if's" e dados colocados pelo usuário. Neste código,

Dev Nasser 1 Nov 3, 2021
Python with braces. Because Python is awesome, but whitespace is awful.

Bython Python with braces. Because Python is awesome, but whitespace is awful. Bython is a Python preprosessor which translates curly brackets into in

null 1 Nov 4, 2021
PSP (Python Starter Package) is meant for those who want to start coding in python but are new to the coding scene.

Python Starter Package PSP (Python Starter Package) is meant for those who want to start coding in python, but are new to the coding scene. We include

Giter/ 1 Nov 20, 2021
Py-Parser est un parser de code python en python encore en plien dévlopement.

PY - PARSER Py-Parser est un parser de code python en python encore en plien dévlopement. Une fois achevé, il servira a de nombreux projets comme glad

pf4 3 Feb 21, 2022
A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz

A community based economy bot with python works only with python 3.7.8 as web3 requires cytoolz has some issues building with python 3.10

null 4 Jan 1, 2022