Jitclass with tuple not working

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))

hi @amir650 , I don’t see anything obviously wrong, but I can’t run your code to be sure. could you share a reproducer example? Something that can be copied-and-pasted and will show the error you are getting when executed?
In the code above the imports are missing, and constants is missing. Also, it would help if you use triple quotes ``` so the code remains formatted.

Luk

Hi @luk-f-a,

Thank you for your prompt response. I have updated the code sample with your recommendations. It’s self contained and demonstrates the issue I am having. I can get a List to work in Numba, but not a Tuple as you can see. Please let me know if this is sufficient. Thanks again!

I fixed it - I just need to assign the incoming tuple directly. Thank you.