(
values: &[R],
shape: &[usize],
container: Bound<'py, PyAny>,
)
| 123 | } |
| 124 | |
| 125 | pub(crate) fn view_generic<'py, R: Element>( |
| 126 | values: &[R], |
| 127 | shape: &[usize], |
| 128 | container: Bound<'py, PyAny>, |
| 129 | ) -> PyResult<Bound<'py, PyUntypedArray>> { |
| 130 | assert_eq!( |
| 131 | shape.iter().product::<usize>(), |
| 132 | values.len(), |
| 133 | "shape does not match values length" |
| 134 | ); |
| 135 | let array: ArrayView<R, IxDyn> = |
| 136 | ArrayView::from_shape(shape, values).map_err(anyhow::Error::new)?; |
| 137 | let pyarray = unsafe { PyArray::borrow_from_array(&array, container) }; |
| 138 | Ok(pyarray |
| 139 | .cast_into::<PyUntypedArray>() |
| 140 | .expect("downcast should not fail")) |
| 141 | } |
| 142 | |
| 143 | pub(crate) fn view_scalar_generic<'py, R: Element>( |
| 144 | values: &[R], |
no outgoing calls
no test coverage detected