- Edited
I am trying to return a NumPy array from an NDSP
def test_returnN(self):
return numpy.array([0,1,2,3])
to a kernel
@kernel
def run(self):
...
#print(self.ixon.test_returnN()) # type mismatch: cannot serialize array([0, 1, 2, 3]) as None (drv annot)
print(self.ixon_test_returnN()) # proxy: type mismatch: cannot serialize array([0, 1, 2, 3]) as list
via a proxy with a suitable type annotation
def ixon_test_returnN(self) -> TList(TInt32): # https://m-labs.hk/artiq/manual/compiler.html#remote-procedure-calls
val = self.ixon.test_returnN() # https://m-labs.hk/artiq/sipyco-manual/#module-sipyco.pyon
print("ixon.returnN returns", type(val), val) # ixon.returnN returns <class 'numpy.ndarray'> [0 1 2 3]
print(" base type", type(val[0]), val[0]) # base type <class 'numpy.int32'> 0
return val
but I get the error message:
ixon.returnN returns <class 'numpy.ndarray'> [0 1 2 3]
base type <class 'numpy.int32'> 0
Traceback (most recent call last):
...
artiq.coredevice.comm_kernel.RPCReturnValueError: type mismatch: cannot serialize array([0, 1, 2, 3]) as list (<function test_return.ixon_test_returnN at 0x000002985D8C10D8> has returned [0 1 2 3])
I think the NumPy array is supported by sipyco as mentioned in the manual but I'm making a wrong compiler annotation or some other kind of error. Can this error be fixed with some other annotation from the list in the manual? Grateful for any advice.
Thanks