Skip to content

Commit

Permalink
FIX: Update Axes example, clarify docs and adjust reexports
Browse files Browse the repository at this point in the history
Update the example to use fields instead of method calls. (The
deprecation warnings in examples are never visible to us.)

Use pub(crate) more correctly here, for the items that are not pub.
  • Loading branch information
bluss committed Mar 27, 2021
1 parent a241240 commit be13f3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/dimension/axes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{Axis, Dimension, Ix, Ixs};

/// Create a new Axes iterator
pub fn axes_of<'a, D>(d: &'a D, strides: &'a D) -> Axes<'a, D>
pub(crate) fn axes_of<'a, D>(d: &'a D, strides: &'a D) -> Axes<'a, D>
where
D: Dimension,
{
Expand All @@ -15,9 +15,10 @@ where

/// An iterator over the length and stride of each axis of an array.
///
/// See [`.axes()`](../struct.ArrayBase.html#method.axes) for more information.
/// This iterator is created from the array method
/// [`.axes()`](crate::ArrayBase::axes).
///
/// Iterator element type is `AxisDescription`.
/// Iterator element type is [`AxisDescription`].
///
/// # Examples
///
Expand All @@ -27,10 +28,14 @@ where
///
/// let a = Array3::<f32>::zeros((3, 5, 4));
///
/// // find the largest axis in the array
/// // check the axis index and its length
///
/// let largest_axis = a.axes()
/// .max_by_key(|ax| ax.len())
/// .unwrap().axis();
/// assert_eq!(largest_axis, Axis(1));
/// .max_by_key(|ax| ax.len)
/// .unwrap();
/// assert_eq!(largest_axis.axis, Axis(1));
/// assert_eq!(largest_axis.len, 5);
/// ```
#[derive(Debug)]
pub struct Axes<'a, D> {
Expand Down
3 changes: 2 additions & 1 deletion src/dimension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use crate::slice::SliceArg;
use crate::{Ix, Ixs, Slice, SliceInfoElem};
use num_integer::div_floor;

pub use self::axes::{axes_of, Axes, AxisDescription};
pub use self::axes::{Axes, AxisDescription};
pub(crate) use self::axes::axes_of;
pub use self::axis::Axis;
pub use self::broadcast::DimMax;
pub use self::conversion::IntoDimension;
Expand Down

0 comments on commit be13f3d

Please sign in to comment.