@@ -1689,78 +1689,24 @@ where
1689
1689
/// use ndarray::array;
1690
1690
///
1691
1691
/// assert!(
1692
- /// array![1., 2., 3., 4.].coerce_shape_c ((2, 2)).unwrap()
1692
+ /// array![1., 2., 3., 4.].coerce_shape ((2, 2)).unwrap()
1693
1693
/// == array![[1., 2.],
1694
1694
/// [3., 4.]]
1695
1695
/// );
1696
1696
/// ```
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 >
1700
1698
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 > ,
1754
1700
{
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)
1756
1703
}
1757
1704
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 >
1760
1707
where
1761
- E : IntoDimension ,
1708
+ E : Dimension ,
1762
1709
{
1763
- let shape = shape. into_dimension ( ) ;
1764
1710
if size_of_shape_checked ( & shape) != Ok ( self . dim . size ( ) ) {
1765
1711
return Err ( error:: incompatible_shapes ( & self . dim , & shape) ) ;
1766
1712
}
0 commit comments