MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / view_generic

Function view_generic

pysplashsurf/src/utils.rs:125–141  ·  view source on GitHub ↗
(
    values: &[R],
    shape: &[usize],
    container: Bound<'py, PyAny>,
)

Source from the content-addressed store, hash-verified

123}
124
125pub(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
143pub(crate) fn view_scalar_generic<'py, R: Element>(
144 values: &[R],

Callers 3

view_scalar_genericFunction · 0.85
view_vec_genericFunction · 0.85
view_triangles_genericFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected