Skip to content

Commit

Permalink
force compute before adding to agg dataframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ks905383 committed Feb 20, 2025
1 parent 04bb543 commit c6bbd0f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xagg/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ def aggregate(ds,wm,impl=None,silent=None):
output_dtypes = [float]).to_dataset(name=var)
for var in ds if (('bnds' not in ds[var].sizes) and ('loc' in ds[var].sizes))])

# Trigger computation, otherwise it separately triggers computation
# for every poly_idx below, with tremendous overhead
agg = agg.compute()

# Put in `aggregated` format (TODO: should reform this to remove some of the
# nested lists that are here for some reason)
wm.agg[var] = [[[agg[var].sel(poly_idx = idx).values]] for idx in wm.agg.index]
Expand Down

0 comments on commit c6bbd0f

Please sign in to comment.