shaunc
shaunc

Reputation: 5611

Numba jit() function signature for function returning jitclass

If I define a jitclass:

SPEC = [ ... ]
@jitclass
class Foo:
    ...

How can I specify the type signature for a jit-ed function returning a class instance. When I try:

@jit("Foo(float32[:])")
def some_function(a: np.ndarray): ...

I get NameError: name 'Foo' is not defined even though it is declared just above.

Upvotes: 2

Views: 520

Answers (1)

shaunc
shaunc

Reputation: 5611

From https://stackoverflow.com/a/49102638/435563

Try the following:

@jit(Foo.class_type.instance_type(float32[:]))
def some_function(a: np.ndarray): ...

Upvotes: 2

Related Questions