sinterp
Simple fast linear interpolation for Python
sinterp functions:
interp1d(x: float, xp: list, yp: list, make_checks: bool = CHECK_INPUT)
x - x-variable for interpolation, float
xp - list with x-values of function, list
yp - list with y-values of function, list
make_checks - bool-flag of enable/disable for check inputs. Default value is True.
interp2d(x: float, y: float, xp: list, yp: list, zp: list, make_checks: bool = CHECK_INPUT)
x, y - x- and y-variable for interpolation, float
xp - list with x-values of function, list
yp - list with y-values of function, list
zp - list with y-values of function, list
make_checks - bool-flag of enable/disable for check inputs. Default value is True.
Benchmarks
Simple benchmark for compare 1d-interpolation with Numpy:
import random
import time
from numpy import interp
from sinterp import interp1d
times = [] # list with time of calculation
ratios = [] # ratio of calc with interp to interp1d
deltas = [] # summary delta of difference results by iteration
size = []
for kk in range(2, 5):
x1 = 0
x2 = int(10 ** kk)
size.append(x2)
xp = [float(_) for _ in range(x1, x2 + 1)]
yp = [_ ** 3.0 for _ in xp]
x = [random.uniform(float(x1), float(x2)) for _ in range(10000)]
start_time = time.time()
v_1 = [interp(_, xp, yp) for _ in x]
time_1 = time.time() - start_time
start_time = time.time()
v_2 = [interp1d(_, xp, yp) for _ in x]
time_2 = time.time() - start_time
times.append([time_1, time_2])
ratios.append(time_1 / time_2)
deltas.append(sum(_[1] - _[0] for _ in zip(v_1, v_2)))
# Print benchmark ratios
print('--- Benchmark results ---')
print('List size : Ratio')
for r, v in zip(size, ratios):
print(' %i : %f' % (r, v))
print('Check convergence. Difference between interp and interp1d = %f' % max(deltas))
Results Python 3.6 Win10 (at my laptop):
--- Benchmark results ---
List size : Ratio
10 : 2.312361
100 : 1.810310
1000 : 7.835562
10000 : 54.542985
100000 : 514.559448
Check convergence. Delta between interp and interp1d = 0.000000
Results Python 3.7 Linux-Mint 19.3
--- Benchmark results ---
List size : Ratio
10 : 2.409009
100 : 3.836711
1000 : 19.986599
10000 : 141.633523
100000 : 1155.362543
Check convergence. Delta between interp and interp1d = 0.000000
Simple benchmark for compare interp2d from SciPy with sinterp
import random
import time
from numpy import meshgrid, array
from scipy.interpolate import interp2d as sc_interp2d
from sinterp import interp2d as si_interp2d
times = [] # list with time of calculation
ratios = [] # ratio of calc with interp to interp1d
deltas = [] # summary delta of difference results by iteration
size = []
for kk in range(2, 5):
x1 = 0
x2 = int(10 ** kk)
size.append(x2)
xp = [float(_) for _ in range(0, x2 + 1)]
yp = [float(_) for _ in range(0, x2 + 1)]
zp = [[x * y for y in yp] for x in xp]
XP_GRID, YP_GRID = meshgrid(xp, yp)
ZP_GRID = array(zp)
xv = [random.uniform(0.0, x2) for _ in range(1000)]
yv = [random.uniform(0.0, x2) for _ in range(1000)]
start_time = time.time()
sci_interp2d = sc_interp2d(xp, yp, zp)
v_1 = [sci_interp2d(x, y) for x, y in zip(xv, yv)]
time_1 = time.time() - start_time
start_time = time.time()
v_2 = [si_interp2d(x, y, xp, yp, zp) for x, y in zip(xv, yv)]
time_2 = time.time() - start_time
times.append([time_1, time_2])
ratios.append(time_1 / time_2)
deltas.append(sum(_[1] - _[0] for _ in zip(v_1, v_2)))
# Print benchmark ratios
print('--- Benchmark results ---')
print('List size : Ratio')
for r, v in zip(size, ratios):
print(' %i : %f' % (r, v))
print('Check convergence. Difference between interp2d (scipy) and interp2d (sinterp) = %f' % max(deltas))
Metadata
Release files for sinterp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sinterp-0.2.0.tar.gz | 4.0 kB | Without provenance | Details for sinterp-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sinterp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for sinterp-0.2.0-py3-none-any.whl |
Total release size: 8.9 kB
Release files / sinterp-0.2.0.tar.gz
| Download URL | sinterp-0.2.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91c79759a7c86221c28f783b4a420109068c15d507b644886beba0d002374ff1
|
|
BLAKE2b-256 checksum How to use checksums |
9acb0f96def7d780faef94e4cf43f74fe218ddf8afd7a8a3992782d1d1a51506
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.9
|
Release files / sinterp-0.2.0-py3-none-any.whl
| Download URL | sinterp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4a6c27ba8262b091a5aa2d4297bab18d3b02c9c8d84457308c97b8f4c65b435
|
|
BLAKE2b-256 checksum How to use checksums |
641887cc4c9d6a19304834e1df52914afe836e14dce05757c68c46067d2f7644
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.9
|
Security for sinterp 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.