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

Method permute

src/array.rs:1638–1648  ·  view source on GitHub ↗
(&self, axes: Option<ID>)

Source from the content-addressed store, hash-verified

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());
1640 let mut axes = axes.as_mut().map(|axes| axes.to_npy_dims());
1641 let axes = axes
1642 .as_mut()
1643 .map_or_else(ptr::null_mut, |axes| axes as *mut npyffi::PyArray_Dims);
1644
1645 let py = self.py();
1646 let ptr = unsafe { PY_ARRAY_API.PyArray_Transpose(py, self.as_array_ptr(), axes) };
1647 unsafe { Bound::from_owned_ptr_or_err(py, ptr).map(|ob| ob.cast_into_unchecked()) }
1648 }
1649
1650 fn reshape_with_order<ID: IntoDimension>(
1651 &self,

Callers 1

permute_and_transposeFunction · 0.80

Calls 2

to_npy_dimsMethod · 0.80
as_array_ptrMethod · 0.80

Tested by 1

permute_and_transposeFunction · 0.64