Minterpy - Multidimensional interpolation in Python.

Related tags

Miscellaneousminterpy
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
Button paginator using discord_components

Button Paginator With discord-components Button paginator using discord_components Welcome! It's a paginator for discord-componets! Thanks to the orig

Decave 7 Feb 12, 2022
[draft] tools for schnetpack

schnetkit some tooling for schnetpack EXPERIMENTAL/IN DEVELOPMENT DO NOT USE This is an early draft of some infrastructure built around schnetpack. In

Marcel 1 Nov 08, 2021
Team Curie is a group of people working together to achieve a common aim

Team Curie is a group of people working together to achieve a common aim. We are enthusiasts!.... We are setting the pace!.... We offer encouragement and motivation....And we believe TeamWork makes t

4 Aug 07, 2021
DG - A(n) (unusual) programming language

DG - A(n) (unusual) programming language General structure There are no infix-operators (i.e. 1 + 1) Each operator takes 2 parameters When there are m

1 Mar 05, 2022
Pardus-flatpak-gui - A Flatpak GUI for Pardus

Pardus Flatpak GUI A GUI for Flatpak. You can run, install (from FlatHub and fro

Erdem Ersoy 2 Feb 17, 2022
Statistics Calculator module for all types of Stats calculations.

Statistics-Calculator This Calculator user the formulas and methods to find the statistical values listed. Statistics Calculator module for all types

2 May 29, 2022
Automated GitHub profile content using the USGS API, Plotly and GitHub Actions.

Top 20 Largest Earthquakes in the Past 24 Hours Location Mag Date and Time (UTC) 92 km SW of Sechura, Peru 5.2 11-05-2021 23:19:50 113 km NNE of Lobuj

Mr. Phantom 28 Oct 31, 2022
Pixelarticons - Pixel Art Icons made simple for Flutter, powered by pixelarticons and fontify

Pixelarticons - Pixel Art Icons made simple for Flutter, powered by pixelarticons and fontify

lask 16 Dec 12, 2022
Курс про техническое совершенство для нетехнарей

Technical Excellence 101 Курс про техническое совершенство для нетехнарей. Этот курс представлят из себя серию воркшопов, при помощи которых можно объ

Anton Bevzuk 11 Nov 13, 2022
Transparently load variables from environment or JSON/YAML file.

A thin wrapper over Pydantic's settings management. Allows you to define configuration variables and load them from environment or JSON/YAML file. Also generates initial configuration files and docum

Lincoln Loop 90 Dec 14, 2022
A basic animation modding workflow for FFXIV

AnimAssist Provides a quick and easy way to mod animations in FFXIV. You will need: Before anything, the VC++2012 32-bit Redist from here. Havok will

liam 37 Dec 16, 2022
A proof-of-concept package manager for Cairo contracts/libraries

glyph A proof-of-concept package manager for Cairo contracts/libraries. Distribution through pypi. Installation through existing package managers -- p

Sam Barnes 11 Jun 06, 2022
Decentralized intelligent voting application.

DiVA Decentralized intelligent voting application. Hack the North 2021. Inspiration Following the previous US election, many voters were fearful that

Ali Shariatmadari 4 Jun 05, 2022
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 ins

Tyler Laceby 2 Aug 06, 2021
Welcome to my pod transcript search webb app!

pod_transcript_search Welcome to the pod transcript search webb app! Tech stack used: Languages used: Python (for the back-end), JavaScript (for the f

3 Feb 04, 2022
Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

Waydroid is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu.

WayDroid 4.7k Jan 08, 2023
The Playwright Workshop for TAU: The Homecoming

tau-playwright-workshop This repository contains the instructions and example code for the Playwright workshop for TAU: The Homecoming on December 1,

Pandy Knight 134 Dec 30, 2022
Python language from the beginning.

Python For Beginners Python Programming Language ♦️ Python is a very powerful and user friendly programming language. ❄️ ♦️ There are some basic sytax

Randula Yashasmith Mawaththa 6 Sep 18, 2022
An alternative site to emplea.do due to inconsistent service of the app.

feline a agile and fast alternative to emplea.do License: MIT Settings Moved to settings. Basic Commands Setting Up Your Users To create a normal user

Codetiger 8 Nov 10, 2021
Check broken access control exists in the Java web application

javaEeAccessControlCheck Check broken access control exists in the Java web application. 检查 Java Web 应用程序中是否存在访问控制绕过问题。 使用 python3 javaEeAccessControl

kw0ng 3 May 04, 2022