diff --git a/crates/polars-core/src/frame/column.rs b/crates/polars-core/src/frame/column.rs index 71344b3e9005f..ecad8a22aab6c 100644 --- a/crates/polars-core/src/frame/column.rs +++ b/crates/polars-core/src/frame/column.rs @@ -45,7 +45,7 @@ impl Column { #[inline] pub fn new_empty(name: PlSmallStr, dtype: &DataType) -> Self { // @scalar-opt - Self::Series(Series::new_empty(name, &dtype)) + Self::Series(Series::new_empty(name, dtype)) } #[inline] @@ -266,41 +266,69 @@ impl Column { self.as_materialized_series().null_count() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_min(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_min(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_max(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_max(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_mean(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_mean(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_sum(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_sum(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. pub unsafe fn agg_first(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_first(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. pub unsafe fn agg_last(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_last(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. pub unsafe fn agg_n_unique(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_n_unique(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. pub unsafe fn agg_quantile( &self, groups: &GroupsProxy, @@ -315,21 +343,37 @@ impl Column { .into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_median(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_median(groups) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_var(&self, groups: &GroupsProxy, ddof: u8) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_var(groups, ddof) }.into() } - pub unsafe fn agg_std(&self, groups: &GroupsProxy, ddof: u8) -> Self { + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] + pub(crate) unsafe fn agg_std(&self, groups: &GroupsProxy, ddof: u8) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_std(groups, ddof) }.into() } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. + #[cfg(feature = "algorithm_group_by")] pub unsafe fn agg_list(&self, groups: &GroupsProxy) -> Self { // @scalar-opt unsafe { self.as_materialized_series().agg_list(groups) }.into() @@ -398,6 +442,9 @@ impl Column { .vec_hash_combine(build_hasher, hashes) } + /// # Safety + /// + /// Indexes need to be in bounds. pub(crate) unsafe fn equal_element( &self, idx_self: usize, @@ -524,6 +571,9 @@ impl Column { .map(Column::from) } + /// # Safety + /// + /// This can lead to invalid memory access in downstream code. pub unsafe fn cast_unchecked(&self, dtype: &DataType) -> PolarsResult { // @scalar-opt unsafe { self.as_materialized_series().cast_unchecked(dtype) }.map(Column::from) @@ -709,6 +759,9 @@ impl Column { self.as_materialized_series().phys_iter() } + /// # Safety + /// + /// Does not perform bounds check on `index` pub unsafe fn get_unchecked(&self, index: usize) -> AnyValue { // @scalar-opt self.as_materialized_series().get_unchecked(index) @@ -1008,10 +1061,9 @@ impl From for _SerdeSeries { } } -impl Into for _SerdeSeries { +impl From<_SerdeSeries> for Series { #[inline] - fn into(self) -> Series { - self.0 + fn from(value: _SerdeSeries) -> Self { + value.0 } } - diff --git a/crates/polars-core/src/frame/group_by/mod.rs b/crates/polars-core/src/frame/group_by/mod.rs index 322c6b967e338..e2fbb90d6e749 100644 --- a/crates/polars-core/src/frame/group_by/mod.rs +++ b/crates/polars-core/src/frame/group_by/mod.rs @@ -55,7 +55,9 @@ impl DataFrame { let groups = if by.len() == 1 { let column = &by[0]; - column.as_materialized_series().group_tuples(multithreaded, sorted) + column + .as_materialized_series() + .group_tuples(multithreaded, sorted) } else if by.iter().any(|s| s.dtype().is_object()) { #[cfg(feature = "object")] { @@ -294,7 +296,7 @@ impl<'df> GroupBy<'df> { }, } }) - .map(|s| Column::from(s)) + .map(Column::from) .collect() }) } @@ -396,7 +398,7 @@ impl<'df> GroupBy<'df> { let new_name = fmt_group_by_column(agg_col.name().as_str(), GroupByMethod::Sum); let mut agg = unsafe { agg_col.agg_sum(&self.groups) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -433,7 +435,7 @@ impl<'df> GroupBy<'df> { let new_name = fmt_group_by_column(agg_col.name().as_str(), GroupByMethod::Min); let mut agg = unsafe { agg_col.agg_min(&self.groups) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -470,7 +472,7 @@ impl<'df> GroupBy<'df> { let new_name = fmt_group_by_column(agg_col.name().as_str(), GroupByMethod::Max); let mut agg = unsafe { agg_col.agg_max(&self.groups) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -507,7 +509,7 @@ impl<'df> GroupBy<'df> { let new_name = fmt_group_by_column(agg_col.name().as_str(), GroupByMethod::First); let mut agg = unsafe { agg_col.agg_first(&self.groups) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -544,7 +546,7 @@ impl<'df> GroupBy<'df> { let new_name = fmt_group_by_column(agg_col.name().as_str(), GroupByMethod::Last); let mut agg = unsafe { agg_col.agg_last(&self.groups) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -581,7 +583,7 @@ impl<'df> GroupBy<'df> { let new_name = fmt_group_by_column(agg_col.name().as_str(), GroupByMethod::NUnique); let mut agg = unsafe { agg_col.agg_n_unique(&self.groups) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -616,7 +618,7 @@ impl<'df> GroupBy<'df> { ); let mut agg = unsafe { agg_col.agg_quantile(&self.groups, quantile, interpol) }; agg.rename(new_name); - cols.push(agg.into()); + cols.push(agg); } DataFrame::new(cols) } @@ -1124,7 +1126,13 @@ mod test { .unwrap(); assert_eq!( - Vec::from(res.column("bar_sum").unwrap().as_materialized_series().i32().unwrap()), + Vec::from( + res.column("bar_sum") + .unwrap() + .as_materialized_series() + .i32() + .unwrap() + ), &[Some(2), Some(2), Some(1)] ); } diff --git a/crates/polars-core/src/frame/mod.rs b/crates/polars-core/src/frame/mod.rs index c245484089d47..0edbfa7a726ed 100644 --- a/crates/polars-core/src/frame/mod.rs +++ b/crates/polars-core/src/frame/mod.rs @@ -174,7 +174,7 @@ pub struct DataFrame { } impl DataFrame { - pub fn materialized_column_iter(&self) -> impl Iterator + ExactSizeIterator { + pub fn materialized_column_iter(&self) -> impl ExactSizeIterator { self.columns.iter().map(Column::as_materialized_series) } @@ -630,7 +630,7 @@ impl DataFrame { /// assert_eq!(iterator.next(), None); /// # Ok::<(), PolarsError>(()) /// ``` - pub fn iter(&self) -> impl Iterator + ExactSizeIterator { + pub fn iter(&self) -> impl ExactSizeIterator { self.materialized_column_iter() } @@ -2505,8 +2505,8 @@ impl DataFrame { self.columns[0].clone().as_materialized_series().clone(), )), 2 => min_fn( - &self.columns[0].as_materialized_series(), - &self.columns[1].as_materialized_series(), + self.columns[0].as_materialized_series(), + self.columns[1].as_materialized_series(), ) .map(Some), _ => { diff --git a/crates/polars-core/src/prelude.rs b/crates/polars-core/src/prelude.rs index 2d729261c287b..bd1ade2d9b908 100644 --- a/crates/polars-core/src/prelude.rs +++ b/crates/polars-core/src/prelude.rs @@ -40,13 +40,13 @@ pub use crate::datatypes::{ArrayCollectIterExt, *}; pub use crate::error::{ polars_bail, polars_ensure, polars_err, polars_warn, PolarsError, PolarsResult, }; +pub use crate::frame::column::{Column, IntoColumn}; pub use crate::frame::explode::UnpivotArgsIR; #[cfg(feature = "algorithm_group_by")] pub(crate) use crate::frame::group_by::aggregations::*; #[cfg(feature = "algorithm_group_by")] pub use crate::frame::group_by::*; pub use crate::frame::{DataFrame, UniqueKeepStrategy}; -pub use crate::frame::column::{Column, IntoColumn}; pub use crate::hashing::VecHash; pub use crate::named_from::{NamedFrom, NamedFromOwned}; pub use crate::scalar::Scalar; diff --git a/crates/polars-core/src/scalar/mod.rs b/crates/polars-core/src/scalar/mod.rs index d6ed0955e8cfc..5d428cb7fcbf4 100644 --- a/crates/polars-core/src/scalar/mod.rs +++ b/crates/polars-core/src/scalar/mod.rs @@ -3,7 +3,7 @@ pub mod reduce; use polars_utils::pl_str::PlSmallStr; use crate::datatypes::{AnyValue, DataType}; -use crate::prelude::{Column, Series, IntoColumn}; +use crate::prelude::{Column, IntoColumn, Series}; #[derive(Clone, Debug)] pub struct Scalar { diff --git a/crates/polars-core/src/serde/df.rs b/crates/polars-core/src/serde/df.rs index 677f455d552a6..52d6a0ee6eae4 100644 --- a/crates/polars-core/src/serde/df.rs +++ b/crates/polars-core/src/serde/df.rs @@ -2,7 +2,7 @@ use polars_error::PolarsError; use serde::de::Error; use serde::*; -use crate::prelude::{DataFrame, Column}; +use crate::prelude::{Column, DataFrame}; // utility to ensure we serde to a struct // { diff --git a/crates/polars-core/src/series/mod.rs b/crates/polars-core/src/series/mod.rs index e54f7fcc98d67..2a18d7c7a6e92 100644 --- a/crates/polars-core/src/series/mod.rs +++ b/crates/polars-core/src/series/mod.rs @@ -463,6 +463,7 @@ impl Series { /// Cast from physical to logical types without any checks on the validity of the cast. /// /// # Safety + /// /// This can lead to invalid memory access in downstream code. pub unsafe fn cast_unchecked(&self, dtype: &DataType) -> PolarsResult { match self.dtype() { diff --git a/crates/polars-core/src/series/series_trait.rs b/crates/polars-core/src/series/series_trait.rs index 4e90f9d757d92..2804c5ce1840c 100644 --- a/crates/polars-core/src/series/series_trait.rs +++ b/crates/polars-core/src/series/series_trait.rs @@ -105,10 +105,17 @@ pub(crate) mod private { ) -> PolarsResult<()> { polars_bail!(opq = vec_hash_combine, self._dtype()); } + + /// # Safety + /// + /// Does no bounds checks, groups must be correct. #[cfg(feature = "algorithm_group_by")] unsafe fn agg_min(&self, groups: &GroupsProxy) -> Series { Series::full_null(self._field().name().clone(), groups.len(), self._dtype()) } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. #[cfg(feature = "algorithm_group_by")] unsafe fn agg_max(&self, groups: &GroupsProxy) -> Series { Series::full_null(self._field().name().clone(), groups.len(), self._dtype()) @@ -119,14 +126,23 @@ pub(crate) mod private { unsafe fn agg_sum(&self, groups: &GroupsProxy) -> Series { Series::full_null(self._field().name().clone(), groups.len(), self._dtype()) } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. #[cfg(feature = "algorithm_group_by")] unsafe fn agg_std(&self, groups: &GroupsProxy, _ddof: u8) -> Series { Series::full_null(self._field().name().clone(), groups.len(), self._dtype()) } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. #[cfg(feature = "algorithm_group_by")] unsafe fn agg_var(&self, groups: &GroupsProxy, _ddof: u8) -> Series { Series::full_null(self._field().name().clone(), groups.len(), self._dtype()) } + /// # Safety + /// + /// Does no bounds checks, groups must be correct. #[cfg(feature = "algorithm_group_by")] unsafe fn agg_list(&self, groups: &GroupsProxy) -> Series { Series::full_null(self._field().name().clone(), groups.len(), self._dtype()) diff --git a/crates/polars-io/src/csv/read/read_impl.rs b/crates/polars-io/src/csv/read/read_impl.rs index c7d449b77ccbe..bfe4e45fd2865 100644 --- a/crates/polars-io/src/csv/read/read_impl.rs +++ b/crates/polars-io/src/csv/read/read_impl.rs @@ -64,7 +64,7 @@ pub(crate) fn cast_columns( (_, dt) => c.cast(dt), }?; if !ignore_errors && c.null_count() != out.null_count() { - handle_casting_failures(c.as_materialized_series(), &out.as_materialized_series())?; + handle_casting_failures(c.as_materialized_series(), out.as_materialized_series())?; } Ok(out) }; diff --git a/crates/polars-io/src/parquet/read/read_impl.rs b/crates/polars-io/src/parquet/read/read_impl.rs index 8c62fb3abd0ac..8b1f88cf1b0c9 100644 --- a/crates/polars-io/src/parquet/read/read_impl.rs +++ b/crates/polars-io/src/parquet/read/read_impl.rs @@ -553,7 +553,8 @@ fn rg_to_dfs_optionally_par_over_columns( Some(Filter::new_ranged(rg_slice.0, rg_slice.0 + rg_slice.1)), schema, store, - ).map(Column::from) + ) + .map(Column::from) }) .collect::>>() })? @@ -570,7 +571,8 @@ fn rg_to_dfs_optionally_par_over_columns( Some(Filter::new_ranged(rg_slice.0, rg_slice.0 + rg_slice.1)), schema, store, - ).map(Column::from) + ) + .map(Column::from) }) .collect::>>()? }; @@ -670,7 +672,8 @@ fn rg_to_dfs_par_over_rg( Some(Filter::new_ranged(slice.0, slice.0 + slice.1)), schema, store, - ).map(Column::from) + ) + .map(Column::from) }) .collect::>>()?; diff --git a/crates/polars-lazy/src/tests/arity.rs b/crates/polars-lazy/src/tests/arity.rs index 439d2a8be5873..740678af0af45 100644 --- a/crates/polars-lazy/src/tests/arity.rs +++ b/crates/polars-lazy/src/tests/arity.rs @@ -72,5 +72,12 @@ fn test_lazy_ternary() { ) .collect() .unwrap(); - assert_eq!(43, df.column("new").unwrap().as_materialized_series().sum::().unwrap()); + assert_eq!( + 43, + df.column("new") + .unwrap() + .as_materialized_series() + .sum::() + .unwrap() + ); } diff --git a/crates/polars-lazy/src/tests/queries.rs b/crates/polars-lazy/src/tests/queries.rs index 7cc575a215219..a0b74a3ff968e 100644 --- a/crates/polars-lazy/src/tests/queries.rs +++ b/crates/polars-lazy/src/tests/queries.rs @@ -232,7 +232,14 @@ fn test_lazy_binary_ops() { .select([col("a").eq(lit(2)).alias("foo")]) .collect() .unwrap(); - assert_eq!(new.column("foo").unwrap().as_materialized_series().sum::().unwrap(), 1); + assert_eq!( + new.column("foo") + .unwrap() + .as_materialized_series() + .sum::() + .unwrap(), + 1 + ); } #[test] @@ -501,7 +508,8 @@ fn test_lazy_query_7() { ]; let data = vec![Some(1.), Some(2.), Some(3.), Some(4.), None, None]; let df = DataFrame::new(vec![ - DatetimeChunked::from_naive_datetime("date".into(), dates, TimeUnit::Nanoseconds).into_column(), + DatetimeChunked::from_naive_datetime("date".into(), dates, TimeUnit::Nanoseconds) + .into_column(), Column::new("data".into(), data), ]) .unwrap(); @@ -516,7 +524,13 @@ fn test_lazy_query_7() { )))) .collect() .unwrap(); - let a = out.column("shifted").unwrap().as_materialized_series().sum::().unwrap() - 7.0; + let a = out + .column("shifted") + .unwrap() + .as_materialized_series() + .sum::() + .unwrap() + - 7.0; assert!(a < 0.01 && a > -0.01); } diff --git a/crates/polars-mem-engine/src/executors/stack.rs b/crates/polars-mem-engine/src/executors/stack.rs index 2b59fbc2535db..43c884b1f5633 100644 --- a/crates/polars-mem-engine/src/executors/stack.rs +++ b/crates/polars-mem-engine/src/executors/stack.rs @@ -64,7 +64,7 @@ impl StackExec { // new, unique column names. It is immediately // followed by a projection which pulls out the // possibly mismatching column lengths. - unsafe { df.get_columns_mut() } .extend(res.into_iter().map(Column::from)); + unsafe { df.get_columns_mut() }.extend(res.into_iter().map(Column::from)); } else { let height = df.height(); diff --git a/crates/polars-ops/src/chunked_array/top_k.rs b/crates/polars-ops/src/chunked_array/top_k.rs index c3bcd391e5afe..9caf861b6cd90 100644 --- a/crates/polars-ops/src/chunked_array/top_k.rs +++ b/crates/polars-ops/src/chunked_array/top_k.rs @@ -216,7 +216,7 @@ pub fn top_k(s: &[Column], descending: bool) -> PolarsResult { #[cfg(feature = "dtype-struct")] DataType::Struct(_) => { // Fallback to more generic impl. - top_k_by_impl(k, src, &[src.clone().into()], vec![descending]) + top_k_by_impl(k, src, &[src.clone()], vec![descending]) }, _dt => { macro_rules! dispatch { @@ -289,6 +289,9 @@ fn top_k_by_impl( let idx = _arg_bottom_k(k, by, &mut sort_options)?; - let result = unsafe { src.as_materialized_series().take_unchecked(&idx.into_inner()) }; + let result = unsafe { + src.as_materialized_series() + .take_unchecked(&idx.into_inner()) + }; Ok(result.into()) } diff --git a/crates/polars-ops/src/frame/join/mod.rs b/crates/polars-ops/src/frame/join/mod.rs index cbfcec5ea3f1e..81f4fe54e7e46 100644 --- a/crates/polars-ops/src/frame/join/mod.rs +++ b/crates/polars-ops/src/frame/join/mod.rs @@ -387,8 +387,8 @@ pub trait DataFrameJoinOps: IntoDf { #[cfg(feature = "semi_anti_join")] JoinType::Anti | JoinType::Semi => self._join_impl( other, - vec![lhs_keys.into()], - vec![rhs_keys.into()], + vec![lhs_keys], + vec![rhs_keys], args, _check_rechunk, _verbose, diff --git a/crates/polars-ops/src/frame/pivot/positioning.rs b/crates/polars-ops/src/frame/pivot/positioning.rs index 9bce6710a1db6..7b19872a1bc33 100644 --- a/crates/polars-ops/src/frame/pivot/positioning.rs +++ b/crates/polars-ops/src/frame/pivot/positioning.rs @@ -254,7 +254,6 @@ pub(super) fn compute_col_idx( let ca: &ChunkedArray = column_agg_physical .as_materialized_series() .as_ref() - .as_ref() .as_ref(); compute_col_idx_numeric(ca) }, @@ -262,7 +261,6 @@ pub(super) fn compute_col_idx( let ca: &ChunkedArray = column_agg_physical .as_materialized_series() .as_ref() - .as_ref() .as_ref(); compute_col_idx_numeric(ca) }, @@ -429,7 +427,6 @@ pub(super) fn compute_row_idx( let ca: &ChunkedArray = index_agg_physical .as_materialized_series() .as_ref() - .as_ref() .as_ref(); compute_row_index(index, ca, count, index_s.dtype()) }, @@ -437,7 +434,6 @@ pub(super) fn compute_row_idx( let ca: &ChunkedArray = index_agg_physical .as_materialized_series() .as_ref() - .as_ref() .as_ref(); compute_row_index(index, ca, count, index_s.dtype()) }, diff --git a/crates/polars-ops/src/series/ops/cut.rs b/crates/polars-ops/src/series/ops/cut.rs index 08d40e1877815..cba643cf98e92 100644 --- a/crates/polars-ops/src/series/ops/cut.rs +++ b/crates/polars-ops/src/series/ops/cut.rs @@ -2,12 +2,12 @@ use polars_core::prelude::*; use polars_utils::format_pl_smallstr; fn map_cats( - s: &Column, + s: &Series, labels: &[PlSmallStr], sorted_breaks: &[f64], left_closed: bool, include_breaks: bool, -) -> PolarsResult { +) -> PolarsResult { let out_name = PlSmallStr::from_static("category"); // Create new categorical and pre-register labels for consistent categorical indexes. @@ -58,12 +58,12 @@ fn map_cats( }); let outvals = vec![ - brk_vals.finish().into_column(), + brk_vals.finish().into_series(), bld.finish() ._with_fast_unique(label_has_value.iter().all(bool::clone)) - .into_column(), + .into_series(), ]; - Ok(StructChunked::from_columns(out_name, &outvals)?.into_column()) + Ok(StructChunked::from_series(out_name, &outvals)?.into_series()) } else { Ok(bld .drain_iter_and_finish(s_iter.map(|opt| { @@ -74,7 +74,7 @@ fn map_cats( }) })) ._with_fast_unique(label_has_value.iter().all(bool::clone)) - .into_column()) + .into_series()) } } @@ -96,12 +96,12 @@ pub fn compute_labels(breaks: &[f64], left_closed: bool) -> PolarsResult, labels: Option>, left_closed: bool, include_breaks: bool, -) -> PolarsResult { +) -> PolarsResult { // Breaks must be sorted to cut inputs properly. polars_ensure!(!breaks.iter().any(|x| x.is_nan()), ComputeError: "breaks cannot be NaN"); breaks.sort_unstable_by(|a, b| a.partial_cmp(b).unwrap()); @@ -122,13 +122,13 @@ pub fn cut( } pub fn qcut( - s: &Column, + s: &Series, probs: Vec, labels: Option>, left_closed: bool, allow_duplicates: bool, include_breaks: bool, -) -> PolarsResult { +) -> PolarsResult { polars_ensure!(!probs.iter().any(|x| x.is_nan()), ComputeError: "quantiles cannot be NaN"); if s.null_count() == s.len() { @@ -177,7 +177,7 @@ mod test { use super::map_cats; - let s = Column::new("x".into(), &[1, 2, 3, 4, 5]); + let s = Series::new("x".into(), &[1, 2, 3, 4, 5]); let labels = &["a", "b", "c"].map(PlSmallStr::from_static); let breaks = &[2.0, 4.0]; diff --git a/crates/polars-ops/src/series/ops/fused.rs b/crates/polars-ops/src/series/ops/fused.rs index a2b3215add95c..8132eda7c22ab 100644 --- a/crates/polars-ops/src/series/ops/fused.rs +++ b/crates/polars-ops/src/series/ops/fused.rs @@ -160,6 +160,7 @@ pub fn fms_columns(a: &Column, b: &Column, c: &Column) -> Column { } else { (&(a.as_materialized_series() * b.as_materialized_series()).unwrap() - c.as_materialized_series()) - .unwrap().into() + .unwrap() + .into() } } diff --git a/crates/polars-ops/src/series/ops/replace.rs b/crates/polars-ops/src/series/ops/replace.rs index 9dde258a86aad..f2d8f81287776 100644 --- a/crates/polars-ops/src/series/ops/replace.rs +++ b/crates/polars-ops/src/series/ops/replace.rs @@ -179,7 +179,10 @@ fn replace_by_multiple( }, )?; - let replaced = joined.column("__POLARS_REPLACE_NEW").unwrap().as_materialized_series(); + let replaced = joined + .column("__POLARS_REPLACE_NEW") + .unwrap() + .as_materialized_series(); if replaced.null_count() == 0 { return Ok(replaced.clone()); @@ -238,7 +241,7 @@ fn create_replacer(mut old: Series, mut new: Series, add_mask: bool) -> PolarsRe // @scalar-opt let mask = Column::new(PlSmallStr::from_static("__POLARS_REPLACE_MASK"), &[true]) .new_from_index(0, new.len()); - vec![old.into(), new.into(), mask.into()] + vec![old.into(), new.into(), mask] } else { vec![old.into(), new.into()] }; diff --git a/crates/polars-ops/src/series/ops/rle.rs b/crates/polars-ops/src/series/ops/rle.rs index 6df79825b7068..9277913558a21 100644 --- a/crates/polars-ops/src/series/ops/rle.rs +++ b/crates/polars-ops/src/series/ops/rle.rs @@ -4,7 +4,9 @@ use polars_core::series::IsSorted; /// Get the lengths of runs of identical values. pub fn rle(s: &Column) -> PolarsResult { let (s1, s2) = (s.slice(0, s.len() - 1), s.slice(1, s.len())); - let s_neq = s1.as_materialized_series().not_equal_missing(s2.as_materialized_series())?; + let s_neq = s1 + .as_materialized_series() + .not_equal_missing(s2.as_materialized_series())?; let n_runs = s_neq.sum().ok_or_else(|| polars_err!(InvalidOperation: "could not evaluate 'rle_id' on series of dtype: {}", s.dtype()))? + 1; let mut lengths = Vec::::with_capacity(n_runs as usize); @@ -34,11 +36,13 @@ pub fn rle(s: &Column) -> PolarsResult { /// Similar to `rle`, but maps values to run IDs. pub fn rle_id(s: &Column) -> PolarsResult { - if s.len() == 0 { + if s.is_empty() { return Ok(Column::new_empty(s.name().clone(), &IDX_DTYPE)); } let (s1, s2) = (s.slice(0, s.len() - 1), s.slice(1, s.len())); - let s_neq = s1.as_materialized_series().not_equal_missing(s2.as_materialized_series())?; + let s_neq = s1 + .as_materialized_series() + .not_equal_missing(s2.as_materialized_series())?; let mut out = Vec::::with_capacity(s.len()); let mut last = 0; diff --git a/crates/polars-pipe/src/executors/operators/projection.rs b/crates/polars-pipe/src/executors/operators/projection.rs index f948fbe2e4ef0..9ae6dbc5299d5 100644 --- a/crates/polars-pipe/src/executors/operators/projection.rs +++ b/crates/polars-pipe/src/executors/operators/projection.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use polars_core::error::PolarsResult; +use polars_core::frame::column::{Column, IntoColumn}; use polars_core::frame::DataFrame; use polars_core::schema::SchemaRef; -use polars_core::frame::column::{Column, IntoColumn}; use polars_plan::prelude::ProjectionOptions; use polars_utils::pl_str::PlSmallStr; @@ -118,7 +118,10 @@ impl Operator for HstackOperator { let projected = self .exprs .iter() - .map(|e| e.evaluate(chunk, &context.execution_state).map(Column::from)) + .map(|e| { + e.evaluate(chunk, &context.execution_state) + .map(Column::from) + }) .collect::>>()?; let columns = chunk.data.get_columns()[..width].to_vec(); diff --git a/crates/polars-pipe/src/executors/sinks/group_by/string.rs b/crates/polars-pipe/src/executors/sinks/group_by/string.rs index f16ca2e17bc36..d2fec9c16173a 100644 --- a/crates/polars-pipe/src/executors/sinks/group_by/string.rs +++ b/crates/polars-pipe/src/executors/sinks/group_by/string.rs @@ -210,7 +210,11 @@ impl StringGroupbySink { let mut cols = Vec::with_capacity(1 + self.number_of_aggs()); cols.push(key_builder.finish().into_series().into_column()); - cols.extend(buffers.into_iter().map(|buf| buf.into_series().into_column())); + cols.extend( + buffers + .into_iter() + .map(|buf| buf.into_series().into_column()), + ); physical_agg_to_logical(&mut cols, &self.output_schema); Some(unsafe { DataFrame::new_no_checks(cols) }) }) diff --git a/crates/polars-plan/src/dsl/function_expr/array.rs b/crates/polars-plan/src/dsl/function_expr/array.rs index d1c92cba1df26..dce6d44bce948 100644 --- a/crates/polars-plan/src/dsl/function_expr/array.rs +++ b/crates/polars-plan/src/dsl/function_expr/array.rs @@ -221,9 +221,12 @@ pub(super) fn contains(s: &[Column]) -> PolarsResult { polars_ensure!(matches!(array.dtype(), DataType::Array(_, _)), SchemaMismatch: "invalid series dtype: expected `Array`, got `{}`", array.dtype(), ); - Ok(is_in(item.as_materialized_series(), array.as_materialized_series())? - .with_name(array.name().clone()) - .into_column()) + Ok(is_in( + item.as_materialized_series(), + array.as_materialized_series(), + )? + .with_name(array.name().clone()) + .into_column()) } #[cfg(feature = "array_count")] @@ -236,7 +239,8 @@ pub(super) fn count_matches(args: &[Column]) -> PolarsResult { element.len() ); let ca = s.array()?; - ca.array_count_matches(element.get(0).unwrap()).map(Column::from) + ca.array_count_matches(element.get(0).unwrap()) + .map(Column::from) } pub(super) fn shift(s: &[Column]) -> PolarsResult { diff --git a/crates/polars-plan/src/dsl/function_expr/clip.rs b/crates/polars-plan/src/dsl/function_expr/clip.rs index 4b537c8112350..9a721d65d1985 100644 --- a/crates/polars-plan/src/dsl/function_expr/clip.rs +++ b/crates/polars-plan/src/dsl/function_expr/clip.rs @@ -3,17 +3,17 @@ use super::*; pub(super) fn clip(s: &[Column], has_min: bool, has_max: bool) -> PolarsResult { match (has_min, has_max) { (true, true) => polars_ops::series::clip( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), - &s[2].as_materialized_series(), + s[0].as_materialized_series(), + s[1].as_materialized_series(), + s[2].as_materialized_series(), ), (true, false) => polars_ops::series::clip_min( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), + s[0].as_materialized_series(), + s[1].as_materialized_series(), ), (false, true) => polars_ops::series::clip_max( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), + s[0].as_materialized_series(), + s[1].as_materialized_series(), ), _ => unreachable!(), } diff --git a/crates/polars-plan/src/dsl/function_expr/correlation.rs b/crates/polars-plan/src/dsl/function_expr/correlation.rs index 14b3f0f77a4c3..0413bac9dc01e 100644 --- a/crates/polars-plan/src/dsl/function_expr/correlation.rs +++ b/crates/polars-plan/src/dsl/function_expr/correlation.rs @@ -113,20 +113,26 @@ fn spearman_rank_corr(s: &[Column], ddof: u8, propagate_nans: bool) -> PolarsRes let a = a.drop_nulls(); let b = b.drop_nulls(); - let a_rank = a.as_materialized_series().rank( - RankOptions { - method: RankMethod::Average, - ..Default::default() - }, - None, - ).into(); - let b_rank = b.as_materialized_series().rank( - RankOptions { - method: RankMethod::Average, - ..Default::default() - }, - None, - ).into(); + let a_rank = a + .as_materialized_series() + .rank( + RankOptions { + method: RankMethod::Average, + ..Default::default() + }, + None, + ) + .into(); + let b_rank = b + .as_materialized_series() + .rank( + RankOptions { + method: RankMethod::Average, + ..Default::default() + }, + None, + ) + .into(); pearson_corr(&[a_rank, b_rank], ddof) } diff --git a/crates/polars-plan/src/dsl/function_expr/datetime.rs b/crates/polars-plan/src/dsl/function_expr/datetime.rs index 9dbde708e7bf2..436e1718d5e34 100644 --- a/crates/polars-plan/src/dsl/function_expr/datetime.rs +++ b/crates/polars-plan/src/dsl/function_expr/datetime.rs @@ -465,10 +465,7 @@ pub(super) fn truncate(s: &[Column]) -> PolarsResult { #[cfg(feature = "offset_by")] pub(super) fn offset_by(s: &[Column]) -> PolarsResult { - impl_offset_by( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), - ).map(Column::from) + impl_offset_by(s[0].as_materialized_series(), s[1].as_materialized_series()).map(Column::from) } #[cfg(feature = "month_start")] diff --git a/crates/polars-plan/src/dsl/function_expr/dispatch.rs b/crates/polars-plan/src/dsl/function_expr/dispatch.rs index fb73f51ab5de1..6ee70819b4f78 100644 --- a/crates/polars-plan/src/dsl/function_expr/dispatch.rs +++ b/crates/polars-plan/src/dsl/function_expr/dispatch.rs @@ -16,11 +16,8 @@ pub(super) fn diff(s: &Column, n: i64, null_behavior: NullBehavior) -> PolarsRes #[cfg(feature = "pct_change")] pub(super) fn pct_change(s: &[Column]) -> PolarsResult { - polars_ops::prelude::pct_change( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), - ) - .map(Column::from) + polars_ops::prelude::pct_change(s[0].as_materialized_series(), s[1].as_materialized_series()) + .map(Column::from) } #[cfg(feature = "interpolate")] @@ -175,9 +172,9 @@ pub(super) fn hist( #[cfg(feature = "replace")] pub(super) fn replace(s: &[Column]) -> PolarsResult { polars_ops::series::replace( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), - &s[2].as_materialized_series(), + s[0].as_materialized_series(), + s[1].as_materialized_series(), + s[2].as_materialized_series(), ) .map(Column::from) } @@ -186,16 +183,16 @@ pub(super) fn replace(s: &[Column]) -> PolarsResult { pub(super) fn replace_strict(s: &[Column], return_dtype: Option) -> PolarsResult { match s.get(3) { Some(default) => polars_ops::series::replace_or_default( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), - &s[2].as_materialized_series(), + s[0].as_materialized_series(), + s[1].as_materialized_series(), + s[2].as_materialized_series(), default.as_materialized_series(), return_dtype, ), None => polars_ops::series::replace_strict( - &s[0].as_materialized_series(), - &s[1].as_materialized_series(), - &s[2].as_materialized_series(), + s[0].as_materialized_series(), + s[1].as_materialized_series(), + s[2].as_materialized_series(), return_dtype, ), } diff --git a/crates/polars-plan/src/dsl/function_expr/list.rs b/crates/polars-plan/src/dsl/function_expr/list.rs index c2badaecea8d2..35467eff92bc2 100644 --- a/crates/polars-plan/src/dsl/function_expr/list.rs +++ b/crates/polars-plan/src/dsl/function_expr/list.rs @@ -508,7 +508,8 @@ pub(super) fn gather(args: &[Column], null_on_oob: bool) -> PolarsResult // make sure we return a list out.reshape_list(&[-1, 1]) } else { - ca.lst_gather(idx.as_materialized_series(), null_on_oob).map(Column::from) + ca.lst_gather(idx.as_materialized_series(), null_on_oob) + .map(Column::from) } } @@ -518,7 +519,9 @@ pub(super) fn gather_every(args: &[Column]) -> PolarsResult { let n = &args[1].strict_cast(&IDX_DTYPE)?; let offset = &args[2].strict_cast(&IDX_DTYPE)?; - ca.list()?.lst_gather_every(n.idx()?, offset.idx()?).map(Column::from) + ca.list()? + .lst_gather_every(n.idx()?, offset.idx()?) + .map(Column::from) } #[cfg(feature = "list_count")] @@ -600,10 +603,10 @@ pub(super) fn set_operation(s: &[Column], set_type: SetOperation) -> PolarsResul let s0 = &s[0]; let s1 = &s[1]; - if s0.len() == 0 || s1.len() == 0 { + if s0.is_empty() || s1.is_empty() { return match set_type { SetOperation::Intersection => { - if s0.len() == 0 { + if s0.is_empty() { Ok(s0.clone()) } else { Ok(s1.clone().with_name(s0.name().clone())) @@ -611,7 +614,7 @@ pub(super) fn set_operation(s: &[Column], set_type: SetOperation) -> PolarsResul }, SetOperation::Difference => Ok(s0.clone()), SetOperation::Union | SetOperation::SymmetricDifference => { - if s0.len() == 0 { + if s0.is_empty() { Ok(s1.clone().with_name(s0.name().clone())) } else { Ok(s0.clone()) diff --git a/crates/polars-plan/src/dsl/function_expr/mod.rs b/crates/polars-plan/src/dsl/function_expr/mod.rs index 0f66344a2cbac..0f29723eee4e8 100644 --- a/crates/polars-plan/src/dsl/function_expr/mod.rs +++ b/crates/polars-plan/src/dsl/function_expr/mod.rs @@ -20,6 +20,7 @@ mod concat; mod correlation; #[cfg(feature = "cum_agg")] mod cum; +mod cut; #[cfg(feature = "temporal")] mod datetime; mod dispatch; @@ -1074,7 +1075,7 @@ impl From for SpecialEq> { left_closed, include_breaks, } => map!( - cut, + cut::cut, breaks.clone(), labels.clone(), left_closed, @@ -1088,7 +1089,7 @@ impl From for SpecialEq> { allow_duplicates, include_breaks, } => map!( - qcut, + cut::qcut, probs.clone(), labels.clone(), left_closed, diff --git a/crates/polars-plan/src/dsl/function_expr/rolling_by.rs b/crates/polars-plan/src/dsl/function_expr/rolling_by.rs index dfc6e34e8c5a1..3077c83355f29 100644 --- a/crates/polars-plan/src/dsl/function_expr/rolling_by.rs +++ b/crates/polars-plan/src/dsl/function_expr/rolling_by.rs @@ -44,7 +44,7 @@ pub(super) fn rolling_min_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_min_by(&s[1].as_materialized_series(), options) + .rolling_min_by(s[1].as_materialized_series(), options) .map(Column::from) } @@ -54,7 +54,7 @@ pub(super) fn rolling_max_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_max_by(&s[1].as_materialized_series(), options) + .rolling_max_by(s[1].as_materialized_series(), options) .map(Column::from) } @@ -64,7 +64,7 @@ pub(super) fn rolling_mean_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_mean_by(&s[1].as_materialized_series(), options) + .rolling_mean_by(s[1].as_materialized_series(), options) .map(Column::from) } @@ -74,7 +74,7 @@ pub(super) fn rolling_sum_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_sum_by(&s[1].as_materialized_series(), options) + .rolling_sum_by(s[1].as_materialized_series(), options) .map(Column::from) } @@ -84,7 +84,7 @@ pub(super) fn rolling_quantile_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_quantile_by(&s[1].as_materialized_series(), options) + .rolling_quantile_by(s[1].as_materialized_series(), options) .map(Column::from) } @@ -94,7 +94,7 @@ pub(super) fn rolling_var_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_var_by(&s[1].as_materialized_series(), options) + .rolling_var_by(s[1].as_materialized_series(), options) .map(Column::from) } @@ -104,6 +104,6 @@ pub(super) fn rolling_std_by( ) -> PolarsResult { // @scalar-opt s[0].as_materialized_series() - .rolling_std_by(&s[1].as_materialized_series(), options) + .rolling_std_by(s[1].as_materialized_series(), options) .map(Column::from) } diff --git a/crates/polars-plan/src/dsl/function_expr/shrink_type.rs b/crates/polars-plan/src/dsl/function_expr/shrink_type.rs index 8489adda82a85..99dbb97cc67cb 100644 --- a/crates/polars-plan/src/dsl/function_expr/shrink_type.rs +++ b/crates/polars-plan/src/dsl/function_expr/shrink_type.rs @@ -37,5 +37,6 @@ pub(super) fn shrink(s: Column) -> PolarsResult { } else { Ok(s.clone()) } - }.map(Column::from) + } + .map(Column::from) } diff --git a/crates/polars-plan/src/dsl/function_expr/strings.rs b/crates/polars-plan/src/dsl/function_expr/strings.rs index d3743463d3088..ba06dc00e67c1 100644 --- a/crates/polars-plan/src/dsl/function_expr/strings.rs +++ b/crates/polars-plan/src/dsl/function_expr/strings.rs @@ -672,7 +672,7 @@ fn to_date(s: &Column, options: &StrptimeOptions) -> PolarsResult { }; if options.strict && ca.null_count() != out.null_count() { - handle_casting_failures(s.as_materialized_series(), &out.as_materialized_series())?; + handle_casting_failures(s.as_materialized_series(), out.as_materialized_series())?; } Ok(out.into_column()) } @@ -719,7 +719,7 @@ fn to_datetime( }; if options.strict && datetime_strings.null_count() != out.null_count() { - handle_casting_failures(&s[0].as_materialized_series(), &out.as_materialized_series())?; + handle_casting_failures(s[0].as_materialized_series(), out.as_materialized_series())?; } Ok(out.into_column()) } @@ -736,7 +736,7 @@ fn to_time(s: &Column, options: &StrptimeOptions) -> PolarsResult { .into_column(); if options.strict && ca.null_count() != out.null_count() { - handle_casting_failures(s.as_materialized_series(), &out.as_materialized_series())?; + handle_casting_failures(s.as_materialized_series(), out.as_materialized_series())?; } Ok(out.into_column()) } diff --git a/crates/polars-plan/src/dsl/function_expr/trigonometry.rs b/crates/polars-plan/src/dsl/function_expr/trigonometry.rs index 0e7080b0461b5..c0d83822aef96 100644 --- a/crates/polars-plan/src/dsl/function_expr/trigonometry.rs +++ b/crates/polars-plan/src/dsl/function_expr/trigonometry.rs @@ -113,7 +113,9 @@ where { let dtype = T::get_dtype(); let x = x.cast(&dtype)?; - let x = y.unpack_series_matching_type(x.as_materialized_series()).unwrap(); + let x = y + .unpack_series_matching_type(x.as_materialized_series()) + .unwrap(); if x.len() == 1 { let x_value = x diff --git a/crates/polars-plan/src/dsl/mod.rs b/crates/polars-plan/src/dsl/mod.rs index a2cf069e1db3f..786867f32e149 100644 --- a/crates/polars-plan/src/dsl/mod.rs +++ b/crates/polars-plan/src/dsl/mod.rs @@ -1512,7 +1512,7 @@ impl Expr { if let DataType::Float32 = c.dtype() { out.cast(&DataType::Float32).map(Column::from).map(Some) } else { - Ok(Some(out.into())) + Ok(Some(out)) } }, GetOutput::map_field(|field| { diff --git a/crates/polars-plan/src/dsl/python_udf.rs b/crates/polars-plan/src/dsl/python_udf.rs index 0fb786db493d8..0f9ac4a3dc9ab 100644 --- a/crates/polars-plan/src/dsl/python_udf.rs +++ b/crates/polars-plan/src/dsl/python_udf.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use polars_core::datatypes::{DataType, Field}; use polars_core::error::*; -use polars_core::frame::DataFrame; use polars_core::frame::column::Column; +use polars_core::frame::DataFrame; use polars_core::schema::Schema; use pyo3::prelude::*; use pyo3::pybacked::PyBackedBytes; diff --git a/crates/polars-plan/src/dsl/udf.rs b/crates/polars-plan/src/dsl/udf.rs index 74371639a54a1..b09ef6f556a2d 100644 --- a/crates/polars-plan/src/dsl/udf.rs +++ b/crates/polars-plan/src/dsl/udf.rs @@ -5,7 +5,7 @@ use polars_core::prelude::Field; use polars_core::schema::Schema; use polars_utils::pl_str::PlSmallStr; -use super::{Expr, GetOutput, ColumnsUdf, SpecialEq}; +use super::{ColumnsUdf, Expr, GetOutput, SpecialEq}; use crate::prelude::{Context, FunctionOptions}; /// Represents a user-defined function diff --git a/crates/polars-python/src/interop/numpy/to_numpy_df.rs b/crates/polars-python/src/interop/numpy/to_numpy_df.rs index b249970c438de..c14753bdc7a3a 100644 --- a/crates/polars-python/src/interop/numpy/to_numpy_df.rs +++ b/crates/polars-python/src/interop/numpy/to_numpy_df.rs @@ -113,7 +113,10 @@ fn check_df_dtypes_support_view(df: &DataFrame) -> Option<&DataType> { fn check_df_columns_contiguous(df: &DataFrame) -> bool { let columns = df.get_columns(); - if columns.iter().any(|s| s.as_materialized_series().n_chunks() > 1) { + if columns + .iter() + .any(|s| s.as_materialized_series().n_chunks() > 1) + { return false; } if columns.len() <= 1 { @@ -174,7 +177,13 @@ where T: PolarsNumericType, T::Native: Element, { - let ca: &ChunkedArray = df.get_columns().first().unwrap().as_materialized_series().unpack().unwrap(); + let ca: &ChunkedArray = df + .get_columns() + .first() + .unwrap() + .as_materialized_series() + .unpack() + .unwrap(); let first_slice = ca.data_views().next().unwrap(); let start_ptr = first_slice.as_ptr(); diff --git a/crates/polars-time/src/group_by/dynamic.rs b/crates/polars-time/src/group_by/dynamic.rs index 480c678e920ca..8a8d2312d5800 100644 --- a/crates/polars-time/src/group_by/dynamic.rs +++ b/crates/polars-time/src/group_by/dynamic.rs @@ -787,7 +787,10 @@ mod test { let expected = Series::new("".into(), [0.0, 8.0, 8.0, 9.333333333333343, 24.5, 0.0]); assert!(abs(&(var - expected)?).unwrap().lt(1e-12).unwrap().all()); - let quantile = unsafe { a.as_materialized_series().agg_quantile(&groups, 0.5, QuantileInterpolOptions::Linear) }; + let quantile = unsafe { + a.as_materialized_series() + .agg_quantile(&groups, 0.5, QuantileInterpolOptions::Linear) + }; let expected = Series::new("".into(), [3.0, 5.0, 5.0, 6.0, 5.5, 1.0]); assert_eq!(quantile, expected); diff --git a/crates/polars/tests/it/core/joins.rs b/crates/polars/tests/it/core/joins.rs index 9388a94d5960d..92f3d883f9dcd 100644 --- a/crates/polars/tests/it/core/joins.rs +++ b/crates/polars/tests/it/core/joins.rs @@ -137,7 +137,14 @@ fn test_full_outer_join() -> PolarsResult<()> { JoinArgs::new(JoinType::Full).with_coalesce(JoinCoalesce::CoalesceColumns), )?; assert_eq!(joined.height(), 5); - assert_eq!(joined.column("days")?.as_materialized_series().sum::().unwrap(), 7); + assert_eq!( + joined + .column("days")? + .as_materialized_series() + .sum::() + .unwrap(), + 7 + ); let df_left = df!( "a"=> ["a", "b", "a", "z"], diff --git a/crates/polars/tests/it/io/csv.rs b/crates/polars/tests/it/io/csv.rs index ccab0cec3d1e4..894aeb6bd3bcd 100644 --- a/crates/polars/tests/it/io/csv.rs +++ b/crates/polars/tests/it/io/csv.rs @@ -221,7 +221,14 @@ fn test_parser() -> PolarsResult<()> { assert_eq!(col.get(2)?, AnyValue::String("Setosa")); assert_eq!("sepal_length", df.get_columns()[0].name().as_str()); - assert_eq!(1, df.column("sepal_length").unwrap().as_materialized_series().chunks().len()); + assert_eq!( + 1, + df.column("sepal_length") + .unwrap() + .as_materialized_series() + .chunks() + .len() + ); assert_eq!(df.height(), 7); // test windows line endings diff --git a/docs/src/rust/user-guide/expressions/lists.rs b/docs/src/rust/user-guide/expressions/lists.rs index 9ce160cd58aae..fd097d98df7e0 100644 --- a/docs/src/rust/user-guide/expressions/lists.rs +++ b/docs/src/rust/user-guide/expressions/lists.rs @@ -142,8 +142,8 @@ fn main() -> Result<(), Box> { col2.append_slice(&[1, 7, 3]); col2.append_slice(&[8, 1, 0]); let array_df = DataFrame::new(vec![ - col1.finish().into_series(), - col2.finish().into_series(), + col1.finish().into_column(), + col2.finish().into_column(), ])?; println!("{}", &array_df);