Two classes shown below. A particle object with 4 scalar values. A Particles object which consists of a list of Particles, a size, and a tuple that represents the color of the group of particles. I can’t get this to compile. Can someone help me understand what I’m doing wrong?
import numba
import numpy as np
from numba import int32, float64, types
from numba.experimental import jitclass
p_spec = [
('x', float64),
('y', float64),
('vx', float64),
('vy', float64),
]
@jitclass(p_spec)
class Particle(object):
def __init__(self, x, y):
self.x = x
self.y = y
self.vx = 0
self.vy = 0
ps_spec = [
('size', int32),
('color', types.UniTuple(int32, 3)),
('particles', types.ListType(Particle.class_type.instance_type)),
]
@jitclass(ps_spec)
class Particles(object):
def __init__(self, size, color):
self.size = size
self.color = numba.typed.UniTuple(1, 2, 3)
self.particles = numba.typed.List([Particle(v[0], v[1]) for v in zip(np.random.uniform(0, 1000, size),
np.random.uniform(0, 1000, size))])
p = Particles(200, (1, 2, 3))