You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import numpy as np
from numba import njit
from numba.experimental import jitclass
from numba import float64 # import the types
spec = [
('var', float64[:]),
]
@jitclass(spec)
class varClass():
def __init__(self, a):
self.var = np.array([a])
@njit
def printVar():
vinst = varClass(1.)
print(vinst.var)
vinst.var[0] = 0.0
print(vinst.var)
# Uncommenting this line breaks the var update
# positionsPartGroups = [i for i in range(10)]
printVar()
If I run the script, the output is:
[1.]
[0.]
which is correct.
If I uncomment the last line of the printVar function, which should have no effect, the output is
[1.]
[1.]
which is not correct.
Note that building the list with a loop works:
positionPartGroups= []
for i in range(10):
positionPartGroups.append(i)
The text was updated successfully, but these errors were encountered:
sebbelese
changed the title
Assignment of jitclass-owned array fails when list of arrays is declared in the calling function
Assignment of jitclass-owned array fails when list is declared in the calling function
Feb 3, 2022
sebbelese
changed the title
Assignment of jitclass-owned array fails when list is declared in the calling function
Assignment of jitclass-owned array fails when list comprehension is used in the calling function
Feb 3, 2022
With numba 0.55.1.
Consider the following code:
If I run the script, the output is:
which is correct.
If I uncomment the last line of the printVar function, which should have no effect, the output is
which is not correct.
Note that building the list with a loop works:
The text was updated successfully, but these errors were encountered: