Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jan 7, 2025
1 parent 7a794ba commit eec4dd4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions flox/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,11 @@ def _initialize_aggregation(
),
}

if agg.name == "topk" and finalize_kwargs["k"] < 0:
if finalize_kwargs is not None:
assert isinstance(finalize_kwargs, dict)
agg.finalize_kwargs = finalize_kwargs

if agg.name == "topk" and agg.finalize_kwargs["k"] < 0:
agg.fill_value["intermediate"] = (dtypes.INF,)
# Replace sentinel fill values according to dtype
agg.fill_value["user"] = fill_value
Expand All @@ -852,10 +856,6 @@ def _initialize_aggregation(
else:
agg.fill_value["numpy"] = (fv,)

if finalize_kwargs is not None:
assert isinstance(finalize_kwargs, dict)
agg.finalize_kwargs = finalize_kwargs

# This is needed for the dask pathway.
# Because we use intermediate fill_value since a group could be
# absent in one block, but present in another block
Expand Down Expand Up @@ -883,7 +883,7 @@ def _initialize_aggregation(
simple_combine.append(getattr(np, combine))
else:
if agg.name == "topk":
combine = partial(combine, **finalize_kwargs)
combine = partial(combine, **agg.finalize_kwargs)
simple_combine.append(combine)

agg.simple_combine = tuple(simple_combine)
Expand Down

0 comments on commit eec4dd4

Please sign in to comment.