Skip to content
Advertisement

Setting item to numpy array with numba doesn’t execute and it doesn’t raise any exception

When I search for a solution of why the code below doesn’t run, I always conclude that it should just work.

I am essentially trying to speed up the colouring of RGB images using numba. I get that the problem is with setting the item into the brushOverlay array because if I simply get the item and print it, it works just fine. I thought it could be a static type issue, but all arrays are float64 dtype. What am I missing? Thanks!

JavaScript

Advertisement

Answer

There is an out-of-bound on brushOverlay which cause a segmentation fault (ie. an unexpected crash of the process due to some part of the memory read/written while it as not been allocated). Indeed, np.nonzero(mask) returns a tuple of two arrays of size 2048 causing the nested loop to iterate over the range range(2048).

Note that Numba does not perform any check on ND-arrays by default (due to the additional overhead it would cause). This is why the error is not explicitly reported.

Advertisement