diff --git a/src/array.rs b/src/array.rs index fc4478086..4d68f7c2e 100644 --- a/src/array.rs +++ b/src/array.rs @@ -326,7 +326,8 @@ impl PyArray { /// # Example /// /// ``` - /// use numpy::{PyArray3, PyArrayMethods, PyUntypedArrayMethods}; + /// use numpy::prelude::*; + /// use numpy::PyArray3; /// use pyo3::Python; /// /// Python::with_gil(|py| { @@ -1329,7 +1330,8 @@ impl PyArray { /// # Example /// /// ``` - /// use numpy::{PyArray, PyArrayMethods, PyUntypedArrayMethods}; + /// use numpy::prelude::*; + /// use numpy::PyArray; /// use pyo3::Python; /// /// Python::with_gil(|py| { @@ -1846,8 +1848,8 @@ pub trait PyArrayMethods<'py, T, D>: PyUntypedArrayMethods<'py> { /// Extends or truncates the dimensions of an array. /// - /// This method works only on [contiguous][PyUntypedArray::is_contiguous] arrays. - /// Missing elements will be initialized as if calling [`zeros`][Self::zeros]. + /// This method works only on [contiguous][PyUntypedArrayMethods::is_contiguous] arrays. + /// Missing elements will be initialized as if calling [`zeros`][PyArray::zeros_bound]. /// /// See also [`ndarray.resize`][ndarray-resize] and [`PyArray_Resize`][PyArray_Resize]. /// @@ -1859,7 +1861,8 @@ pub trait PyArrayMethods<'py, T, D>: PyUntypedArrayMethods<'py> { /// # Example /// /// ``` - /// use numpy::{PyArray, PyArrayMethods, PyUntypedArrayMethods}; + /// use numpy::prelude::*; + /// use numpy::PyArray; /// use pyo3::Python; /// /// Python::with_gil(|py| { diff --git a/src/lib.rs b/src/lib.rs index ff696dff6..095cb01e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,6 +119,21 @@ pub use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods}; pub use ndarray::{array, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn}; +/// A prelude +/// +/// The purpose of this module is to avoid direct imports of +/// the method traits defined by this crate via a glob import: +/// +/// ``` +/// # #![allow(unused_imports)] +/// use numpy::prelude::*; +/// ``` +pub mod prelude { + pub use crate::array::{PyArray0Methods, PyArrayMethods}; + pub use crate::dtype::PyArrayDescrMethods; + pub use crate::untyped_array::PyUntypedArrayMethods; +} + #[cfg(doctest)] mod doctest { macro_rules! doc_comment {