From 8b3c652251173ef8ce87085c65b8d0df213bfb4c Mon Sep 17 00:00:00 2001 From: bluss Date: Thu, 24 Dec 2020 00:10:02 +0100 Subject: [PATCH] API: Update all internal uses of genrows/gencolumns to rows/columns --- benches/bench1.rs | 4 ++-- examples/life.rs | 2 +- src/lib.rs | 24 ++++++++++++------------ src/zip/mod.rs | 4 ++-- src/zip/zipmacro.rs | 2 +- tests/array.rs | 2 +- tests/iterators.rs | 22 +++++++++++----------- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/benches/bench1.rs b/benches/bench1.rs index 8cd04c458..35a1d6e7e 100644 --- a/benches/bench1.rs +++ b/benches/bench1.rs @@ -61,7 +61,7 @@ fn iter_sum_2d_by_row(bench: &mut test::Bencher) { let a = black_box(a); bench.iter(|| { let mut sum = 0; - for row in a.genrows() { + for row in a.rows() { for &elt in row { sum += elt; } @@ -121,7 +121,7 @@ fn iter_sum_2d_cutout_outer_iter(bench: &mut test::Bencher) { let a = black_box(av); bench.iter(|| { let mut sum = 0; - for row in a.genrows() { + for row in a.rows() { for &elt in row { sum += elt; } diff --git a/examples/life.rs b/examples/life.rs index 1c2789389..748f16053 100644 --- a/examples/life.rs +++ b/examples/life.rs @@ -67,7 +67,7 @@ fn turn_on_corners(z: &mut Board) { } fn render(a: &Board) { - for row in a.genrows() { + for row in a.rows() { for &x in row { if x > 0 { print!("#"); diff --git a/src/lib.rs b/src/lib.rs index a99d6d52f..b94eee228 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -413,16 +413,16 @@ pub type Ixs = isize; /// /// The `outer_iter` and `axis_iter` are one dimensional producers. /// -/// ## `.genrows()`, `.gencolumns()` and `.lanes()` +/// ## `.rows()`, `.columns()` and `.lanes()` /// -/// [`.genrows()`][gr] is a producer (and iterable) of all rows in an array. +/// [`.rows()`][gr] is a producer (and iterable) of all rows in an array. /// /// ``` /// use ndarray::Array; /// /// // 1. Loop over the rows of a 2D array /// let mut a = Array::zeros((10, 10)); -/// for mut row in a.genrows_mut() { +/// for mut row in a.rows_mut() { /// row.fill(1.); /// } /// @@ -430,7 +430,7 @@ pub type Ixs = isize; /// use ndarray::Zip; /// let mut b = Array::zeros(a.nrows()); /// -/// Zip::from(a.genrows()) +/// Zip::from(a.rows()) /// .and(&mut b) /// .apply(|a_row, b_elt| { /// *b_elt = a_row[a.ncols() - 1] - a_row[0]; @@ -448,21 +448,21 @@ pub type Ixs = isize; /// has *a m* rows. It's composed of *a* times the previous array, so it /// has *a* times as many rows. /// -/// All methods: [`.genrows()`][gr], [`.genrows_mut()`][grm], -/// [`.gencolumns()`][gc], [`.gencolumns_mut()`][gcm], +/// All methods: [`.rows()`][gr], [`.rows_mut()`][grm], +/// [`.columns()`][gc], [`.columns_mut()`][gcm], /// [`.lanes(axis)`][l], [`.lanes_mut(axis)`][lm]. /// -/// [gr]: #method.genrows -/// [grm]: #method.genrows_mut -/// [gc]: #method.gencolumns -/// [gcm]: #method.gencolumns_mut +/// [gr]: #method.rows +/// [grm]: #method.rows_mut +/// [gc]: #method.columns +/// [gcm]: #method.columns_mut /// [l]: #method.lanes /// [lm]: #method.lanes_mut /// -/// Yes, for 2D arrays `.genrows()` and `.outer_iter()` have about the same +/// Yes, for 2D arrays `.rows()` and `.outer_iter()` have about the same /// effect: /// -/// + `genrows()` is a producer with *n* - 1 dimensions of 1 dimensional items +/// + `rows()` is a producer with *n* - 1 dimensions of 1 dimensional items /// + `outer_iter()` is a producer with 1 dimension of *n* - 1 dimensional items /// /// ## Slicing diff --git a/src/zip/mod.rs b/src/zip/mod.rs index ed92e2509..835ae5d31 100644 --- a/src/zip/mod.rs +++ b/src/zip/mod.rs @@ -561,7 +561,7 @@ impl NdProducer for RawArrayViewMut { /// let mut totals = Array1::zeros(a.nrows()); /// /// Zip::from(&mut totals) -/// .and(a.genrows()) +/// .and(a.rows()) /// .apply(|totals, row| *totals = row.sum()); /// /// // Check the result against the built in `.sum_axis()` along axis 1. @@ -570,7 +570,7 @@ impl NdProducer for RawArrayViewMut { /// /// // Example 3: Recreate Example 2 using apply_collect to make a new array /// -/// let mut totals2 = Zip::from(a.genrows()).apply_collect(|row| row.sum()); +/// let mut totals2 = Zip::from(a.rows()).apply_collect(|row| row.sum()); /// /// // Check the result against the previous example. /// assert_eq!(totals, totals2); diff --git a/src/zip/zipmacro.rs b/src/zip/zipmacro.rs index ba2b3da22..bce642505 100644 --- a/src/zip/zipmacro.rs +++ b/src/zip/zipmacro.rs @@ -90,7 +90,7 @@ /// // /// // The row is an array view; it doesn't need to be dereferenced. /// let mut totals = Array1::zeros(a.rows()); -/// azip!((totals in &mut totals, row in a.genrows()) *totals = row.sum()); +/// azip!((totals in &mut totals, row in a.rows()) *totals = row.sum()); /// /// // Check the result against the built in `.sum_axis()` along axis 1. /// assert_eq!(totals, a.sum_axis(Axis(1))); diff --git a/tests/array.rs b/tests/array.rs index db54b7e5f..7a0e2d513 100644 --- a/tests/array.rs +++ b/tests/array.rs @@ -1701,7 +1701,7 @@ fn test_f_order() { assert_eq!(c.strides(), &[3, 1]); assert_eq!(f.strides(), &[1, 2]); itertools::assert_equal(f.iter(), c.iter()); - itertools::assert_equal(f.genrows(), c.genrows()); + itertools::assert_equal(f.rows(), c.rows()); itertools::assert_equal(f.outer_iter(), c.outer_iter()); itertools::assert_equal(f.axis_iter(Axis(0)), c.axis_iter(Axis(0))); itertools::assert_equal(f.axis_iter(Axis(1)), c.axis_iter(Axis(1))); diff --git a/tests/iterators.rs b/tests/iterators.rs index 371339b96..7a30003c4 100644 --- a/tests/iterators.rs +++ b/tests/iterators.rs @@ -142,7 +142,7 @@ fn inner_iter() { // [8, 9], // ... assert_equal( - a.genrows(), + a.rows(), vec![ aview1(&[0, 1]), aview1(&[2, 3]), @@ -156,7 +156,7 @@ fn inner_iter() { b.swap_axes(0, 2); b.assign(&a); assert_equal( - b.genrows(), + b.rows(), vec![ aview1(&[0, 1]), aview1(&[2, 3]), @@ -171,13 +171,13 @@ fn inner_iter() { #[test] fn inner_iter_corner_cases() { let a0 = ArcArray::::zeros(()); - assert_equal(a0.genrows(), vec![aview1(&[0])]); + assert_equal(a0.rows(), vec![aview1(&[0])]); let a2 = ArcArray::::zeros((0, 3)); - assert_equal(a2.genrows(), vec![aview1(&[]); 0]); + assert_equal(a2.rows(), vec![aview1(&[]); 0]); let a2 = ArcArray::::zeros((3, 0)); - assert_equal(a2.genrows(), vec![aview1(&[]); 3]); + assert_equal(a2.rows(), vec![aview1(&[]); 3]); } #[test] @@ -185,7 +185,7 @@ fn inner_iter_size_hint() { // Check that the size hint is correctly computed let a = ArcArray::from_iter(0..24).reshape((2, 3, 4)); let mut len = 6; - let mut it = a.genrows().into_iter(); + let mut it = a.rows().into_iter(); assert_eq!(it.len(), len); while len > 0 { it.next(); @@ -223,7 +223,7 @@ fn outer_iter() { found_rows.push(row); } } - assert_equal(a.genrows(), found_rows.clone()); + assert_equal(a.rows(), found_rows.clone()); let mut found_rows_rev = Vec::new(); for sub in b.outer_iter().rev() { @@ -251,7 +251,7 @@ fn outer_iter() { } } println!("{:#?}", found_rows); - assert_equal(a.genrows(), found_rows); + assert_equal(a.rows(), found_rows); } #[test] @@ -370,7 +370,7 @@ fn outer_iter_mut() { found_rows.push(row); } } - assert_equal(a.genrows(), found_rows); + assert_equal(a.rows(), found_rows); } #[test] @@ -747,8 +747,8 @@ fn iterators_are_send_sync() { _send_sync(&a.iter_mut()); _send_sync(&a.indexed_iter()); _send_sync(&a.indexed_iter_mut()); - _send_sync(&a.genrows()); - _send_sync(&a.genrows_mut()); + _send_sync(&a.rows()); + _send_sync(&a.rows_mut()); _send_sync(&a.outer_iter()); _send_sync(&a.outer_iter_mut()); _send_sync(&a.axis_iter(Axis(1)));