Skip to content

Commit 0707d86

Browse files
committed
added returned type for all aggregation functions and methods (issue larray-project#864)
1 parent 28694d2 commit 0707d86

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

larray/core/array.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
from larray.util.options import _OPTIONS, DISPLAY_MAXLINES, DISPLAY_EDGEITEMS, DISPLAY_WIDTH, DISPLAY_PRECISION
6464

6565

66-
def all(values, axis=None):
66+
def all(values, axis=None) -> 'Array':
6767
r"""
6868
Test whether all array elements along a given axis evaluate to True.
6969
@@ -77,7 +77,7 @@ def all(values, axis=None):
7777
return builtins.all(values)
7878

7979

80-
def any(values, axis=None):
80+
def any(values, axis=None) -> 'Array':
8181
r"""
8282
Test whether any array elements along a given axis evaluate to True.
8383
@@ -92,7 +92,7 @@ def any(values, axis=None):
9292

9393

9494
# commutative modulo float precision errors
95-
def sum(array, *args, **kwargs):
95+
def sum(array, *args, **kwargs) -> 'Array':
9696
r"""
9797
Sum of array elements.
9898
@@ -110,7 +110,7 @@ def sum(array, *args, **kwargs):
110110
return builtins.sum(array, *args, **kwargs)
111111

112112

113-
def prod(array, *args, **kwargs):
113+
def prod(array, *args, **kwargs) -> 'Array':
114114
r"""
115115
Product of array elements.
116116
@@ -121,7 +121,7 @@ def prod(array, *args, **kwargs):
121121
return array.prod(*args, **kwargs)
122122

123123

124-
def cumsum(array, *args, **kwargs):
124+
def cumsum(array, *args, **kwargs) -> 'Array':
125125
r"""
126126
Returns the cumulative sum of array elements.
127127
@@ -132,7 +132,7 @@ def cumsum(array, *args, **kwargs):
132132
return array.cumsum(*args, **kwargs)
133133

134134

135-
def cumprod(array, *args, **kwargs):
135+
def cumprod(array, *args, **kwargs) -> 'Array':
136136
r"""
137137
Returns the cumulative product of array elements.
138138
@@ -143,7 +143,7 @@ def cumprod(array, *args, **kwargs):
143143
return array.cumprod(*args, **kwargs)
144144

145145

146-
def min(array, *args, **kwargs):
146+
def min(array, *args, **kwargs) -> 'Array':
147147
r"""
148148
Minimum of array elements.
149149
@@ -157,7 +157,7 @@ def min(array, *args, **kwargs):
157157
return builtins.min(array, *args, **kwargs)
158158

159159

160-
def max(array, *args, **kwargs):
160+
def max(array, *args, **kwargs) -> 'Array':
161161
r"""
162162
Maximum of array elements.
163163
@@ -171,7 +171,7 @@ def max(array, *args, **kwargs):
171171
return builtins.max(array, *args, **kwargs)
172172

173173

174-
def mean(array, *args, **kwargs):
174+
def mean(array, *args, **kwargs) -> 'Array':
175175
r"""
176176
Computes the arithmetic mean.
177177
@@ -182,7 +182,7 @@ def mean(array, *args, **kwargs):
182182
return array.mean(*args, **kwargs)
183183

184184

185-
def median(array, *args, **kwargs):
185+
def median(array, *args, **kwargs) -> 'Array':
186186
r"""
187187
Computes the median.
188188
@@ -193,7 +193,7 @@ def median(array, *args, **kwargs):
193193
return array.median(*args, **kwargs)
194194

195195

196-
def percentile(array, *args, **kwargs):
196+
def percentile(array, *args, **kwargs) -> 'Array':
197197
r"""
198198
Computes the qth percentile of the data along the specified axis.
199199
@@ -205,7 +205,7 @@ def percentile(array, *args, **kwargs):
205205

206206

207207
# not commutative
208-
def ptp(array, *args, **kwargs):
208+
def ptp(array, *args, **kwargs) -> 'Array':
209209
r"""
210210
Returns the range of values (maximum - minimum).
211211
@@ -216,7 +216,7 @@ def ptp(array, *args, **kwargs):
216216
return array.ptp(*args, **kwargs)
217217

218218

219-
def var(array, *args, **kwargs):
219+
def var(array, *args, **kwargs) -> 'Array':
220220
r"""
221221
Computes the variance.
222222
@@ -227,7 +227,7 @@ def var(array, *args, **kwargs):
227227
return array.var(*args, **kwargs)
228228

229229

230-
def std(array, *args, **kwargs):
230+
def std(array, *args, **kwargs) -> 'Array':
231231
r"""
232232
Computes the standard deviation.
233233
@@ -3978,7 +3978,7 @@ def wrapper(self, *args, **kwargs):
39783978
return decorated
39793979

39803980
@_decorate_agg_method(np.all, commutative=True, long_name="AND reduction")
3981-
def all(self, *args, **kwargs):
3981+
def all(self, *args, **kwargs) -> 'Array':
39823982
r"""{signature}
39833983
39843984
Test whether all selected elements evaluate to True.
@@ -4049,7 +4049,7 @@ def all(self, *args, **kwargs):
40494049
pass
40504050

40514051
@_decorate_agg_method(np.all, commutative=True, by_agg=True, long_name="AND reduction")
4052-
def all_by(self, *args, **kwargs):
4052+
def all_by(self, *args, **kwargs) -> 'Array':
40534053
r"""{signature}
40544054
40554055
Test whether all selected elements evaluate to True.
@@ -4117,7 +4117,7 @@ def all_by(self, *args, **kwargs):
41174117
pass
41184118

41194119
@_decorate_agg_method(np.any, commutative=True, long_name="OR reduction")
4120-
def any(self, *args, **kwargs):
4120+
def any(self, *args, **kwargs) -> 'Array':
41214121
r"""{signature}
41224122
41234123
Test whether any selected elements evaluate to True.
@@ -4188,7 +4188,7 @@ def any(self, *args, **kwargs):
41884188
pass
41894189

41904190
@_decorate_agg_method(np.any, commutative=True, by_agg=True, long_name="OR reduction")
4191-
def any_by(self, *args, **kwargs):
4191+
def any_by(self, *args, **kwargs) -> 'Array':
41924192
r"""{signature}
41934193
41944194
Test whether any selected elements evaluate to True.
@@ -4258,7 +4258,7 @@ def any_by(self, *args, **kwargs):
42584258
# commutative modulo float precision errors
42594259

42604260
@_decorate_agg_method(np.sum, np.nansum, commutative=True, extra_kwargs=['dtype'])
4261-
def sum(self, *args, **kwargs):
4261+
def sum(self, *args, **kwargs) -> 'Array':
42624262
r"""{signature}
42634263
42644264
Computes the sum of array elements along given axes/groups.
@@ -4323,7 +4323,7 @@ def sum(self, *args, **kwargs):
43234323
pass
43244324

43254325
@_decorate_agg_method(np.sum, np.nansum, commutative=True, by_agg=True, extra_kwargs=['dtype'], long_name="sum")
4326-
def sum_by(self, *args, **kwargs):
4326+
def sum_by(self, *args, **kwargs) -> 'Array':
43274327
r"""{signature}
43284328
43294329
Computes the sum of array elements for the given axes/groups.
@@ -4386,7 +4386,7 @@ def sum_by(self, *args, **kwargs):
43864386

43874387
# nanprod needs numpy 1.10
43884388
@_decorate_agg_method(np.prod, np_nanprod, commutative=True, extra_kwargs=['dtype'], long_name="product")
4389-
def prod(self, *args, **kwargs):
4389+
def prod(self, *args, **kwargs) -> 'Array':
43904390
r"""{signature}
43914391
43924392
Computes the product of array elements along given axes/groups.
@@ -4452,7 +4452,7 @@ def prod(self, *args, **kwargs):
44524452

44534453
@_decorate_agg_method(np.prod, np_nanprod, commutative=True, by_agg=True, extra_kwargs=['dtype'],
44544454
long_name="product")
4455-
def prod_by(self, *args, **kwargs):
4455+
def prod_by(self, *args, **kwargs) -> 'Array':
44564456
r"""{signature}
44574457
44584458
Computes the product of array elements for the given axes/groups.
@@ -4514,7 +4514,7 @@ def prod_by(self, *args, **kwargs):
45144514
pass
45154515

45164516
@_decorate_agg_method(np.min, np.nanmin, commutative=True, long_name="minimum", action_verb="search")
4517-
def min(self, *args, **kwargs):
4517+
def min(self, *args, **kwargs) -> 'Array':
45184518
r"""{signature}
45194519
45204520
Get minimum of array elements along given axes/groups.
@@ -4578,7 +4578,7 @@ def min(self, *args, **kwargs):
45784578
pass
45794579

45804580
@_decorate_agg_method(np.min, np.nanmin, commutative=True, by_agg=True, long_name="minimum", action_verb="search")
4581-
def min_by(self, *args, **kwargs):
4581+
def min_by(self, *args, **kwargs) -> 'Array':
45824582
r"""{signature}
45834583
45844584
Get minimum of array elements for the given axes/groups.
@@ -4639,7 +4639,7 @@ def min_by(self, *args, **kwargs):
46394639
pass
46404640

46414641
@_decorate_agg_method(np.max, np.nanmax, commutative=True, long_name="maximum", action_verb="search")
4642-
def max(self, *args, **kwargs):
4642+
def max(self, *args, **kwargs) -> 'Array':
46434643
r"""{signature}
46444644
46454645
Get maximum of array elements along given axes/groups.
@@ -4703,7 +4703,7 @@ def max(self, *args, **kwargs):
47034703
pass
47044704

47054705
@_decorate_agg_method(np.max, np.nanmax, commutative=True, by_agg=True, long_name="maximum", action_verb="search")
4706-
def max_by(self, *args, **kwargs):
4706+
def max_by(self, *args, **kwargs) -> 'Array':
47074707
r"""{signature}
47084708
47094709
Get maximum of array elements for the given axes/groups.
@@ -4764,7 +4764,7 @@ def max_by(self, *args, **kwargs):
47644764
pass
47654765

47664766
@_decorate_agg_method(np.mean, np.nanmean, commutative=True, extra_kwargs=['dtype'])
4767-
def mean(self, *args, **kwargs):
4767+
def mean(self, *args, **kwargs) -> 'Array':
47684768
r"""{signature}
47694769
47704770
Computes the arithmetic mean.
@@ -4830,7 +4830,7 @@ def mean(self, *args, **kwargs):
48304830
pass
48314831

48324832
@_decorate_agg_method(np.mean, np.nanmean, commutative=True, by_agg=True, extra_kwargs=['dtype'], long_name="mean")
4833-
def mean_by(self, *args, **kwargs):
4833+
def mean_by(self, *args, **kwargs) -> 'Array':
48344834
r"""{signature}
48354835
48364836
Computes the arithmetic mean.
@@ -4893,7 +4893,7 @@ def mean_by(self, *args, **kwargs):
48934893
pass
48944894

48954895
@_decorate_agg_method(np.median, np.nanmedian, commutative=True)
4896-
def median(self, *args, **kwargs):
4896+
def median(self, *args, **kwargs) -> 'Array':
48974897
r"""{signature}
48984898
48994899
Computes the arithmetic median.
@@ -4963,7 +4963,7 @@ def median(self, *args, **kwargs):
49634963
pass
49644964

49654965
@_decorate_agg_method(np.median, np.nanmedian, commutative=True, by_agg=True, long_name="mediane")
4966-
def median_by(self, *args, **kwargs):
4966+
def median_by(self, *args, **kwargs) -> 'Array':
49674967
r"""{signature}
49684968
49694969
Computes the arithmetic median.
@@ -5034,7 +5034,7 @@ def median_by(self, *args, **kwargs):
50345034
# since in this case np.percentile() may be called several times.
50355035
# percentile needs an explicit method because it has not the same
50365036
# signature as other aggregate functions (extra argument)
5037-
def percentile(self, q, *args, **kwargs):
5037+
def percentile(self, q, *args, **kwargs) -> 'Array':
50385038
r"""{signature}
50395039
50405040
Computes the qth percentile of the data along the specified axis.
@@ -5122,7 +5122,7 @@ def percentile(self, q, *args, **kwargs):
51225122
_doc_agg_method(percentile, False, "qth percentile", extra_args=['q'],
51235123
kwargs=['out', 'interpolation', 'skipna', 'keepaxes'])
51245124

5125-
def percentile_by(self, q, *args, **kwargs):
5125+
def percentile_by(self, q, *args, **kwargs) -> 'Array':
51265126
r"""{signature}
51275127
51285128
Computes the qth percentile of the data for the specified axis.
@@ -5208,7 +5208,7 @@ def percentile_by(self, q, *args, **kwargs):
52085208

52095209
# not commutative
52105210

5211-
def ptp(self, *args, **kwargs):
5211+
def ptp(self, *args, **kwargs) -> 'Array':
52125212
r"""{signature}
52135213
52145214
Returns the range of values (maximum - minimum).
@@ -5273,7 +5273,7 @@ def ptp(self, *args, **kwargs):
52735273
_doc_agg_method(ptp, False, kwargs=['out'])
52745274

52755275
@_decorate_agg_method(np.var, np.nanvar, extra_kwargs=['dtype', 'ddof'], long_name="variance")
5276-
def var(self, *args, **kwargs):
5276+
def var(self, *args, **kwargs) -> 'Array':
52775277
r"""{signature}
52785278
52795279
Computes the unbiased variance.
@@ -5337,7 +5337,7 @@ def var(self, *args, **kwargs):
53375337
pass
53385338

53395339
@_decorate_agg_method(np.var, np.nanvar, by_agg=True, extra_kwargs=['dtype', 'ddof'], long_name="variance")
5340-
def var_by(self, *args, **kwargs):
5340+
def var_by(self, *args, **kwargs) -> 'Array':
53415341
r"""{signature}
53425342
53435343
Computes the unbiased variance.
@@ -5401,7 +5401,7 @@ def var_by(self, *args, **kwargs):
54015401
pass
54025402

54035403
@_decorate_agg_method(np.std, np.nanstd, extra_kwargs=['dtype', 'ddof'], long_name="standard deviation")
5404-
def std(self, *args, **kwargs):
5404+
def std(self, *args, **kwargs) -> 'Array':
54055405
r"""{signature}
54065406
54075407
Computes the sample standard deviation.
@@ -5466,7 +5466,7 @@ def std(self, *args, **kwargs):
54665466

54675467
@_decorate_agg_method(np.std, np.nanstd, by_agg=True, extra_kwargs=['dtype', 'ddof'],
54685468
long_name="standard deviation")
5469-
def std_by(self, *args, **kwargs):
5469+
def std_by(self, *args, **kwargs) -> 'Array':
54705470
r"""{signature}
54715471
54725472
Computes the sample standard deviation.
@@ -5530,7 +5530,7 @@ def std_by(self, *args, **kwargs):
55305530
pass
55315531

55325532
# cumulative aggregates
5533-
def cumsum(self, axis=-1):
5533+
def cumsum(self, axis=-1) -> 'Array':
55345534
r"""
55355535
Returns the cumulative sum of array elements along an axis.
55365536
@@ -5578,7 +5578,7 @@ def cumsum(self, axis=-1):
55785578
"""
55795579
return self._cum_aggregate(np.cumsum, axis)
55805580

5581-
def cumprod(self, axis=-1):
5581+
def cumprod(self, axis=-1) -> 'Array':
55825582
r"""
55835583
Returns the cumulative product of array elements.
55845584

0 commit comments

Comments
 (0)