Comments (4)
Hi @fmwatson,
That bug is not very easy to fix, but there is a simple workaround. You need to specify a value for all arguments of eval_spline
. The following code works:
import numpy as np
from interpolation.splines import UCGrid, filter_cubic, eval_spline
vals = np.random.rand(5)
grid = UCGrid((0., 1., 5))
coef = filter_cubic(grid, vals)
x = np.array([0.22])
eval_spline(grid, coef, x, out=None, order=3, diff="None", extrap_mode="linear")
Reason arguments are passed as strings is to make them behave as litterals (i.e. a different function gets compiled for each value
of them).
With current version of numba, I haven't found a way to do that properly with named arguments. Not properly in the sense that it doesn't work for default values.
from interpolation.py.
Thanks @albop - that works for me now, and it is indeed a simple workaround (sorry if this is documented elsewhere!)
I wondered if this would also fix what seemed like a similar issue I'm having trying to use eval_cubic/eval_spline in a prange loop, but I still get an error in this case:
LoweringError: Failed in nopython mode pipeline (step: native lowering) scalar type Tuple(float64, float64, int64) given for non scalar argument #3
with example code
import numpy as np
import numba as nb
from interpolation.splines import UCGrid, filter_cubic, eval_spline
@nb.jit(nopython=True, parallel=True)
def run_in_pfor(vals, grid, coef, x):
for i in nb.prange(6):
_= eval_spline(grid, coef, x, out=None, order=3, diff="None", extrap_mode="linear")
vals = np.random.rand(5)
grid = UCGrid((0., 1., 5))
coef = filter_cubic(grid, vals)
x = np.array([0.22])
run_in_pfor(vals, grid, coef, x)
It looks like this was probably unrelated though (I think the error message has changed at least!) - so probably needs its own thread.
from interpolation.py.
Humm that's a new one.
My guess is it is some limitation of numba parfor but I'm not sure which one (maybe tuple in parallel for loops).
The following code raises the same error:
import numpy as np
import numba as nb
from numba import prange
@nb.jit
def my_fun(vals, grid, coef, x):
return vals[0] + coef[0] + x[0] + grid[0][0]
@nb.jit(nopython=True, parallel=True)
def run_in_pfor(vals, grid, coef, x):
t = 0.0
for h in prange(6):
res = my_fun(vals, grid, coef, x)
t += res
return t
vals = np.random.rand(5)
grid = ((0., 1., 5),)
coef = vals.copy()
x = np.array([0.22])
run_in_pfor(vals, grid, coef, x)
This indeed deserves its own thread, probably in numba though.
from interpolation.py.
I'm closing the issue here as there isn't much I can do about it.
from interpolation.py.
Related Issues (20)
- Is the dependency on tempita necessary? HOT 7
- `eval_splines` gives error `TypeError: 'module' object is not callable` HOT 2
- "interp" not working with python 3.11 HOT 2
- Errors with multidimensional outputs HOT 4
- eval_spline() doesn't recognize argument `k=` HOT 5
- New version HOT 5
- Numba warnings HOT 8
- eval_cubic fails when array to interpolate on is non-writable
- After 2.2.0 eval_linear needs C-order and dtype FLOAT64 HOT 3
- guvectorized wrapping of eval_linear() appears broken HOT 2
- DOC: reorganize
- 1D interpolation with eval_linear HOT 5
- Documentation link broken HOT 1
- Import jitclass error HOT 1
- interpolating wind data on the satellilte track (in same lon lat time)
- Documentation for derivatives HOT 9
- Error when running example code in the documentation HOT 3
- `curses` requirement? HOT 6
- Python 3.10 support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interpolation.py.