Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Jan 6, 2025
1 parent f144974 commit 528d79d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
4 changes: 3 additions & 1 deletion crates/polars-core/src/chunked_array/logical/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ impl LogicalType for DatetimeChunked {
.into_time()
.into_series());
},
dt if dt.is_primitive_numeric() => return self.0.cast_with_options(dtype, cast_options),
dt if dt.is_primitive_numeric() => {
return self.0.cast_with_options(dtype, cast_options)
},
dt => {
polars_bail!(
InvalidOperation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ impl ChunkExplode for ListChunked {
let (indices, new_offsets) = if listarr.null_count() == 0 {
// SPECIALIZED path.
let inner_phys = self.inner_dtype().to_physical();
if inner_phys.is_primitive_numeric() || inner_phys.is_null() || inner_phys.is_bool() {
if inner_phys.is_primitive_numeric() || inner_phys.is_null() || inner_phys.is_bool()
{
return Ok(self.specialized(values, offsets, offsets_buf));
}
// Use gather
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ impl Series {
Boolean => s.cast(&Float64).unwrap().agg_median(groups),
Float32 => SeriesWrap(s.f32().unwrap().clone()).agg_median(groups),
Float64 => SeriesWrap(s.f64().unwrap().clone()).agg_median(groups),
dt if dt.is_primitive_numeric() => apply_method_physical_integer!(s, agg_median, groups),
dt if dt.is_primitive_numeric() => {
apply_method_physical_integer!(s, agg_median, groups)
},
#[cfg(feature = "dtype-datetime")]
dt @ Datetime(_, _) => self
.to_physical_repr()
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-core/src/series/arithmetic/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub fn coerce_lhs_rhs_owned(lhs: Series, rhs: Series) -> PolarsResult<(Series, S
}

fn is_eligible(lhs: &DataType, rhs: &DataType) -> bool {
!lhs.is_logical() && lhs.to_physical().is_primitive_numeric() && rhs.to_physical().is_primitive_numeric()
!lhs.is_logical()
&& lhs.to_physical().is_primitive_numeric()
&& rhs.to_physical().is_primitive_numeric()
}

#[cfg(feature = "performant")]
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-expr/src/expressions/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ fn apply_operator_owned(left: Column, right: Column, op: Operator) -> PolarsResu
match op {
Operator::Plus => left.try_add_owned(right),
Operator::Minus => left.try_sub_owned(right),
Operator::Multiply if left.dtype().is_primitive_numeric() && right.dtype().is_primitive_numeric() => {
Operator::Multiply
if left.dtype().is_primitive_numeric() && right.dtype().is_primitive_numeric() =>
{
left.try_mul_owned(right)
},
_ => apply_operator(&left, &right, op),
Expand Down
12 changes: 10 additions & 2 deletions crates/polars-plan/src/plans/conversion/dsl_to_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,11 @@ pub fn to_alp_impl(lp: DslPlan, ctxt: &mut DslConversionContext) -> PolarsResult
&input_schema,
),
StatsFunction::Mean => stats_helper(
|dt| dt.is_primitive_numeric() || dt.is_temporal() || dt == &DataType::Boolean,
|dt| {
dt.is_primitive_numeric()
|| dt.is_temporal()
|| dt == &DataType::Boolean
},
|name| col(name.clone()).mean(),
&input_schema,
),
Expand All @@ -838,7 +842,11 @@ pub fn to_alp_impl(lp: DslPlan, ctxt: &mut DslConversionContext) -> PolarsResult
&input_schema,
),
StatsFunction::Median => stats_helper(
|dt| dt.is_primitive_numeric() || dt.is_temporal() || dt == &DataType::Boolean,
|dt| {
dt.is_primitive_numeric()
|| dt.is_temporal()
|| dt == &DataType::Boolean
},
|name| col(name.clone()).median(),
&input_schema,
),
Expand Down
10 changes: 6 additions & 4 deletions crates/polars-python/src/series/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ impl PySeries {
length: len,
})
},
dt if dt.is_primitive_numeric() => Ok(with_match_physical_numeric_polars_type!(dt, |$T| {
let ca: &ChunkedArray<$T> = s.as_ref().as_ref().as_ref();
BufferInfo { pointer: get_pointer(ca), offset: 0, length: ca.len() }
})),
dt if dt.is_primitive_numeric() => {
Ok(with_match_physical_numeric_polars_type!(dt, |$T| {
let ca: &ChunkedArray<$T> = s.as_ref().as_ref().as_ref();
BufferInfo { pointer: get_pointer(ca), offset: 0, length: ca.len() }
}))
},
dt => {
let msg = format!("`_get_buffer_info` not implemented for non-physical type {dt}; try to select a buffer first");
Err(PyTypeError::new_err(msg))
Expand Down

0 comments on commit 528d79d

Please sign in to comment.