I’m facing error while trying to run this piece of code:
import numpy as np
from numba import njit
@njit
def cartesian_product(*arrays):
“”"
A generator function that generates the Cartesian product of multiple arrays.
“”"
# Generate the meshgrid
grids = np.meshgrid(*arrays, indexing=‘ij’)
# Stack the arrays together to form the Cartesian product
stacked = np.stack([grid.ravel() for grid in grids], axis=-1)
# Yield each element of the Cartesian product
for elem in stacked:
yield tuple(elem)
############################
Example usage
a = np.array([1, 2, 3])
b = np.array([4, 5])
c = np.array([6, 7, 8])
for elem in cartesian_product(a, b, c):
print(elem)
#################Error !!!#################################3
File “C:\Users\XYZ\Anaconda3\lib\site-packages\numba\dataflow.py”, line 358, in op_CALL_FUNCTION_EX
raise NotImplementedError(errmsg)
NotImplementedError: Failed in nopython mode pipeline (step: analyzing bytecode)
CALL_FUNCTION_EX with **kwargs not supported
Win7, Python 3.7, numpy 1.16.5