@@ -97,17 +97,21 @@ def f(values, axis=None, skipna=True, **kwds):
97
97
for k , v in self .kwargs .items ():
98
98
if k not in kwds :
99
99
kwds [k ] = v
100
- try :
101
- if values .size == 0 and kwds .get ("min_count" ) is None :
102
- # We are empty, returning NA for our type
103
- # Only applies for the default `min_count` of None
104
- # since that affects how empty arrays are handled.
105
- # TODO(GH-18976) update all the nanops methods to
106
- # correctly handle empty inputs and remove this check.
107
- # It *may* just be `var`
108
- return _na_for_min_count (values , axis )
109
-
110
- if _USE_BOTTLENECK and skipna and _bn_ok_dtype (values .dtype , bn_name ):
100
+
101
+ if values .size == 0 and kwds .get ("min_count" ) is None :
102
+ # We are empty, returning NA for our type
103
+ # Only applies for the default `min_count` of None
104
+ # since that affects how empty arrays are handled.
105
+ # TODO(GH-18976) update all the nanops methods to
106
+ # correctly handle empty inputs and remove this check.
107
+ # It *may* just be `var`
108
+ return _na_for_min_count (values , axis )
109
+
110
+ if _USE_BOTTLENECK and skipna and _bn_ok_dtype (values .dtype , bn_name ):
111
+ if kwds .get ("mask" , None ) is None :
112
+ # `mask` is not recognised by bottleneck, would raise
113
+ # TypeError if called
114
+ kwds .pop ("mask" , None )
111
115
result = bn_func (values , axis = axis , ** kwds )
112
116
113
117
# prefer to treat inf/-inf as NA, but must compute the func
@@ -116,18 +120,8 @@ def f(values, axis=None, skipna=True, **kwds):
116
120
result = alt (values , axis = axis , skipna = skipna , ** kwds )
117
121
else :
118
122
result = alt (values , axis = axis , skipna = skipna , ** kwds )
119
- except Exception :
120
- try :
121
- result = alt (values , axis = axis , skipna = skipna , ** kwds )
122
- except ValueError as e :
123
- # we want to transform an object array
124
- # ValueError message to the more typical TypeError
125
- # e.g. this is normally a disallowed function on
126
- # object arrays that contain strings
127
-
128
- if is_object_dtype (values ):
129
- raise TypeError (e )
130
- raise
123
+ else :
124
+ result = alt (values , axis = axis , skipna = skipna , ** kwds )
131
125
132
126
return result
133
127
0 commit comments