File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
5658Shape = TypeVar ("Shape" , bound = tuple [int , ...])
You can’t perform that action at this time.
0 commit comments