@@ -81,10 +81,10 @@ def _can_use_numexpr(op, op_str, left_op, right_op, dtype_check) -> bool:
8181 if left_op .size > _MIN_ELEMENTS :
8282 # check for dtype compatibility
8383 dtypes : set [str ] = set ()
84- for operand in [left_op , right_op ]:
84+ for o in [left_op , right_op ]:
8585 # ndarray and Series Case
86- if hasattr (operand , "dtype" ):
87- dtypes |= {operand .dtype .name }
86+ if hasattr (o , "dtype" ):
87+ dtypes |= {o .dtype .name }
8888
8989 # allowed are a superset
9090 if not len (dtypes ) or _ALLOWED_DTYPES [dtype_check ] >= dtypes :
@@ -108,7 +108,7 @@ def _evaluate_numexpr(op, op_str, left_op, right_op):
108108 try :
109109 result = ne .evaluate (
110110 f"left_value { op_str } right_value" ,
111- local_dict = {"a_value " : left_value , "b_value " : right_value },
111+ local_dict = {"left_value " : left_value , "right_value " : right_value },
112112 casting = "safe" ,
113113 )
114114 except TypeError :
@@ -170,24 +170,24 @@ def _evaluate_numexpr(op, op_str, left_op, right_op):
170170}
171171
172172
173- def _where_standard (cond , a , b ):
173+ def _where_standard (cond , left_op , right_op ):
174174 # Caller is responsible for extracting ndarray if necessary
175- return np .where (cond , a , b )
175+ return np .where (cond , left_op , right_op )
176176
177177
178- def _where_numexpr (cond , a , b ):
178+ def _where_numexpr (cond , left_op , right_op ):
179179 # Caller is responsible for extracting ndarray if necessary
180180 result = None
181181
182- if _can_use_numexpr (None , "where" , a , b , "where" ):
182+ if _can_use_numexpr (None , "where" , left_op , right_op , "where" ):
183183 result = ne .evaluate (
184- "where(cond_value, a_value, b_value )" ,
185- local_dict = {"cond_value" : cond , "a_value " : a , "b_value " : b },
184+ "where(cond_value, left_value, right_value )" ,
185+ local_dict = {"cond_value" : cond , "left_value " : left_op , "right_value " : right_op },
186186 casting = "safe" ,
187187 )
188188
189189 if result is None :
190- result = _where_standard (cond , a , b )
190+ result = _where_standard (cond , left_op , right_op )
191191
192192 return result
193193
@@ -206,13 +206,13 @@ def _has_bool_dtype(x):
206206_BOOL_OP_UNSUPPORTED = {"+" : "|" , "*" : "&" , "-" : "^" }
207207
208208
209- def _bool_arith_fallback (op_str , a , b ) -> bool :
209+ def _bool_arith_fallback (op_str , left_op , right_op ) -> bool :
210210 """
211211 Check if we should fallback to the python `_evaluate_standard` in case
212212 of an unsupported operation by numexpr, which is the case for some
213213 boolean ops.
214214 """
215- if _has_bool_dtype (a ) and _has_bool_dtype (b ):
215+ if _has_bool_dtype (left_op ) and _has_bool_dtype (right_op ):
216216 if op_str in _BOOL_OP_UNSUPPORTED :
217217 warnings .warn (
218218 f"evaluating in Python space because the { op_str !r} "
@@ -226,7 +226,7 @@ def _bool_arith_fallback(op_str, a, b) -> bool:
226226
227227def evaluate (op , left_op , right_op , use_numexpr : bool = True ):
228228 """
229- Evaluate and return the expression of the op on a and b .
229+ Evaluate and return the expression of the op on left_op and right_op .
230230
231231 Parameters
232232 ----------
@@ -244,20 +244,20 @@ def evaluate(op, left_op, right_op, use_numexpr: bool = True):
244244 return _evaluate_standard (op , op_str , left_op , right_op )
245245
246246
247- def where (cond , a , b , use_numexpr : bool = True ):
247+ def where (cond , left_op , right_op , use_numexpr : bool = True ):
248248 """
249- Evaluate the where condition cond on a and b .
249+ Evaluate the where condition cond on left_op and right_op .
250250
251251 Parameters
252252 ----------
253253 cond : np.ndarray[bool]
254- a : return if cond is True
255- b : return if cond is False
254+ left_op : return if cond is True
255+ right_op : return if cond is False
256256 use_numexpr : bool, default True
257257 Whether to try to use numexpr.
258258 """
259259 assert _where is not None
260- return _where (cond , a , b ) if use_numexpr else _where_standard (cond , a , b )
260+ return _where (cond , left_op , right_op ) if use_numexpr else _where_standard (cond , left_op , right_op )
261261
262262
263263def set_test_mode (v : bool = True ) -> None :
@@ -284,4 +284,4 @@ def get_test_result() -> list[bool]:
284284 global _TEST_RESULT
285285 res = _TEST_RESULT
286286 _TEST_RESULT = []
287- return res
287+ return res
0 commit comments