1
1
import functools
2
2
import itertools
3
3
import operator
4
- from typing import Any , Callable , Optional , Tuple , Union
4
+ from typing import Any , Optional , Tuple , Union
5
5
6
6
import numpy as np
7
7
@@ -56,7 +56,7 @@ def __init__(self, *dtypes):
56
56
def check (self , obj ) -> bool :
57
57
return hasattr (obj , "dtype" ) and issubclass (obj .dtype .type , self .dtypes )
58
58
59
- def __call__ (self , f ) -> Callable :
59
+ def __call__ (self , f ):
60
60
@functools .wraps (f )
61
61
def _f (* args , ** kwargs ):
62
62
obj_iter = itertools .chain (args , kwargs .values ())
@@ -81,11 +81,11 @@ def _f(*args, **kwargs):
81
81
82
82
83
83
class bottleneck_switch :
84
- def __init__ (self , name : Optional [ str ] = None , ** kwargs ):
84
+ def __init__ (self , name = None , ** kwargs ):
85
85
self .name = name
86
86
self .kwargs = kwargs
87
87
88
- def __call__ (self , alt : Callable ) -> Callable :
88
+ def __call__ (self , alt ) :
89
89
bn_name = self .name or alt .__name__
90
90
91
91
try :
@@ -167,9 +167,7 @@ def _has_infs(result) -> bool:
167
167
168
168
169
169
def _get_fill_value (
170
- dtype : Dtype ,
171
- fill_value : Optional [Scalar ] = None ,
172
- fill_value_typ : Optional [str ] = None ,
170
+ dtype : Dtype , fill_value : Optional [Scalar ] = None , fill_value_typ = None
173
171
):
174
172
""" return the correct fill value for the dtype of the values """
175
173
if fill_value is not None :
@@ -850,7 +848,7 @@ def nansem(
850
848
return np .sqrt (var ) / np .sqrt (count )
851
849
852
850
853
- def _nanminmax (meth : str , fill_value_typ : str ) -> Callable :
851
+ def _nanminmax (meth , fill_value_typ ) :
854
852
@bottleneck_switch (name = "nan" + meth )
855
853
def reduction (
856
854
values : np .ndarray ,
@@ -1307,7 +1305,7 @@ def nancorr(
1307
1305
return f (a , b )
1308
1306
1309
1307
1310
- def get_corr_func (method ) -> Callable :
1308
+ def get_corr_func (method ):
1311
1309
if method in ["kendall" , "spearman" ]:
1312
1310
from scipy .stats import kendalltau , spearmanr
1313
1311
elif method in ["pearson" ]:
@@ -1381,7 +1379,7 @@ def _ensure_numeric(x):
1381
1379
# NA-friendly array comparisons
1382
1380
1383
1381
1384
- def make_nancomp (op ) -> Callable :
1382
+ def make_nancomp (op ):
1385
1383
def f (x , y ):
1386
1384
xmask = isna (x )
1387
1385
ymask = isna (y )
@@ -1409,7 +1407,7 @@ def f(x, y):
1409
1407
1410
1408
1411
1409
def _nanpercentile_1d (
1412
- values : np .ndarray , mask : np .ndarray , q , na_value : Scalar , interpolation : str
1410
+ values : np .ndarray , mask : np .ndarray , q , na_value : Scalar , interpolation
1413
1411
) -> Union [Scalar , np .ndarray ]:
1414
1412
"""
1415
1413
Wrapper for np.percentile that skips missing values, specialized to
@@ -1448,7 +1446,7 @@ def nanpercentile(
1448
1446
na_value ,
1449
1447
mask : np .ndarray ,
1450
1448
ndim : int ,
1451
- interpolation : str ,
1449
+ interpolation ,
1452
1450
):
1453
1451
"""
1454
1452
Wrapper for np.percentile that skips missing values.
0 commit comments