I created a fresh virtual environment and followed the instructions for installing the development version of interpolation. The example code does not run, but luckily it seems that the fix is relatively straightforward.
import numpy as np
from interpolation.splines import UCGrid, CGrid, nodes
# we interpolate function
f = lambda x,y: np.sin(np.sqrt(x**2+y**2+0.00001))/np.sqrt(x**2+y**2+0.00001)
# uniform cartesian grid
grid = UCGrid((-1.0, 1.0, 10), (-1.0, 1.0, 10))
# get grid points
gp = nodes(grid) # 100x2 matrix
# compute values on grid points
values = f(gp[:,0], gp[:,1]).reshape((10,10))
from interpolation.splines import eval_linear
# interpolate at one point
point = np.array([0.1,0.45]) # 1d array
val = eval_linear(grid, values, point) # float
# interpolate at many points:
points = np.random.random((10000,2))
eval_linear(grid, values, points) # 10000 vector
# output can be preallocated
out = np.zeros(10000)
eval_linear(grid, values, points, out) # 10000 vector
Running this script yields the following error:
Traceback (most recent call last):
File "/home/efvega/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/213.7172.26/plugins/python/helpers/pydev/pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/efvega/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/213.7172.26/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/efvega/heap/interp/test.py", line 9, in <module>
grid = UCGrid((-1.0, 1.0, 10), (-1.0, 1.0, 10))
File "/home/efvega/heap/interp-venv/lib/python3.8/site-packages/interpolation/splines/__init__.py", line 13, in UCGrid
tt = numba.typeof((10.0, 1.0, 1))
NameError: name 'numba' is not defined
python-BaseException
The fix that got the script working for me was simply to add the numba import statement to the interpolation/splines/__init__.py file. Hope this helps!
Hello,
I created a fresh virtual environment and followed the instructions for installing the development version of interpolation. The example code does not run, but luckily it seems that the fix is relatively straightforward.
Setup virtual env
pip -m venv interp-venv
source interp-venv/bin/activate
pip install --upgrade pip
Install interpolation
pip install poetry
pip install git+https://github.com/econforge/interpolation.py.git/
Create script with contents copied from the docs:
Running this script yields the following error:
The fix that got the script working for me was simply to add the numba import statement to the
interpolation/splines/__init__.py
file. Hope this helps!