interpolatorch
Linear and cubic-spline interpolation functions compatible with pytorch's autograd.
Science Score: 31.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.9%) to scientific vocabulary
Repository
Linear and cubic-spline interpolation functions compatible with pytorch's autograd.
Basic Info
- Host: GitHub
- Owner: gumrukcuoglu
- Language: Python
- Default Branch: master
- Size: 26.4 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
This is a simple module which contains vectorised interpolators for linear and cubic-spline interpolation. It is compatible with torch's autograd. It extends torchinterp1d with Cubic Spline function with a few extrapolation options.
History:
- v0.3 21/1/2025 - Added monotonic cubic interpolation (PCHIP)
- v0.2 18/9/2024 - Implemented parallel handling of independent interpolations\ 20/9/2024 - Fixed a forgotten contiguous conversion for already batched parameters
- v0.1 11/7/2024 - Initial version, single function interpolation, both linear and cubic spline.
Installation
Install via pip:
pip install git+https://github.com/gumrukcuoglu/interpolatorch
Usage:
Initialise the interpolation function with:
f_int = interpolatorch.InterpolateLinear(x_vals, y_vals, extrapolate = False, ext=0, ext_value=None)
where x_vals and y_vals have shape (N_b, N_t), with N_b counting the number of independent interpolations and N_t corresponds to the number of indices in each data set. x_vals needs to be sorted in dim=1.
Then call with f_int(x) with any torch tensor x. If dim=0 of x has size N_b, then each element of these will be used to evaluate different interpolation functions. Otherwise, x will be assumed to apply to all interpolation functions.
Same rules apply to interpolatorch.CubicSplines and interpolatorch.PCHIP.
If extrapolating:
- ext = 0 : continuous extrapolation using the relationship at the closest boundary
- ext = 1 : second order discontinuous extrapolation using the constant value at the closest boundary
- ext = 2 : (potentially) first order discontinuous extrapolation using the values provided in ext_value.
Note that PCHIP does not have extrapolation option.
To do:
Currently, a single pair of extrapolation values are supported in ext = 2 option. Separate pairs for each interpolation functions will be supported... if I need it.
Owner
- Name: Emir Gumrukcuoglu
- Login: gumrukcuoglu
- Kind: user
- Repositories: 2
- Profile: https://github.com/gumrukcuoglu
Mathematical physicist.
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: Gumrukcuoglu
given-names: Emir
orcid: https://orcid.org/0000-0002-6783-9236
title: "interpolatorch"
version: 0.3
date-released: 2025-01-21
url: "https://github.com/gumrukcuoglu/interpolatorch"
GitHub Events
Total
- Issues event: 2
- Push event: 3
Last Year
- Issues event: 2
- Push event: 3
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: 1 day
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: 1 day
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- gumrukcuoglu (1)