@@ -107,15 +107,12 @@ def _evaluate_numexpr(op, op_str, a, b, reversed=False):
107
107
108
108
a_value = getattr (a , "values" , a )
109
109
b_value = getattr (b , "values" , b )
110
- try :
111
- result = ne .evaluate (
112
- "a_value {op} b_value" .format (op = op_str ),
113
- local_dict = {"a_value" : a_value , "b_value" : b_value },
114
- casting = "safe" ,
115
- )
116
- except ValueError as detail :
117
- if "unknown type object" in str (detail ):
118
- pass
110
+
111
+ result = ne .evaluate (
112
+ "a_value {op} b_value" .format (op = op_str ),
113
+ local_dict = {"a_value" : a_value , "b_value" : b_value },
114
+ casting = "safe" ,
115
+ )
119
116
120
117
if _TEST_MODE :
121
118
_store_test_result (result is not None )
@@ -140,21 +137,15 @@ def _where_numexpr(cond, a, b):
140
137
a_value = getattr (a , "values" , a )
141
138
b_value = getattr (b , "values" , b )
142
139
143
- try :
144
- result = ne .evaluate (
145
- "where(cond_value, a_value, b_value)" ,
146
- local_dict = {
147
- "cond_value" : cond_value ,
148
- "a_value" : a_value ,
149
- "b_value" : b_value ,
150
- },
151
- casting = "safe" ,
152
- )
153
- except ValueError as detail :
154
- if "unknown type object" in str (detail ):
155
- pass
156
- except Exception as detail :
157
- raise TypeError (str (detail ))
140
+ result = ne .evaluate (
141
+ "where(cond_value, a_value, b_value)" ,
142
+ local_dict = {
143
+ "cond_value" : cond_value ,
144
+ "a_value" : a_value ,
145
+ "b_value" : b_value ,
146
+ },
147
+ casting = "safe" ,
148
+ )
158
149
159
150
if result is None :
160
151
result = _where_standard (cond , a , b )
@@ -167,11 +158,10 @@ def _where_numexpr(cond, a, b):
167
158
168
159
169
160
def _has_bool_dtype (x ):
161
+ if isinstance (x , ABCDataFrame ):
162
+ return "bool" in x .dtypes
170
163
try :
171
- if isinstance (x , ABCDataFrame ):
172
- return "bool" in x .dtypes
173
- else :
174
- return x .dtype == bool
164
+ return x .dtype == bool
175
165
except AttributeError :
176
166
return isinstance (x , (bool , np .bool_ ))
177
167
0 commit comments