Open
Description
If I pass an array of structs to pointer
, it fails with the error, "NotImplementedError: Type dtype('O') not implemented"
from lpython import CPtr, c_p_pointer, p_c_pointer, dataclass, empty_c_void_p, pointer
from numpy import empty
@dataclass
class Foo:
pass
def main() -> None:
foos: Foo[1] = empty(1, dtype=Foo)
pointer(foos)
main()
$ python /var/tmp/main.py
Traceback (most recent call last):
File "/var/tmp/main.py", line 13, in <module>
main()
File "/var/tmp/main.py", line 11, in main
pointer(foos)
File "/home/dylon/Workspace/lpython/src/runtime/lpython/lpython.py", line 446, in pointer
return x.ctypes.data_as(ctypes.POINTER(convert_numpy_dtype_to_ctype(x.dtype)))
File "/home/dylon/Workspace/lpython/src/runtime/lpython/lpython.py", line 291, in convert_numpy_dtype_to_ctype
raise NotImplementedError("Type %r not implemented" % arg)
NotImplementedError: Type dtype('O') not implemented
A solution seems to be to add the dtype to convert_numpy_dtype_to_ctype
:
elif arg == np.void or arg == np.dtype('O'):
return ctypes.c_void_p
Metadata
Metadata
Assignees
Labels
No labels