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
⚡KiCad library containing footprints and symbols for inductive analog keyboard switches

Inductive Analog Switches This library contains footprints and symbols for inductive analog keyboard switches for use with the Texas Instruments LDC13

Elias Sjögreen 3 Jun 30, 2022
Simple python script for AD enumeration

AutoAD - Simple python script for AD enumeration This tool was created on my spare time to help fellow penetration testers in automating the basic enu

Mohammad Arman 28 Jun 21, 2022
A python script developed to process Windows memory images based on triage type.

Overview A python script developed to process Windows memory images based on triage type. Requirements Python3 Bulk Extractor Volatility2 with Communi

CrowdStrike 245 Nov 24, 2022
Site de gestion de cave à vin utilisant une BDD manipulée avec SQLite3 via Python

cave-vin Site de gestion de cave à vin utilisant une bdd manipulée avec MySQL ACCEDER AU SITE : Pour accéder à votre cave vous aurez besoin de lancer

Elouann Lucas 0 Jul 05, 2022
Expression interpreter written in Python

Calc Interpreter An interpreter modeled after a calculator implemented in Python 3. The program currently only supports basic mathematical expressions

1 Oct 17, 2021
CEI Natural Disaster Tracking Portal

CEI Natural Disaster Tracking Portal (cc) Climatic Eye of ISCI We are an initiative that conducts studies in the field of Space Science, publishes pro

Baris Dincer 7 Dec 24, 2022
Your missing PO formatter and linter

pofmt Your missing PO formatter and linter Features Wrap msgid and msgstr with a constant max width. Can act as a pre-commit hook. Display lint errors

Frost Ming 5 Mar 22, 2022
Solutions for the Advent of Code 2021 event.

About 📋 This repository holds all of the solution code for the Advent of Code 2021 event. All solutions are done in Python 3.9.9 and done in non-real

robert yin 0 Mar 21, 2022
Um Script De Mensagem anonimas Para linux e Termux Feito em python

Um Script De Mensagem anonimas Para linux e Termux Feito em python feito em um celular

6 Sep 09, 2021
WorldsCollide - Final Fantasy VI Randomizer

FFVI Worlds Collide Worlds Collide is an open worlds randomizer for Final Fantas

8 Jun 13, 2022
Semester long, web application project for CSCI 4370/6370 (Database Management)

Database_Project Prototype ideas for website: Computer Science library (Sells books, products, etc.) Code editor Graph visualizer / creator (can save

Jordan Harman 4 Feb 17, 2022
A Curated Collection of Awesome Python Scripts

A Curated Collection of Awesome Python Scripts that will make you go wow. This repository will help you in getting those green squares. Hop in and enjoy the journey of open source. 🚀

Prathima Kadari 248 Dec 31, 2022
Pokemon catch events project to demonstrate data pipeline on AWS

Pokemon Catches Data Pipeline This is a sample project to practice end-to-end data project; Terraform is used to deploy infrastructure; Kafka is the t

Vitor Carra 4 Sep 03, 2021
This is a simple quizz which can ask user for login/register session, then consult to the Quiz interface.

SIMPLE-QUIZ- This is a simple quizz which can ask user for login/register session, then consult to the Quiz interface. By CHAKFI Ahmed MASTER SYSTEMES

CHAKFI Ahmed 1 Jan 10, 2022
Tool to generate wrappers for Linux libraries allowing for dlopen()ing them without writing any boilerplate

Dynload wrapper This program will generate a wrapper to make it easy to dlopen() shared objects on Linux without writing a ton of boilerplate code. Th

Hein-Pieter van Braam 25 Oct 24, 2022
Anki for desktop computers

Anki This repo contains the source code for the computer version of Anki. If you'd like to try development builds of Anki but don't feel comfortable b

Ankitects 12.9k Jan 09, 2023
Displays Christmas-themed ASCII art

Christmas Color Scripts Displays Christmas-themed ASCII art. This was mainly inspired by DistroTube's Shell Color Scripts Screenshots ASCII Shadow Tex

1 Aug 09, 2022
Github Star Tracking app with Streamlit

github-star-tracking-python-app Github Star Tracking app with Streamlit #8daysofstreamlit How to run it locally? Clone or Download & Unzip the Repo En

amrrs 4 Sep 22, 2022
Convert temps in your Alfred search bar

Alfred Temp Converter Convert temps in your Alfred search bar. Download Here Usage: temp 100f converts to Celsius, Kelvin, and Rankine. temp 100c conv

Justin Hamilton 4 Apr 11, 2022
Generates Windows 95 and 95 OEM keys using the modulus 7 check algorithm

w95keygen-python windowskeygen.py - Generates Windows 95 and 95 OEM keys using the modulus 7 check algorithm Just download and drop in the directory y

Joshua Alto 1 Dec 06, 2021