You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The follwing bare bone function seems to fail to understand numpy.zeros.
I see in the example you could use zero_like maybe, but in my case my output is 1D greater than any input, so I need to create it via a numpy.zeros or similar.
I left the actual function I'm trying to implement commented out, if naybody can comment on obvious numba errors with it please feel free to do so.
Also if I type n1=n2=n3=n4=10 the jit doesn't understand.
import numba
from numba.decorators import jit as jit
def recontruct4DCore(ps,A,B,P0):
## n1,n3,n4 = ps.shape
## n2=A.shape[0]
n1=10
n2=10
n3=10
n4=10
p = numpy.zeros((n1,n2,n3,n4))
## for j in range(n2):
## Afact=A[j]_P0
## for i in range(n1):
## for k in range(n3):
## for l in range(n4):
## p[i,j,k,l]=ps[i,k,l]_B[j]+Afact
return p
There are many Numpy function not currently supported, and numpy.zeros() is no exception. The work around is to use an output parameter, similar to the example in fbcorr.py (modulo the "return" statement, see issue #21). For example:
def recontruct4DCore(ps,A,B,P0, output):
n1,n3,n4 = ps.shape
n2=A.shape[0]
for j in range(n2):
Afact=A[j]*P0
for i in range(n1):
for k in range(n3):
for l in range(n4):
output[i,j,k,l]=ps[i,k,l]*B[j]+Afact
Use numpy.zeros() outside the call to this function to create the output array, and it should work (not sure if shape support handles indexing that well, however).
Hello,
The follwing bare bone function seems to fail to understand numpy.zeros.
I see in the example you could use zero_like maybe, but in my case my output is 1D greater than any input, so I need to create it via a numpy.zeros or similar.
I left the actual function I'm trying to implement commented out, if naybody can comment on obvious numba errors with it please feel free to do so.
Also if I type n1=n2=n3=n4=10 the jit doesn't understand.
import numba
from numba.decorators import jit as jit
def recontruct4DCore(ps,A,B,P0):
## n1,n3,n4 = ps.shape
## n2=A.shape[0]
n1=10
n2=10
n3=10
n4=10
p = numpy.zeros((n1,n2,n3,n4))
## for j in range(n2):
## Afact=A[j]_P0
## for i in range(n1):
## for k in range(n3):
## for l in range(n4):
## p[i,j,k,l]=ps[i,k,l]_B[j]+Afact
return p
numbaReconstruct4D = jit(ret_type = numba.d[:,:,:,:], arg_types=[numba.d[:,:,:],numba.d[:],numba.d[:],numba.d])(recontruct4DCore)
The text was updated successfully, but these errors were encountered: