Open abdullahselek opened 1 year ago
👍 yeah I have hit many similar issues when trying a bit more realistic python interop; is this a known issue? is there any ETA or tracking task at all we might be able to follow to know when to expect to be able to call out to python and a few core libs like numpy reliably?
Hi @zachgrayio and @abdullahselek passing multidimensional arrays to Python isn't supported yet, we can use this ticket to track it.
@arthurevans @scottamain potentially add this to the roadmap sharp edges?
There is a workaround until this is resolved:
import ast
import numpy as np
def array(arrays: str, dtype):
_, dtype = dtype.split(".")
return np.array(ast.literal_eval(arrays), getattr(np, dtype))
from python import Python
fn main() raises:
Python.add_to_path(".")
let np = Python.import_module("np_helper")
let array = np.array("[[1, 2, 3], [4, 5, 6]]", "np.int32")
print(array)
fyi @stumpOS I couldn't find an existing ticket for this
FYI, this was opened almost a year ago now... But thought I'd mention, for what it's worth, the following is possible:
var np = Python.import_module("numpy")
var np_array = np.array([1, 2, 3, 4, 5, 6], np.int32).reshape(2,3)
Nested lists currently are not supported, and related to this:
Bug description
Can't create multi dimensional numpy array, creating single dimension numpy array works well.
Steps to reproduce
Same behaviour both on playground and VSCode. It throws "call expansion failed - no concrete specializations" and "expression failed to parse (no further compiler diagnostics)".
System information