Hello,
I’m using version “0.55.1”.
I have a series of 3D points, that I need to digitize along the 2 first axes (X,Y) to produce 2D images as for each pixel one image is the sum over the Z and the other counts the number of points belonging to that pixel.
The regular numpy is ok. I had in mind to try to speed the for loop using numba
although I am newby with numba so I may have done it wrong.
@nb.jit(nb.types.Tuple((nb.float32[:,:], nb.uint32[:,:]))(nb.float32[:,:,:],nb.float32[:,:], nb.uint32[:,:]))
def digitpts_and_updateimg(pts,img_sum,img_counts):
pts_x_id = np.digitize(pts[0,:],binsx).astype(np.uint32)
pts_y_id = np.digitize(pts[1,:],binsy).astype(np.uint32)
pts_z = pts[2,:]
for i,j,z in zip(pts_x_id,pts_y_id,pts_z):
img_sum[j,i] += z
img_counts[j,i] += 1
return img_sum, img_counts
The error is the following:
NumbaWarning:
Compilation is falling back to object mode WITH looplifting enabled because Function "digitpts_and_updateimg" failed type inference due to: No implementation of function Function(<built-in function getitem>) found for signature:
>>> getitem(array(float32, 2d, A), UniTuple(array(uint32, 1d, A) x 2))
There are 22 candidate implementations:
- Of which 20 did not match due to:
Overload of function 'getitem': File: <numerous>: Line N/A.
With argument(s): '(array(float32, 2d, A), UniTuple(array(uint32, 1d, A) x 2))':
No match.
- Of which 2 did not match due to:
Overload in function 'GetItemBuffer.generic': File: numba/core/typing/arraydecl.py: Line 166.
With argument(s): '(array(float32, 2d, A), UniTuple(array(uint32, 1d, A) x 2))':
Rejected as the implementation raised a specific error:
NumbaNotImplementedError: only one advanced index supported
....
Any idea?