From 846eb0fcfb2cfd38ad818eb2e3701791b9c0b29a Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Wed, 9 Oct 2024 23:31:53 +1100 Subject: [PATCH] c --- .../polars-core/src/series/arithmetic/borrowed.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/polars-core/src/series/arithmetic/borrowed.rs b/crates/polars-core/src/series/arithmetic/borrowed.rs index e4b7a535a81b..6c7a11fafb74 100644 --- a/crates/polars-core/src/series/arithmetic/borrowed.rs +++ b/crates/polars-core/src/series/arithmetic/borrowed.rs @@ -634,8 +634,17 @@ impl Div for &Series { list_borrowed::NumericListOp::Div.execute(self, rhs) }, _ => { - let (lhs, rhs) = coerce_lhs_rhs(self, rhs)?; - lhs.divide(rhs.as_ref()) + let leaf_supertype = + try_get_supertype(&self.dtype().leaf_dtype(), &rhs.dtype().leaf_dtype())?; + let leaf_supertype = if leaf_supertype.is_float() { + leaf_supertype + } else { + DataType::Float64 + }; + + let lhs = self.cast(&self.dtype().cast_leaf(leaf_supertype.clone()))?; + let rhs = rhs.cast(&rhs.dtype().cast_leaf(leaf_supertype))?; + lhs.divide(&rhs) }, }, }