Hello, I have shared the reproducible code above. Background: Let me quickly introduce my data station_combinations is the cross product of “my_list” separated by the notation “_”. You can think of it as a destination among “my_list” items so 1_2 would be going from 1 to 2 whereas 2_1 would going from 2 to 1. So I will refer as

# Tag: numba

## The most efficient way rather than using np.setdiff1d and np.in1d, to remove common values of 1D arrays with unique values

I need a much faster code to remove values of an 1D array (array length ~ 10-15) that are common with another 1D array (array length ~ 1e5-5e5 –> rarely up to 7e5), which are index arrays contain integers. There is no duplicate in the arrays, and they are not sorted and the order of the values must be kept

## Python numba returned data types when calculating MSE

I am using numba to calculate MSE. The input are images which are ready as numpy arrays of uint8. Each element is 0-255. When calculating the squared difference between two images the python function returns (expectedly) a uint8 result, but the same function when using numba returns int64. What’s unclear to me is why the python-only code preserves the data-type

## how to use mask using numba @jit

I would like to do simple division and average using jit function where nopython = True. my jit function goes however this throws me an error, what would be the workaround for this? I am trying to do this without the loop, any lights would be appreiciate. Answer numba doesn’t support some arguments for some of numpy modules (e.g. np.mean()

## How to efficiently loop over an image pixel by pixel in python OpenCV?

What I want to do is to loop over an image pixel by pixel using each pixel value to draw a circle in another corresponding image. My approach is as follows: Looping this way is somewhat slow. I tried adding the @njit decorator of numba, but apparently it has problems with opencv. Input images are 32×32 pixels They map to

## Numba: indexing a vector is giving an error

I started using python and numba recently. My problem is: I have a matrix (n rows and m columns).In a for loop I have to change the values of specific columns. Without numba, the code is running fine. But when I use njit(), it just crashes. Note: In my real project, each row don’t have the same values. This is

## Time & memory complexity management with multi-dimensional matrices using parallelisation and numpy

I have a time series of very large matrices. I am trying to speed up the process and was wondering the most optimal way to do this. The two things that came to mind are to parallelize the process using numba or to apply a function to the matrices such as with np.apply_along_axis. Speed and memory complexity are very important.

## 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

## Correct usage of numpy.vstack with python’s numba

I am currently trying to speed up some python code using numba. According to the documentation of numba, numpy.meshgrid is not supported but numpy.vstack is. So I replaced the meshgrid call by vstack which works fine when not using numba. It does not work, however, when using numba. Here is the code: And here is the error message: It sounds

## Create np.array filled with zero arrays

I’m trying to initialize an “empty” array with each elements containing t_list a 8×8 np.zeros array : t_list = np.zeros((8,8), dtype=np.float32) I would now want to have a np.array with multiple t_list at each indexes: result = np.array((t_list, t_list, …., tlist)) I would like to be able to control the number of time t_list is in result. I know that