Skip to content

Commit

Permalink
MNT remove old fix for polars version 0.20 part 2 (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr authored Nov 4, 2024
1 parent bad03eb commit 54dac93
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/model_diagnostics/calibration/identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,30 +737,20 @@ def compute_marginal(
)
.sort("__priority", descending=True)
.head(n_bins)
)
# FIXME: When n_bins=0, the result 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(
[
.sort(feature_name, descending=False)
.select(
pl.col(feature_name),
pl.col("y_obs_mean"),
pl.col("y_pred_mean"),
pl.col("y_obs_stderr"),
pl.col("y_pred_stderr"),
pl.col("weights_sum").alias("weights"),
pl.col("count"),
]
+ (
[]
if is_cat_or_string
else [pl.col("bin_edges"), pl.col("__feature_std")]
*(
[]
if is_cat_or_string
else [pl.col("bin_edges"), pl.col("__feature_std")]
),
)
).collect()

Expand Down

0 comments on commit 54dac93

Please sign in to comment.