MCPcopy Index your code
hub / github.com/PyO3/rust-numpy / to_pyarray_object_array

Function to_pyarray_object_array

tests/to_py.rs:252–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250
251#[test]
252fn to_pyarray_object_array() {
253 Python::attach(|py| {
254 let mut nd_arr = Array2::from_shape_fn((2, 3), |(_, _)| py.None());
255 nd_arr[(0, 2)] = PyDict::new(py).into_any().unbind();
256 nd_arr[(1, 0)] = PyString::new(py, "Hello:)").into_any().unbind();
257
258 let py_arr = nd_arr.to_pyarray(py);
259
260 for (a, b) in nd_arr
261 .as_slice()
262 .unwrap()
263 .iter()
264 .zip(py_arr.readonly().as_slice().unwrap().iter())
265 {
266 assert_eq!(
267 a.bind(py).compare(b).map_err(|e| e.print(py)).unwrap(),
268 Ordering::Equal
269 );
270 }
271 });
272}
273
274#[test]
275fn slice_container_type_confusion() {

Callers

nothing calls this directly

Calls 3

to_pyarrayMethod · 0.80
readonlyMethod · 0.80
as_sliceMethod · 0.45

Tested by

no test coverage detected