@@ -1689,78 +1689,24 @@ where
16891689 /// use ndarray::array;
16901690 ///
16911691 /// assert!(
1692- /// array![1., 2., 3., 4.].coerce_shape_c ((2, 2)).unwrap()
1692+ /// array![1., 2., 3., 4.].coerce_shape ((2, 2)).unwrap()
16931693 /// == array![[1., 2.],
16941694 /// [3., 4.]]
16951695 /// );
16961696 /// ```
1697- #[ deprecated( note="Replaced by one of `to_shape`, `coerce_shape_c`, `coerce_shape_f` \
1698- and `into_shape_owned`.", since="0.15.0" ) ]
1699- pub fn into_shape_ < E > ( self , shape : E ) -> Result < ArrayBase < S , E :: Dim > , ShapeError >
1697+ pub fn coerce_shape < E > ( self , shape : E ) -> Result < ArrayBase < S , E :: Dim > , ShapeError >
17001698 where
1701- E : IntoDimension ,
1702- {
1703- self . coerce_shape_with_order ( shape, Order :: Automatic )
1704- }
1705-
1706- /// Transform the array into `shape`; any shape with the same number of elements is accepted,
1707- /// but the source array or view must be contiguous and stored in standard row-major (C) memory
1708- /// order.
1709- ///
1710- /// This method allows any array, view or raw view and never copies elements.
1711- ///
1712- /// **Errors** if the new shape doesn't have the same number of elements as the array's current
1713- /// shape.<br>
1714- /// **Errors** if the input array is not C-contiguous.
1715- ///
1716- /// ```
1717- /// use ndarray::array;
1718- ///
1719- /// assert!(
1720- /// array![1., 2., 3., 4.].coerce_shape_c((2, 2)).unwrap()
1721- /// == array![[1., 2.],
1722- /// [3., 4.]]
1723- /// );
1724- /// ```
1725- pub fn coerce_shape_c < E > ( self , shape : E ) -> Result < ArrayBase < S , E :: Dim > , ShapeError >
1726- where
1727- E : IntoDimension ,
1728- {
1729- self . coerce_shape_with_order ( shape, Order :: RowMajor )
1730- }
1731-
1732- /// Transform the array into `shape`; any shape with the same number of elements is accepted,
1733- /// but the source array or view must be contiguous and stored in column-major (F) memory
1734- /// order.
1735- ///
1736- /// This method allows any array, view or raw view and never copies elements.
1737- ///
1738- /// **Errors** if the new shape doesn't have the same number of elements as the array's current
1739- /// shape.<br>
1740- /// **Errors** if the input array is not F-contiguous.
1741- ///
1742- /// ```
1743- /// use ndarray::array;
1744- ///
1745- /// assert!(
1746- /// array![1., 2., 3., 4.].coerce_shape_f((2, 2)).unwrap()
1747- /// == array![[1., 3.],
1748- /// [2., 4.]]
1749- /// );
1750- /// ```
1751- pub fn coerce_shape_f < E > ( self , shape : E ) -> Result < ArrayBase < S , E :: Dim > , ShapeError >
1752- where
1753- E : IntoDimension ,
1699+ E : ShapeArg < StrideType = Contiguous > ,
17541700 {
1755- self . coerce_shape_with_order ( shape, Order :: ColumnMajor )
1701+ let ( shape, order) = shape. into_shape_and_order ( Order :: RowMajor ) ;
1702+ self . coerce_shape_order ( shape, order)
17561703 }
17571704
1758- fn coerce_shape_with_order < E > ( self , shape : E , mut order : Order )
1759- -> Result < ArrayBase < S , E :: Dim > , ShapeError >
1705+ fn coerce_shape_order < E > ( self , shape : E , mut order : Order )
1706+ -> Result < ArrayBase < S , E > , ShapeError >
17601707 where
1761- E : IntoDimension ,
1708+ E : Dimension ,
17621709 {
1763- let shape = shape. into_dimension ( ) ;
17641710 if size_of_shape_checked ( & shape) != Ok ( self . dim . size ( ) ) {
17651711 return Err ( error:: incompatible_shapes ( & self . dim , & shape) ) ;
17661712 }
0 commit comments