Skip to content

Commit 30385c1

Browse files
authored
Deprecate misspelled aggegrate_func in favour of aggregate_func (#444)
1 parent c2283f3 commit 30385c1

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

cubed/array_api/statistical_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def mean(x, /, *, axis=None, keepdims=False, use_new_impl=True, split_every=None
4747
x,
4848
_mean_func,
4949
combine_func=_mean_combine,
50-
aggegrate_func=_mean_aggregate,
50+
aggregate_func=_mean_aggregate,
5151
axis=axis,
5252
intermediate_dtype=intermediate_dtype,
5353
dtype=dtype,

cubed/core/ops.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from numbers import Integral, Number
77
from operator import add
88
from typing import TYPE_CHECKING, Any, Sequence, Union
9+
from warnings import warn
910

1011
import numpy as np
1112
import zarr
@@ -886,7 +887,8 @@ def reduction(
886887
x: "Array",
887888
func,
888889
combine_func=None,
889-
aggegrate_func=None,
890+
aggegrate_func=None, # typo, will removed in next release
891+
aggregate_func=None,
890892
axis=None,
891893
intermediate_dtype=None,
892894
dtype=None,
@@ -896,12 +898,19 @@ def reduction(
896898
extra_func_kwargs=None,
897899
) -> "Array":
898900
"""Apply a function to reduce an array along one or more axes."""
901+
if aggegrate_func is not None and aggregate_func is None:
902+
warn(
903+
"`aggegrate_func` is deprecated, please use `aggregate_func` instead",
904+
DeprecationWarning,
905+
stacklevel=2,
906+
)
907+
aggregate_func = aggegrate_func
899908
if use_new_impl:
900909
return reduction_new(
901910
x,
902911
func,
903912
combine_func,
904-
aggegrate_func,
913+
aggregate_func,
905914
axis,
906915
intermediate_dtype,
907916
dtype,
@@ -983,8 +992,8 @@ def reduction(
983992
extra_func_kwargs=extra_func_kwargs,
984993
)
985994

986-
if aggegrate_func is not None:
987-
result = map_blocks(aggegrate_func, result, dtype=dtype)
995+
if aggregate_func is not None:
996+
result = map_blocks(aggregate_func, result, dtype=dtype)
988997

989998
if not keepdims:
990999
axis_to_squeeze = tuple(i for i in axis if result.shape[i] == 1)
@@ -1002,7 +1011,7 @@ def reduction_new(
10021011
x: "Array",
10031012
func,
10041013
combine_func=None,
1005-
aggegrate_func=None,
1014+
aggregate_func=None,
10061015
axis=None,
10071016
intermediate_dtype=None,
10081017
dtype=None,
@@ -1043,8 +1052,8 @@ def reduction_new(
10431052
)
10441053

10451054
# aggregate final chunks
1046-
if aggegrate_func is not None:
1047-
result = map_blocks(aggegrate_func, result, dtype=dtype)
1055+
if aggregate_func is not None:
1056+
result = map_blocks(aggregate_func, result, dtype=dtype)
10481057

10491058
if not keepdims:
10501059
axis_to_squeeze = tuple(i for i in axis if result.shape[i] == 1)
@@ -1213,7 +1222,7 @@ def arg_reduction(
12131222
out,
12141223
_arg_func,
12151224
combine_func=partial(_arg_combine, arg_func=arg_func),
1216-
aggegrate_func=_arg_aggregate,
1225+
aggregate_func=_arg_aggregate,
12171226
axis=axis,
12181227
intermediate_dtype=intermediate_dtype,
12191228
dtype=dtype,

cubed/nan_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def nanmean(x, /, *, axis=None, keepdims=False, use_new_impl=True, split_every=N
2626
x,
2727
_nanmean_func,
2828
combine_func=_nanmean_combine,
29-
aggegrate_func=_nanmean_aggregate,
29+
aggregate_func=_nanmean_aggregate,
3030
axis=axis,
3131
intermediate_dtype=intermediate_dtype,
3232
dtype=dtype,

0 commit comments

Comments
 (0)