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
In jitclass, will not compile when a member variable is used in numpy.zeros() #5095
Comments
Thanks for the report. Slightly modifying the I cannot seem to reproduce: import numpy as np
from numba import jitclass # import the decorator
from numba import int32, float32 # import the types
spec = [
('value', int32), # a simple scalar field
('array', float32[:]), # an array field
]
@jitclass(spec)
class Bag(object):
def __init__(self, value):
self.value = value
self.array = np.zeros(value, dtype=np.float32)
outputs = np.zeros((10, self.value), dtype=np.float64)
@property
def size(self):
return self.array.size
def increment(self, val):
for i in range(self.size):
self.array[i] += val
outputs = np.zeros((10, self.value), dtype=np.float64)
return self.array, outputs
mybag = Bag(21)
print('isinstance(mybag, Bag)', isinstance(mybag, Bag))
print('mybag.value', mybag.value)
print('mybag.array', mybag.array)
print('mybag.size', mybag.size)
print('mybag.increment(3)', mybag.increment(3))
print('mybag.increment(6)', mybag.increment(6)) Please could you provide more information about what caused this problem:
Once we have a reproducer someone can take a look and work on a fix. Thanks for your help. |
Strangely enough, I'm not able to reproduce the error either. I continued working on my project with my work around because it was time-sensitive. I just came back to this issue and removed the work around and it compiles just fine. |
Thanks for reporting back. Closing this issue as it seems to be resolved. If this is not the case please re-open with a comment about any item that appears to be unresolved. Many thanks. |
Dear all, unfortunately I have the same problem i.e. I get an error when I declare a zero-matrix inside a jitclass. Was this issue solved? |
@capocci-d It looks like it - if you're having an issue could you please post details of the code you're struggling with on https://numba.discourse.group ? |
does not work, but
does.
The text was updated successfully, but these errors were encountered: