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

Function as_array

tests/array.rs:154–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

152
153#[test]
154fn as_array() {
155 Python::attach(|py| {
156 let pyarr = PyArray::<f64, _>::zeros(py, [3, 2, 4], false).readonly();
157 let arr = pyarr.as_array();
158
159 assert_eq!(pyarr.shape(), arr.shape());
160 assert_eq!(
161 pyarr
162 .strides()
163 .iter()
164 .map(|x| x / size_of::<f64>() as isize)
165 .collect::<Vec<_>>(),
166 arr.strides()
167 );
168
169 let not_contiguous = not_contiguous_array(py).readonly();
170 assert_eq!(not_contiguous.as_array(), array![1, 3]);
171 });
172}
173
174#[test]
175fn as_raw_array() {

Callers

nothing calls this directly

Calls 4

zerosFunction · 0.85
not_contiguous_arrayFunction · 0.85
readonlyMethod · 0.80
as_arrayMethod · 0.45

Tested by

no test coverage detected