From 81986620a0a61260eebb5aa98208b8b96b469bc2 Mon Sep 17 00:00:00 2001 From: coastalwhite Date: Fri, 13 Sep 2024 17:46:05 +0200 Subject: [PATCH] remove resize constraint --- crates/polars-core/src/frame/column/mod.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/polars-core/src/frame/column/mod.rs b/crates/polars-core/src/frame/column/mod.rs index 4acf57f4b2d6..2296b09a4a03 100644 --- a/crates/polars-core/src/frame/column/mod.rs +++ b/crates/polars-core/src/frame/column/mod.rs @@ -1113,14 +1113,8 @@ impl ScalarColumn { /// Resize the [`ScalarColumn`] to new `length`. /// /// This reuses the materialized [`Series`], if `length <= self.length`. - /// - /// # Panics - /// - /// This panics if `self.length == 0`. pub fn resize(&self, length: usize) -> ScalarColumn { - assert_ne!(self.length, 0); - - let mut sliced = Self { + let mut resized = Self { name: self.name.clone(), scalar: self.scalar.clone(), length, @@ -1129,12 +1123,12 @@ impl ScalarColumn { if self.length >= length { if let Some(materialized) = self.materialized.get() { - sliced.materialized = OnceLock::from(materialized.head(Some(length))); - debug_assert_eq!(sliced.materialized.get().unwrap().len(), length); + resized.materialized = OnceLock::from(materialized.head(Some(length))); + debug_assert_eq!(resized.materialized.get().unwrap().len(), length); } } - sliced + resized } pub fn cast_with_options(&self, dtype: &DataType, options: CastOptions) -> PolarsResult {