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

Function to_pyarray_object_vec

tests/to_py.rs:233–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

231
232#[test]
233fn to_pyarray_object_vec() {
234 Python::attach(|py| {
235 let dict = PyDict::new(py);
236 let string = PyString::new(py, "Hello:)");
237 #[allow(clippy::useless_vec)] // otherwise we do not test the right trait impl
238 let vec = vec![dict.into_any().unbind(), string.into_any().unbind()];
239
240 let arr = vec.to_pyarray(py);
241
242 for (a, b) in vec.iter().zip(arr.readonly().as_slice().unwrap().iter()) {
243 assert_eq!(
244 a.bind(py).compare(b).map_err(|e| e.print(py)).unwrap(),
245 Ordering::Equal
246 );
247 }
248 });
249}
250
251#[test]
252fn to_pyarray_object_array() {

Callers

nothing calls this directly

Calls 3

to_pyarrayMethod · 0.80
readonlyMethod · 0.80
as_sliceMethod · 0.45

Tested by

no test coverage detected