Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from numba import jitclass, float64, optional, njit
- from numba.types import ListType
- from numba.typed import List
- @njit(cache=True)
- def npv3(a,b,c):
- return np.array((a,b,c),dtype=np.float64)
- spec = [
- ('C', float64),
- ('points', optional( ListType(float64[:])) ) ,
- ]
- float_array = float64[:]
- @jitclass(spec)
- class SampleClass(object):
- def __init__(self):
- self.C = np.float64(1.0)
- self.points = List.empty_list(float_array)
- self.init_values()
- def init_values(self):
- self.points.append( npv3(0,0,0) )
- self.points.append( npv3(0,0,0) )
- def clear(self):
- self.points.clear()
- if __name__ == '__main__':
- sc = SampleClass()
- print("len:",len(sc.points))
- #sc.points.__init__()
- #sc.points.__delitem__(0)
- sc.clear()
- #sc.points.clear()
- #sc.points = List.empty_list( float_array )
- print("len:", len(sc.points))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement