Skip to content

Commit be13f3d

Browse files
committed
FIX: Update Axes example, clarify docs and adjust reexports
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.
1 parent a241240 commit be13f3d

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/dimension/axes.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{Axis, Dimension, Ix, Ixs};
22

33
/// Create a new Axes iterator
4-
pub fn axes_of<'a, D>(d: &'a D, strides: &'a D) -> Axes<'a, D>
4+
pub(crate) fn axes_of<'a, D>(d: &'a D, strides: &'a D) -> Axes<'a, D>
55
where
66
D: Dimension,
77
{
@@ -15,9 +15,10 @@ where
1515

1616
/// An iterator over the length and stride of each axis of an array.
1717
///
18-
/// See [`.axes()`](../struct.ArrayBase.html#method.axes) for more information.
18+
/// This iterator is created from the array method
19+
/// [`.axes()`](crate::ArrayBase::axes).
1920
///
20-
/// Iterator element type is `AxisDescription`.
21+
/// Iterator element type is [`AxisDescription`].
2122
///
2223
/// # Examples
2324
///
@@ -27,10 +28,14 @@ where
2728
///
2829
/// let a = Array3::<f32>::zeros((3, 5, 4));
2930
///
31+
/// // find the largest axis in the array
32+
/// // check the axis index and its length
33+
///
3034
/// let largest_axis = a.axes()
31-
/// .max_by_key(|ax| ax.len())
32-
/// .unwrap().axis();
33-
/// assert_eq!(largest_axis, Axis(1));
35+
/// .max_by_key(|ax| ax.len)
36+
/// .unwrap();
37+
/// assert_eq!(largest_axis.axis, Axis(1));
38+
/// assert_eq!(largest_axis.len, 5);
3439
/// ```
3540
#[derive(Debug)]
3641
pub struct Axes<'a, D> {

src/dimension/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use crate::slice::SliceArg;
1111
use crate::{Ix, Ixs, Slice, SliceInfoElem};
1212
use num_integer::div_floor;
1313

14-
pub use self::axes::{axes_of, Axes, AxisDescription};
14+
pub use self::axes::{Axes, AxisDescription};
15+
pub(crate) use self::axes::axes_of;
1516
pub use self::axis::Axis;
1617
pub use self::broadcast::DimMax;
1718
pub use self::conversion::IntoDimension;

0 commit comments

Comments
 (0)