Skip to content

Commit

Permalink
API: Rename .genrows/gencolumns/_mut into .rows/columns/_mut
Browse files Browse the repository at this point in the history
Rename these to give them clearer names. Rows is for rows (and
generalized rows, which is a bit strange). Columns is for columns (and
generalized ones).

Generalized just means that we take the concept of rows/columns and
somehow extend it to n-dimension arrays.

The old names .genrows/gencolums/_mut are deprecated
  • Loading branch information
bluss committed Dec 23, 2020
1 parent 1912bd9 commit 94be57d
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,12 @@ where
/// [[ 6, 7, 8], // -- row 1, 0
/// [ 9, 10, 11]]]); // -- row 1, 1
///
/// // `genrows` will yield the four generalized rows of the array.
/// for row in a.genrows() {
/// // `rows` will yield the four generalized rows of the array.
/// for row in a.rows() {
/// /* loop body */
/// }
/// ```
pub fn genrows(&self) -> Lanes<'_, A, D::Smaller>
pub fn rows(&self) -> Lanes<'_, A, D::Smaller>
where
S: Data,
{
Expand All @@ -827,11 +827,19 @@ where
Lanes::new(self.view(), Axis(n - 1))
}

#[deprecated(note="Renamed to .rows()", since="0.15")]
pub fn genrows(&self) -> Lanes<'_, A, D::Smaller>
where
S: Data,
{
self.rows()
}

/// Return a producer and iterable that traverses over the *generalized*
/// rows of the array and yields mutable array views.
///
/// Iterator element is `ArrayView1<A>` (1D read-write array view).
pub fn genrows_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
pub fn rows_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
where
S: DataMut,
{
Expand All @@ -842,6 +850,14 @@ where
LanesMut::new(self.view_mut(), Axis(n - 1))
}

#[deprecated(note="Renamed to .rows_mut()", since="0.15")]
pub fn genrows_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
where
S: DataMut,
{
self.rows_mut()
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array. For a 2D array these are the regular columns.
///
Expand All @@ -863,29 +879,53 @@ where
/// let a = arr3(&[[[ 0, 1, 2], [ 3, 4, 5]],
/// [[ 6, 7, 8], [ 9, 10, 11]]]);
///
/// // Here `gencolumns` will yield the six generalized columns of the array.
/// for row in a.gencolumns() {
/// // Here `columns` will yield the six generalized columns of the array.
/// for row in a.columns() {
/// /* loop body */
/// }
/// ```
pub fn gencolumns(&self) -> Lanes<'_, A, D::Smaller>
pub fn columns(&self) -> Lanes<'_, A, D::Smaller>
where
S: Data,
{
Lanes::new(self.view(), Axis(0))
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array. For a 2D array these are the regular columns.
///
/// Renamed to `.columns()`
#[deprecated(note="Renamed to .columns()", since="0.15")]
pub fn gencolumns(&self) -> Lanes<'_, A, D::Smaller>
where
S: Data,
{
self.columns()
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array and yields mutable array views.
///
/// Iterator element is `ArrayView1<A>` (1D read-write array view).
pub fn gencolumns_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
pub fn columns_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
where
S: DataMut,
{
LanesMut::new(self.view_mut(), Axis(0))
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array and yields mutable array views.
///
/// Renamed to `.columns_mut()`
#[deprecated(note="Renamed to .columns_mut()", since="0.15")]
pub fn gencolumns_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
where
S: DataMut,
{
self.columns_mut()
}

/// Return a producer and iterable that traverses over all 1D lanes
/// pointing in the direction of `axis`.
///
Expand Down

0 comments on commit 94be57d

Please sign in to comment.