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
GA SEI Unit 4 project backend for Bloom.

Grow Your OpportunitiesTM Background Watch the Bloom Intro Video At Bloom, we believe every job seeker deserves an opportunity to find meaningful work

Jonathan Herman 3 Sep 20, 2021
This tool helps you to reverse any regex and gives you the opposite/allowed Letters,numerics and symbols.

Regex-Reverser This tool helps you to reverse any regex and gives you the opposite/allowed Letters,numerics and symbols. Screenshots Usage/Examples py

x19 0 Jun 02, 2022
Google Scholar App Using Python

Google Scholar App Watch the tutorial video How to build a Google Scholar App | Streamlit #30 Demo Launch the web app: Reproducing this web app To rec

Chanin Nantasenamat 4 Jun 05, 2022
Repository to store sample python programs for python learning

py Repository to store sample Python programs. This repository is meant for beginners to assist them in their learning of Python. The repository cover

codebasics 5.8k Dec 30, 2022
Transform a Google Drive server into a VFX pipeline ready server

Google Drive VFX Server VFX Pipeline About The Project Quick tutorial to setup a Google Drive Server for multiple machines access, and VFX Pipeline on

Valentin Beaumont 17 Jun 27, 2022
A web-based analysis toolkit for the System Usability Scale providing calculation, plotting, interpretation and contextualization utility

System Usability Scale Analysis Toolkit The System Usability Scale (SUS) Analysis Toolkit is a web-based python application that provides a compilatio

Jonas Blattgerste 3 Oct 27, 2022
Lock a program and kills it indefinitely if it is started.

Kill By Lock Lock a program and kills it indefinitely if it is started. How start it? It' simple, you just have to double-click on the python file (.p

1 Jan 12, 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
Process GPX files (adding sensor metrics, uploading to InfluxDB, etc.) exported from imxingzhe.com

Xingzhe GPX Processor 行者轨迹处理工具 Xingzhe sells cheap GPS bike meters with sensor support including cadence, heart rate and power. But the GPX files expo

Shengqi Chen 8 Sep 23, 2022
Web app for keeping track of buildings in danger of collapsing in the event of an earthquake

Bulina Roșie 🇷🇴 Un cutremur în București nu este o situație ipotetică. Este o certitudine că acest lucru se va întâmpla. În acest context, la mai bi

Code for Romania 27 Nov 29, 2022
Open HW & SW for Scanning Electron Microscopes

OpenSEM Project Status: Preliminary The purpose of this project is to create a modern and open-source hardware and software platform for using vintage

Steven Lovegrove 7 Nov 01, 2022
Basic cryptography done in Python for study purposes

criptografia Criptografia básica feita em Python para fins de estudo Converte letras em numeros partindo do indice 0 e vice-versa A criptografia é fei

Carlos Eduardo 2 Dec 05, 2021
a simple functional programming language compiler written in python

Functional Programming Language A compiler for my small functional language. Written in python with SLY lexer/parser generator library. Requirements p

Ashkan Laei 3 Nov 05, 2021
A 3-line lisp implementation

Nanolisp The download page of many a language harbors deep senses of forboding, of evil lurking in its native lair. You feel that the language is not

5 Jun 17, 2022
A simple calculator that can add, subtract, multiply or divide depending upon the input from the user

Calculator A simple calculator that can add, subtract, multiply or divide depending upon the input from the user. In this example, we should have the

Jayesh Mali 1 Dec 27, 2021
Tool that adds githuh profile views to ur acc

Tool that adds githuh profile views to ur acc

Lamp 2 Nov 28, 2021
Pacman - A suite of tools for manipulating debian packages

Overview Repository is a suite of tools for manipulating debian packages. At a h

Pardis Pashakhanloo 1 Feb 24, 2022
An application to see if your Ethereum staking validator(s) are members of the current or next post-Altair sync committees.

eth_sync_committee.py Since the Altair upgrade, 512 validators are randomly chosen every 256 epochs (~27 hours) to form a sync committee. Validators i

4 Oct 27, 2022
A simple service that allows you to run commands on the server using text

Server Text A simple flask service that allows you to run commands on the server/computer over sms. Think of it as a shell where you run commands over

MT Devs 49 Nov 09, 2021
Pyjiting is a experimental Python-JIT compiler, which is the product of my undergraduate thesis

Pyjiting is a experimental Python-JIT compiler, which is the product of my undergraduate thesis. The goal is to implement a light-weight miniature general-purpose Python JIT compiler.

Lance.Moe 10 Apr 17, 2022