New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How make a python class jitclass compatible when it contains itself jitclass classes? #4940
Comments
This issue is marked as stale as it has had no activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with any updates and confirm that this issue still needs to be addressed. |
@ymmx2 apologies for the long delay in the response here. The problem is that import numpy as np
from numba.experimental import jitclass
from numba import int32, float64
from numba.typed import List
from numba.types import ListType
spec = [("type", int32), ("val", float64[:]), ("result", float64)]
@jitclass(spec)
class First:
def __init__(self):
self.type = 1
self.val = np.ones(100)
self.result = 0.0
def sum(self):
self.result = np.sum(self.val)
spec1 = [("ListA", ListType(First.class_type.instance_type))]
@jitclass(spec1)
class Combined:
def __init__(self):
self.ListA = List((First(), First()))
def sum(self):
for i, c in enumerate(self.ListA):
c.sum()
def getresult(self):
result = []
for i, c in enumerate(self.ListA):
result.append(c.result)
return result
C = Combined()
C.sum()
result = C.getresult()
print(result) which prints:
|
This issue is marked as stale as it has had no activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with any updates and confirm that this issue still needs to be addressed. |
Closing this issue as no further feedback has been received. |
I'm trying to make a class that could be a part of
jitclass
but has some attribute that are themselfjitclass
objects.for example, if I have two class with the decorator
@jitclass
, I would like instanced those in a third class (combined
).In that example I get an error because
numba
cannot determine the type ofself.List
which is a combination of the two jitclasses.How can I make the class
Combined
bejitclass
compatible?update
It tried Something I found elsewhere:
but I get this error
The text was updated successfully, but these errors were encountered: