From 5984ff81f30c12b7e36f82322956995e25320c30 Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Thu, 12 Sep 2024 08:49:14 +0100 Subject: [PATCH] Fix for polars 1.7.0 by disabling projection_pushdown (#237) --- artistools/lightcurve/plotlightcurve.py | 2 ++ artistools/misc.py | 2 +- artistools/plotspherical.py | 2 +- artistools/spectra/spectra.py | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/artistools/lightcurve/plotlightcurve.py b/artistools/lightcurve/plotlightcurve.py index d8bc37ce0..bb1814cdb 100644 --- a/artistools/lightcurve/plotlightcurve.py +++ b/artistools/lightcurve/plotlightcurve.py @@ -1620,7 +1620,9 @@ def main(args: argparse.Namespace | None = None, argsraw: Sequence[str] | None = if not isinstance(args.modelpath, Iterable): args.modelpath = [args.modelpath] + assert isinstance(args.modelpath, list) args.modelpath = at.flatten_list(args.modelpath) + # flatten the list modelpaths = [] for elem in args.modelpath: diff --git a/artistools/misc.py b/artistools/misc.py index e2bcc309d..7d9c32904 100644 --- a/artistools/misc.py +++ b/artistools/misc.py @@ -1137,7 +1137,7 @@ def get_linelist_pldf(modelpath: Path | str, get_ion_str: bool = False) -> pl.La .with_columns(pl.col(pl.Int64).cast(pl.Int32)) ) - if "ionstage" in linelist_lazy.columns: + if "ionstage" in linelist_lazy.collect_schema().names(): linelist_lazy = linelist_lazy.rename({"ionstage": "ion_stage"}) if get_ion_str: diff --git a/artistools/plotspherical.py b/artistools/plotspherical.py index f17aca61f..78da521a5 100755 --- a/artistools/plotspherical.py +++ b/artistools/plotspherical.py @@ -174,7 +174,7 @@ def plot_spherical( .join(dfpackets, how="left", on=["costhetabin", "phibin"], coalesce=True) .fill_null(0) .sort(["costhetabin", "phibin"]) - ).collect() + ).collect(projection_pushdown=False) # projection_pushdown broke in polars 1.17.0 print(f'packets plotted: {alldirbins.select("count").sum().item(0, 0):.1e}') diff --git a/artistools/spectra/spectra.py b/artistools/spectra/spectra.py index 69bb14dce..e8b74027e 100644 --- a/artistools/spectra/spectra.py +++ b/artistools/spectra/spectra.py @@ -306,7 +306,7 @@ def get_from_packets( print("Applying filter to ARTIS spectrum") dfbinned_lazy = dfbinned_lazy.with_columns(cs.starts_with("f_lambda_").map_batches(fluxfilterfunc)) - dfbinned = dfbinned_lazy.collect() + dfbinned = dfbinned_lazy.collect(projection_pushdown=False) # projection_pushdown broke in polars 1.17.0 assert isinstance(dfbinned, pl.DataFrame) dfdict = {} @@ -979,7 +979,7 @@ def get_flux_contributions_from_packets( if directionbin != -1: cols |= {"costhetabin", "phibin", "dirbin"} - dfpackets = lzdfpackets.select([col for col in cols if col in lzdfpackets.columns]).collect() + dfpackets = lzdfpackets.select([col for col in cols if col in lzdfpackets.collect_schema().names()]).collect() emissiongroups = ( {