interpylate
interpylate is a Python library for N-linear regular grid interpolation. It provides a flexible and efficient method to interpolate N-dimensional arrays using a N-linear approach, making it particularly useful for image interpolation and its higher-dimensional equivalents.
Installation
pip install interpylate
Dependencies
numpy: Core dependency for array operations
Architecture
The library is structured with a unified interface and specialized implementations:
NLinearRegularGridInterpolator: A unified interface that automatically selects the appropriate dimension-specific implementation based on the input dimension- For dimensions > 3, it utilizes
NLinearRegularGridInterpolatorLarge
- For dimensions > 3, it utilizes
LinearRegularGridInterpolator: Optimized for 1D arraysBiLinearRegularGridInterpolator: Optimized for 2D arrays (images)TriLinearRegularGridInterpolator: Optimized for 3D arrays (volumes)NLinearRegularGridInterpolatorLarge: Less optimized general implementation for any dimensions
This design provides both optimization for common cases and flexibility for higher dimensions.
Usage
from interpylate import NLinearRegularGridInterpolator
# Create an instance of the interpolator
# This will automatically select the appropriate implementation based on dimension
interpolator = NLinearRegularGridInterpolator(dim=3)
# Evaluate the interpolation at specified coordinates
interpolated_values = interpolator.evaluate(NDarray, continuous_inds)
# Compute the gradient of the interpolated array
gradient = interpolator.grad(NDarray, continuous_inds, evaluate_too=False)
# Compute the hessian of the interpolated array
hessian = interpolator.hess(NDarray, continuous_inds, grad_too=False, evaluate_too=False)
Main Features
- Dimension-agnostic API: Work with arrays of any dimension using a consistent interface
- Performance-optimized implementations: Specialized algorithms for 1D, 2D, and 3D cases
- Gradient computation: Calculate first-order derivatives of interpolated arrays
- Hessian computation: Compute second-order derivatives for advanced analysis
- Regular grid support: Designed specifically for regular grid structures
Examples
The interpylate GitHub repository includes several example scripts demonstrating the library's capabilities:
- 1D Interpolation: Basic interpolation for one-dimensional arrays
- 2D Interpolation: Image interpolation techniques
- 3D Interpolation: Volume data interpolation methods
- Speed Contest: Performance comparison between interpylate's TriLinearRegularGridInterpolator and scipy.interpolate.RegularGridInterpolator
Documentation
The full API documentation is available in the docs/ directory of the project or via the online documentation portal.
Contributing
At the moment, I am not actively reviewing contributions. However, if you encounter issues or have suggestions, feel free to open an issue.
License
This project is licensed under the CeCILL License.
Metadata
Release files for interpylate 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| interpylate-1.0.2.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interpylate-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / interpylate-1.0.2.tar.gz
| Download URL | interpylate-1.0.2.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8851cc084daf21cc9ad20308e0ec6b37bd787ff44362b799c3ef338d0940ef1b
|
|
BLAKE2b-256 checksum How to use checksums |
4f706c9f73e23f79bc0e15a1f9504457d25bd47a1222617e97bf701a54cdcd10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / interpylate-1.0.2-py3-none-any.whl
| Download URL | interpylate-1.0.2-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d12909a75f37d5ae8c57b3ffa5c3a5993fba662e2d73d93e4eecfe3e34121945
|
|
BLAKE2b-256 checksum How to use checksums |
5df85ba3fd6b84c7a651e93688c7e9514b374a0c4b4cfef84d944a033d8e836f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|