I don't understand why the function compute
works when it is outside of the the class myclass
but doesn't works when it is inside?
import numpy as np
from numba import njit
@njit
def compute(length):
x=np.zeros(length)
for i in range(length):
x[i] = i
return x
class myclass():
def __init__(self):
self.length = 100
def Simule(self):
res = compute(self.length)
print(res)
def Simule2(self):
res = self.compute(self.length)
print(res)
@njit
def compute(self, length):
x = np.zeros(length)
for i in range(length):
x[i] = i
return x
if __name__ == "__main__":
instance = myclass()
instance.Simule()
instance.Simule2()