Skip to content

Commit

Permalink
Fix references to old method
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed May 21, 2024
1 parent adae1c6 commit 2089737
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ impl DataFrame {
series = series.new_from_index(0, height);
}

if series.len() == height || df.is_empty() {
if series.len() == height || df.get_columns().is_empty() {
df.add_column_by_search(series)?;
Ok(df)
}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ impl DataFrame {
series = series.new_from_index(0, height);
}

if series.len() == height || self.is_empty() {
if series.len() == height || self.columns.is_empty() {
self.add_column_by_schema(series, schema)?;
Ok(self)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-io/src/predicates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn apply_predicate(
predicate: Option<&dyn PhysicalIoExpr>,
parallel: bool,
) -> PolarsResult<()> {
if let (Some(predicate), false) = (&predicate, df.is_empty()) {
if let (Some(predicate), false) = (&predicate, df.get_columns().is_empty()) {
let s = predicate.evaluate_io(df)?;
let mask = s.bool().expect("filter predicates was not of type boolean");

Expand Down
9 changes: 2 additions & 7 deletions py-polars/src/interop/numpy/to_numpy_df.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ fn df_to_numpy(
writable: bool,
allow_copy: bool,
) -> PyResult<PyObject> {
// TODO: Use `is_empty` when fixed:
// https://github.com/pola-rs/polars/pull/16351
if df.height() == 0 {
if df.is_empty() {
// Take this path to ensure a writable array.
// This does not actually copy data for an empty DataFrame.
return df_to_numpy_with_copy(py, df, order, true);
Expand Down Expand Up @@ -76,10 +74,7 @@ fn df_to_numpy(
}

fn try_df_to_numpy_view(py: Python, df: &DataFrame) -> Option<PyObject> {
if df.is_empty() {
return None;
}
let first = df.get_columns().first().unwrap().dtype();
let first = df.get_columns().first()?.dtype();
// TODO: Support Datetime/Duration/Array types
if !first.is_numeric() {
return None;
Expand Down

0 comments on commit 2089737

Please sign in to comment.