Skip to content

Commit

Permalink
remove resize constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite committed Sep 13, 2024
1 parent 834ec50 commit 8198662
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions crates/polars-core/src/frame/column/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Self> {
Expand Down

0 comments on commit 8198662

Please sign in to comment.