I'd like to use numba to speed up this function:
from numba import jit
@jit
def rownowaga_numba(u, v):
wymiar_x = len(u)
wymiar_y = len(u[1])
f = [[[0 for j in range(wymiar_y)] for i in range(wymiar_x)] for k in range(9)]
cx = [0., 1., 0., -1., 0., 1., -1., -1., 1.]
cy = [0., 0., 1., 0., -1., 1., 1., -1., -1.]
w = [4./9, 1./9, 1./9, 1./9, 1./9, 1./36, 1./36, 1./36, 1./36]
for i in range( wymiar_x):
for j in range (wymiar_y):
for k in range(9):
up = u[i][j]
vp = v[i][j]
udot = (up**2 + vp**2)
cu = up*cx[k] + vp*cy[k]
f[k][i][j] = w[k] + w[k]*(3.0*cu + 4.5*cu**2 - 1.5*udot)
return f
Where i test it with such data:
import timeit
import math as m
u = [[m.sin(i) + m.cos(j) for j in range(40)] for i in range(1000)]
y = [[m.sin(i) + m.cos(j) for j in range(40)] for i in range(1000)]
t0 = timeit.default_timer()
for i in range (10):
f = rownowaga_pypy(u,y)
dt = timeit.default_timer() - t0
print('loop time:', dt)
And im getting this error:
Traceback (most recent call last):
File "C:\Users\Ricevind\Desktop\PyPy\Skrypty\Rownowaga.py", line 29, in <module>
f = rownowaga_pypy(u,y)
File "C:\pyzo2014a\lib\site-packages\numba\dispatcher.py", line 171, in _compile_for_args
return self.compile(sig)
File "C:\pyzo2014a\lib\site-packages\numba\dispatcher.py", line 348, in compile
flags=flags, locals=self.locals)
File "C:\pyzo2014a\lib\site-packages\numba\compiler.py", line 637, in compile_extra
return pipeline.compile_extra(func)
File "C:\pyzo2014a\lib\site-packages\numba\compiler.py", line 356, in compile_extra
raise e
File "C:\pyzo2014a\lib\site-packages\numba\compiler.py", line 351, in compile_extra
bc = self.extract_bytecode(func)
File "C:\pyzo2014a\lib\site-packages\numba\compiler.py", line 343, in extract_bytecode
bc = bytecode.ByteCode(func=self.func)
File "C:\pyzo2014a\lib\site-packages\numba\bytecode.py", line 343, in __init__
raise NotImplementedError("cell vars are not supported")
NotImplementedError: cell vars are not supported
I'm mostly interested in the meaning of "cell vars are not supported" as Google returns no meaning results.