Skip to content
numpy_interop

numpy_interop

Mojo module 🡭

numpy_interop

Convert numpy, pandas, MAX, and Python numeric arrays to Mojo floats.

Array-like detection and numeric conversion are delegated to numpy: np.ascontiguousarray(array, dtype="float64") accepts an ndarray of any numeric dtype, a plain Python list, and a pandas Series directly. Objects with to_numpy() (including MAX Tensor and Buffer) first copy their data to a host NumPy array. std.python.numpy.from_numpy_array borrows the contiguous result, which is then copied into List[Float64].

Requires numpy in the caller’s environment; Python.import_module( "numpy") raises if it is missing. dataviz itself never depends on numpy (pixi.toml lists it as a dev/test-only dependency).

Only one-dimensional numeric input is supported. Numpy must be installed in the caller’s environment.