1
1
use crate :: error:: * ;
2
2
use crate :: { Dimension , Ix0 , Ix1 , Ix2 , Ix3 , Ix4 , Ix5 , Ix6 , IxDyn } ;
3
3
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.
6
6
///
7
7
/// Uses the [NumPy broadcasting rules]
8
8
// (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 >
10
10
where
11
11
D1 : Dimension ,
12
12
D2 : Dimension ,
@@ -15,7 +15,7 @@ fn co_broadcasting<D1, D2, Output>(shape1: &D1, shape2: &D2) -> Result<Output, S
15
15
let ( k, overflow) = shape1. ndim ( ) . overflowing_sub ( shape2. ndim ( ) ) ;
16
16
// Swap the order if d2 is longer.
17
17
if overflow {
18
- return co_broadcasting :: < D2 , D1 , Output > ( shape2, shape1) ;
18
+ return co_broadcast :: < D2 , D1 , Output > ( shape2, shape1) ;
19
19
}
20
20
// The output should be the same length as shape1.
21
21
let mut out = Output :: zeros ( shape1. ndim ( ) ) ;
@@ -38,7 +38,7 @@ pub trait BroadcastShape<Other: Dimension> {
38
38
/// The resulting dimension type after broadcasting.
39
39
type Output : Dimension ;
40
40
41
- /// Determines the shape after broadcasting the dimensions together.
41
+ /// Determines the shape after broadcasting the shapes together.
42
42
///
43
43
/// If the shapes are not compatible, returns `Err`.
44
44
fn broadcast_shape ( & self , other : & Other ) -> Result < Self :: Output , ShapeError > ;
@@ -51,7 +51,7 @@ impl<D: Dimension> BroadcastShape<D> for D {
51
51
type Output = D ;
52
52
53
53
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)
55
55
}
56
56
}
57
57
@@ -61,15 +61,15 @@ macro_rules! impl_broadcast_distinct_fixed {
61
61
type Output = $larger;
62
62
63
63
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)
65
65
}
66
66
}
67
67
68
68
impl BroadcastShape <$smaller> for $larger {
69
69
type Output = $larger;
70
70
71
71
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)
73
73
}
74
74
}
75
75
} ;
0 commit comments