@@ -621,7 +621,8 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
621
621
/// It produces the whole chunks of a given n-dimensional chunk size,
622
622
/// skipping the remainder along each dimension that doesn't fit evenly.
623
623
///
624
- /// Iterator element is `ArrayView<A, D>`
624
+ /// The produced element is a `ArrayView<A, D>` with exactly the dimension
625
+ /// `chunk_size`.
625
626
///
626
627
/// **Panics** if any dimension of `chunk_size` is zero<br>
627
628
/// (**Panics** if `D` is `IxDyn` and `chunk_size` does not match the
@@ -637,11 +638,33 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
637
638
/// It produces the whole chunks of a given n-dimensional chunk size,
638
639
/// skipping the remainder along each dimension that doesn't fit evenly.
639
640
///
640
- /// Iterator element is `ArrayViewMut<A, D>`
641
+ /// The produced element is a `ArrayViewMut<A, D>` with exactly
642
+ /// the dimension `chunk_size`.
641
643
///
642
644
/// **Panics** if any dimension of `chunk_size` is zero<br>
643
645
/// (**Panics** if `D` is `IxDyn` and `chunk_size` does not match the
644
646
/// number of array axes.)
647
+ ///
648
+ /// ```rust
649
+ /// use ndarray::Array;
650
+ /// use ndarray::arr2;
651
+ /// let mut a = Array::zeros((6, 7));
652
+ ///
653
+ /// // Fill each 2 × 2 chunk with the index of where it appeared in iteration
654
+ /// for (i, mut chunk) in a.whole_chunks_mut((2, 2)).into_iter().enumerate() {
655
+ /// chunk.fill(i);
656
+ /// }
657
+ ///
658
+ /// // The resulting array is:
659
+ /// assert_eq!(
660
+ /// a,
661
+ /// arr2(&[[0, 0, 1, 1, 2, 2, 0],
662
+ /// [0, 0, 1, 1, 2, 2, 0],
663
+ /// [3, 3, 4, 4, 5, 5, 0],
664
+ /// [3, 3, 4, 4, 5, 5, 0],
665
+ /// [6, 6, 7, 7, 8, 8, 0],
666
+ /// [6, 6, 7, 7, 8, 8, 0]]));
667
+ /// ```
645
668
pub fn whole_chunks_mut < E > ( & mut self , chunk_size : E ) -> WholeChunksMut < A , D >
646
669
where E : IntoDimension < Dim =D > ,
647
670
S : DataMut
0 commit comments