Skip to content

Commit

Permalink
FIX polars 0.20.20 lazy neglects head(0) (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr authored Apr 19, 2024
1 parent 615b131 commit edab8b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/model_diagnostics/calibration/identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,15 @@ def compute_bias(
)
.sort("__priority", descending=True)
.head(n_bins)
.sort(feature_name, descending=False)
)
# FIXME: When n_bins=0, the resut should be an empty dataframe
# (0 rows and some columns). For some unknown reason as of
# polars 0.20.20, the following sort neglects the head(0) statement.
# Therefore, we place an explicit collect here. This should not be
# needed!
if n_bins == 0 or feature.null_count() >= 1:
df = df.collect().lazy()
df = df.sort(feature_name, descending=False)

df = df.select(
[
Expand Down

0 comments on commit edab8b5

Please sign in to comment.