Hox to pass a jitclass numba class to a guvectorize function?

Viewed 22

I'm trying to pass a jitclass instance to a function that's using guvectorize but I don't understand what the signature should be. For instance in the example below, what should be the signature for the C parameter ? I tried typeof(myClass()) but it doesn't work.

import numpy as np
from numba import guvectorize, float64,typeof
from numba.experimental import jitclass

spec=[('a', float64[:])]

@jitclass(spec)
class myClass():
    def __init__(self):
        self.a= np.ones(4,)


@guvectorize([(  typeof(myClass()), # the njit class
                 float64[:], # the result
                 float64[:], # dummy for size of b
                 )], '(),(n)->(n)')
def compute(C,c,b):
    b = C.a + C.a


C = myClass()
print(C)
b= np.zeros(4)
c= np.zeros(4)
compute(C,c,b)
print(b)

error

NotImplementedError: instance.jitclass.myClass#22dfcdfb280<a:array(float64, 1d, A)> cannot be represented as a Numpy dtype

0 Answers
Related