@@ -86,7 +86,7 @@ def __init__(self, name=None, **kwargs):
86
86
self .name = name
87
87
self .kwargs = kwargs
88
88
89
- def __call__ (self , alt ) :
89
+ def __call__ (self , alt : F ) -> F :
90
90
bn_name = self .name or alt .__name__
91
91
92
92
try :
@@ -130,7 +130,7 @@ def f(
130
130
131
131
return result
132
132
133
- return f
133
+ return cast ( F , f )
134
134
135
135
136
136
def _bn_ok_dtype (dtype : DtypeObj , name : str ) -> bool :
@@ -514,7 +514,12 @@ def nansum(
514
514
515
515
@disallow (PeriodDtype )
516
516
@bottleneck_switch ()
517
- def nanmean (values , axis = None , skipna = True , mask = None ):
517
+ def nanmean (
518
+ values : np .ndarray ,
519
+ axis : Optional [int ] = None ,
520
+ skipna : bool = True ,
521
+ mask : Optional [np .ndarray ] = None ,
522
+ ) -> float :
518
523
"""
519
524
Compute the mean of the element along an axis ignoring NaNs
520
525
@@ -528,7 +533,7 @@ def nanmean(values, axis=None, skipna=True, mask=None):
528
533
529
534
Returns
530
535
-------
531
- result : float
536
+ float
532
537
Unless input is a float array, in which case use the same
533
538
precision as the input array.
534
539
@@ -558,6 +563,7 @@ def nanmean(values, axis=None, skipna=True, mask=None):
558
563
the_sum = _ensure_numeric (values .sum (axis , dtype = dtype_sum ))
559
564
560
565
if axis is not None and getattr (the_sum , "ndim" , False ):
566
+ count = cast (np .ndarray , count )
561
567
with np .errstate (all = "ignore" ):
562
568
# suppress division by zero warnings
563
569
the_mean = the_sum / count
@@ -1205,17 +1211,17 @@ def _maybe_arg_null_out(
1205
1211
1206
1212
1207
1213
def _get_counts (
1208
- values_shape : Tuple [int ],
1214
+ values_shape : Tuple [int , ... ],
1209
1215
mask : Optional [np .ndarray ],
1210
1216
axis : Optional [int ],
1211
1217
dtype : Dtype = float ,
1212
- ) -> Union [int , np .ndarray ]:
1218
+ ) -> Union [int , float , np .ndarray ]:
1213
1219
"""
1214
1220
Get the count of non-null values along an axis
1215
1221
1216
1222
Parameters
1217
1223
----------
1218
- values_shape : Tuple[ int]
1224
+ values_shape : tuple of int
1219
1225
shape tuple from values ndarray, used if mask is None
1220
1226
mask : Optional[ndarray[bool]]
1221
1227
locations in values that should be considered missing
0 commit comments