11use crate :: error:: * ;
22use crate :: { Dimension , Ix0 , Ix1 , Ix2 , Ix3 , Ix4 , Ix5 , Ix6 , IxDyn } ;
33
4- /// Calculate the common shape for a pair of array shapes, which can be broadcasted
5- /// to each other . Return an error if shapes are not compatible.
4+ /// Calculate the common shape for a pair of array shapes, that they can be broadcasted
5+ /// to. Return an error if the shapes are not compatible.
66///
77/// Uses the [NumPy broadcasting rules]
88// (https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html#general-broadcasting-rules).
9- fn co_broadcasting < D1 , D2 , Output > ( shape1 : & D1 , shape2 : & D2 ) -> Result < Output , ShapeError >
9+ fn co_broadcast < D1 , D2 , Output > ( shape1 : & D1 , shape2 : & D2 ) -> Result < Output , ShapeError >
1010 where
1111 D1 : Dimension ,
1212 D2 : Dimension ,
@@ -15,7 +15,7 @@ fn co_broadcasting<D1, D2, Output>(shape1: &D1, shape2: &D2) -> Result<Output, S
1515 let ( k, overflow) = shape1. ndim ( ) . overflowing_sub ( shape2. ndim ( ) ) ;
1616 // Swap the order if d2 is longer.
1717 if overflow {
18- return co_broadcasting :: < D2 , D1 , Output > ( shape2, shape1) ;
18+ return co_broadcast :: < D2 , D1 , Output > ( shape2, shape1) ;
1919 }
2020 // The output should be the same length as shape1.
2121 let mut out = Output :: zeros ( shape1. ndim ( ) ) ;
@@ -38,7 +38,7 @@ pub trait BroadcastShape<Other: Dimension> {
3838 /// The resulting dimension type after broadcasting.
3939 type Output : Dimension ;
4040
41- /// Determines the shape after broadcasting the dimensions together.
41+ /// Determines the shape after broadcasting the shapes together.
4242 ///
4343 /// If the shapes are not compatible, returns `Err`.
4444 fn broadcast_shape ( & self , other : & Other ) -> Result < Self :: Output , ShapeError > ;
@@ -51,7 +51,7 @@ impl<D: Dimension> BroadcastShape<D> for D {
5151 type Output = D ;
5252
5353 fn broadcast_shape ( & self , other : & D ) -> Result < Self :: Output , ShapeError > {
54- co_broadcasting :: < D , D , Self :: Output > ( self , other)
54+ co_broadcast :: < D , D , Self :: Output > ( self , other)
5555 }
5656}
5757
@@ -61,15 +61,15 @@ macro_rules! impl_broadcast_distinct_fixed {
6161 type Output = $larger;
6262
6363 fn broadcast_shape( & self , other: & $larger) -> Result <Self :: Output , ShapeError > {
64- co_broadcasting :: <Self , $larger, Self :: Output >( self , other)
64+ co_broadcast :: <Self , $larger, Self :: Output >( self , other)
6565 }
6666 }
6767
6868 impl BroadcastShape <$smaller> for $larger {
6969 type Output = $larger;
7070
7171 fn broadcast_shape( & self , other: & $smaller) -> Result <Self :: Output , ShapeError > {
72- co_broadcasting :: <Self , $smaller, Self :: Output >( self , other)
72+ co_broadcast :: <Self , $smaller, Self :: Output >( self , other)
7373 }
7474 }
7575 } ;
0 commit comments