I am not quite sure how to call this -- apparently very bizarre behavior that I am hoping someone can help me understand.
I am trying to update a value in the kernel during the kernel execution. I have a kernel method which is supposed to update the value of the attribute. If that assignment statement is made explicitly in "run", everything works as intended. However, once the assignment statement is put into a function, the result is wrong.
from artiq.experiment import *
import numpy as np
class test(EnvExperiment):
def return_value(self) -> TArray(TFloat):
return np.linspace(1.,10.,3)
@kernel
def reassign(self):
self.v = self.return_value()
def build(self):
self.core = self.get_device('core')
# initialize the array
self.v = self.return_value()
@kernel
def run(self):
# the original array
print(self.v)
# executing the bare assignment statment works
self.v = self.return_value()
print(self.v)
# when put into a function, values are very wrong
self.reassign()
print(self.v)
The output from my Kasli SoC system is:
[ 1. 5.5 10. ]
[ 1. 5.5 10. ]
[1.00000000e+000 4.74599300e-226 4.74601898e-226]
This occurs if the data type of the returned value is a TArray or a TList, but does not occur if you return a bare TFloat or TInt.
However, the output from my Kasli 2.0 system is as expected:
[ 1. 5.5 10. ]
[ 1. 5.5 10. ]
[ 1. 5.5 10. ]
Can anyone reproduce on their Kasli SoC? Is there a way to fix this? Thanks.