MCPcopy Create free account
hub / github.com/PyO3/rust-numpy / to_pyarray_array

Function to_pyarray_array

tests/to_py.rs:34–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33#[test]
34fn to_pyarray_array() {
35 Python::attach(|py| {
36 let arr = Array3::<f64>::zeros((3, 4, 2));
37
38 let shape = arr.shape().to_vec();
39 let strides = arr
40 .strides()
41 .iter()
42 .map(|dim| dim * size_of::<f64>() as isize)
43 .collect::<Vec<_>>();
44
45 let py_arr = PyArray::from_array(py, &arr);
46
47 assert_eq!(py_arr.shape(), shape.as_slice());
48 assert_eq!(py_arr.strides(), strides.as_slice());
49 });
50}
51
52#[test]
53fn iter_to_pyarray() {

Callers

nothing calls this directly

Calls 4

zerosFunction · 0.85
to_vecMethod · 0.80
stridesMethod · 0.80
shapeMethod · 0.45

Tested by

no test coverage detected