You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Numeric scalars will be broadcasted implicitly without intermediate allocation.
139
+
if rhs.dtype().is_numeric(){
140
+
(lhs.clone(), rhs.clone())
141
+
}else{
142
+
(lhs.clone(), rhs.new_from_index(0, lhs.len()))
143
+
}
144
+
},
145
+
(a, b)if a == b => (lhs.clone(), rhs.clone()),
146
+
_ => {
147
+
polars_bail!(InvalidOperation:"can only do arithmetic of array's of the same type and shape; got {} and {}", lhs.dtype(), rhs.dtype())
148
+
},
149
+
};
150
+
Ok(out)
151
+
}
152
+
133
153
#[cfg(feature = "dtype-array")]
134
154
implArrayChunked{
135
155
fnarithm_helper(
136
156
&self,
137
157
rhs:&Series,
138
158
op:&dynFn(Series,Series) -> PolarsResult<Series>,
139
159
) -> PolarsResult<Series>{
140
-
let l_leaf_array = self.clone().into_series().get_leaf_array();
141
-
let shape = array_shape(self.dtype(),true);
160
+
let(lhs, rhs) = broadcast_array(self, rhs)?;
161
+
162
+
let l_leaf_array = lhs.clone().into_series().get_leaf_array();
163
+
let shape = array_shape(lhs.dtype(),true);
142
164
143
165
let r_leaf_array = if rhs.dtype().is_numeric() && rhs.len() == 1{
144
166
rhs.clone()
145
167
}else{
146
-
polars_ensure!(self.dtype() == rhs.dtype(),InvalidOperation:"can only do arithmetic of array's of the same type and shape; got {} and {}",self.dtype(), rhs.dtype());
168
+
polars_ensure!(lhs.dtype() == rhs.dtype(),InvalidOperation:"can only do arithmetic of array's of the same type and shape; got {} and {}",self.dtype(), rhs.dtype());
0 commit comments