Skip to content

Commit e7b8330

Browse files
committed
fix deprecation of Expr.shrink_dtype
1 parent b0dc51d commit e7b8330

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

ovrlpy/_subslicing.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ def _assign_xy(
4242
elif df.select(pl.col(xy_columns).min() < 0).to_numpy().any():
4343
raise ValueError("shift=False is only possible if coordinates are > 0")
4444

45-
lf = lf.with_columns(pl.col(xy_columns) / gridsize).with_columns(
46-
pl.col(xy_columns[0]).cast(Int32).shrink_dtype().alias("x_pixel"),
47-
pl.col(xy_columns[1]).cast(Int32).shrink_dtype().alias("y_pixel"),
45+
df = (
46+
lf.with_columns(pl.col(xy_columns) / gridsize)
47+
.with_columns(
48+
pl.col(xy_columns[0]).cast(Int32).alias("x_pixel"),
49+
pl.col(xy_columns[1]).cast(Int32).alias("y_pixel"),
50+
)
51+
.collect(engine="streaming") # reduce memory usage by using streaming
4852
)
53+
df = df.with_columns(df[xy].shrink_dtype() for xy in xy_columns)
4954

50-
return (
51-
lf.collect(engine="streaming"), # reduce memory usage by using streaming
52-
min_coord,
53-
)
55+
return df, min_coord
5456

5557

5658
Shape = TypeVar("Shape", bound=tuple[int, ...])

0 commit comments

Comments
 (0)