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

Method cast_array

src/array.rs:1623–1636  ·  view source on GitHub ↗
(&self, is_fortran: bool)

Source from the content-addressed store, hash-verified

1621 }
1622
1623 fn cast_array<U: Element>(&self, is_fortran: bool) -> PyResult<Bound<'py, PyArray<U, D>>>
1624 where
1625 T: Element,
1626 {
1627 let ptr = unsafe {
1628 PY_ARRAY_API.PyArray_CastToType(
1629 self.py(),
1630 self.as_array_ptr(),
1631 U::get_dtype(self.py()).into_dtype_ptr(),
1632 if is_fortran { -1 } else { 0 },
1633 )
1634 };
1635 unsafe { Bound::from_owned_ptr_or_err(self.py(), ptr).map(|ob| ob.cast_into_unchecked()) }
1636 }
1637
1638 fn permute<ID: IntoDimension>(&self, axes: Option<ID>) -> PyResult<Bound<'py, PyArray<T, D>>> {
1639 let mut axes = axes.map(|axes| axes.into_dimension());

Callers 1

castMethod · 0.80

Calls 2

as_array_ptrMethod · 0.80
into_dtype_ptrMethod · 0.80

Tested by

no test coverage detected