Skip to content

Commit

Permalink
Del objects to reduce memory pressure
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Dec 15, 2024
1 parent eb2d4e3 commit cbbe262
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions hstrat/dataframe/_surface_unpack_reconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def surface_unpack_reconstruct(df: pl.DataFrame) -> pl.DataFrame:
tqdm.tqdm,
)

logging.info("finalizing tree...")
bitwidth = _get_sole_bitwidth(long_df)
del long_df

logging.info("finalizing phylogeny dataframe...")

phylo_df = pl.from_dict(
records, # type: ignore
Expand All @@ -134,8 +137,12 @@ def surface_unpack_reconstruct(df: pl.DataFrame) -> pl.DataFrame:
"rank": pl.UInt64,
},
)
del records
phylo_df = phylo_df.with_columns(
pl.lit(bitwidth).alias("differentia_bitwidth").cast(pl.UInt32),
)

logging.info("joining frames...")
logging.info("joining user-defined columns...")
df = df.select(
pl.exclude("^dstream_.*$", "^downstream_.*$"),
pl.col("dstream_data_id").cast(pl.UInt64),
Expand All @@ -148,12 +155,6 @@ def surface_unpack_reconstruct(df: pl.DataFrame) -> pl.DataFrame:
else:
logging.info(" - no columns to join, skipping")

logging.info("adding differentia_bitwidth column...")
bitwidth = _get_sole_bitwidth(long_df)
phylo_df = phylo_df.with_columns(
pl.lit(bitwidth).alias("differentia_bitwidth").cast(pl.UInt32),
)

logging.info("surface_unpack_reconstruct complete")
render_polars_snapshot(phylo_df, "reconstruction", logging.info)

Expand Down

0 comments on commit cbbe262

Please sign in to comment.