I ran into this problem several times by now: I save some kind of information I need in a class that holds a tuple of data, since the two are connected (e.g. a channel number for my Zotino board and some internal list index with the voltage corresponding to that channel). Outside of the kernel this is no issue, but as soon as I want to access a tuple member in a kernel function, I get the error
<repository>\tests.py:31:15-31:28: error: type (numpy.int32, numpy.int32) is not iterable
print(self.my_tuple[0])
As an example if I uncomment the last line here, the experiment will not compile:
class GenericTest(EnvExperiment):
def build(self):
self.setattr_device("core")
self.my_tuple = (1, 2)
def run(self):
print(self.my_tuple)
print(self.my_tuple[0])
self.kernel_run()
@kernel
def kernel_run(self):
self.core.reset()
print(self.my_tuple)
#print(self.my_tuple[0])
Interestingly (at least to me), the tuple itself poses no issue, just accessing its members. Why is it designed this way? Accessing list members is no problem, as long as the list has a fixed size and I think these two data types are closely related. Of course it is always possible to rewrite the tuple as a list with two elements, but I think it is a nice and natural language construct for a small amount of closely connected variables.