16
16
17
17
import pandas .core .common as com
18
18
from pandas .core .computation .common import ensure_decoded , result_type_many
19
- from pandas .core .computation .scope import _DEFAULT_GLOBALS
19
+ from pandas .core .computation .scope import DEFAULT_GLOBALS
20
20
21
21
from pandas .io .formats .printing import pprint_thing , pprint_thing_encoded
22
22
23
- _reductions = ("sum" , "prod" )
23
+ REDUCTIONS = ("sum" , "prod" )
24
24
25
25
_unary_math_ops = (
26
26
"sin" ,
46
46
)
47
47
_binary_math_ops = ("arctan2" ,)
48
48
49
- _mathops = _unary_math_ops + _binary_math_ops
49
+ MATHOPS = _unary_math_ops + _binary_math_ops
50
50
51
51
52
- _LOCAL_TAG = "__pd_eval_local_"
52
+ LOCAL_TAG = "__pd_eval_local_"
53
53
54
54
55
55
class UndefinedVariableError (NameError ):
@@ -80,13 +80,13 @@ def __init__(self, name, env, side=None, encoding=None):
80
80
self .env = env
81
81
self .side = side
82
82
tname = str (name )
83
- self .is_local = tname .startswith (_LOCAL_TAG ) or tname in _DEFAULT_GLOBALS
83
+ self .is_local = tname .startswith (LOCAL_TAG ) or tname in DEFAULT_GLOBALS
84
84
self ._value = self ._resolve_name ()
85
85
self .encoding = encoding
86
86
87
87
@property
88
88
def local_name (self ) -> str :
89
- return self .name .replace (_LOCAL_TAG , "" )
89
+ return self .name .replace (LOCAL_TAG , "" )
90
90
91
91
def __repr__ (self ) -> str :
92
92
return pprint_thing (self .name )
@@ -220,7 +220,7 @@ def __repr__(self) -> str:
220
220
@property
221
221
def return_type (self ):
222
222
# clobber types to bool if the op is a boolean operator
223
- if self .op in (_cmp_ops_syms + _bool_ops_syms ):
223
+ if self .op in (CMP_OPS_SYMS + BOOL_OPS_SYMS ):
224
224
return np .bool_
225
225
return result_type_many (* (term .type for term in com .flatten (self )))
226
226
@@ -280,7 +280,7 @@ def _not_in(x, y):
280
280
return x not in y
281
281
282
282
283
- _cmp_ops_syms = (">" , "<" , ">=" , "<=" , "==" , "!=" , "in" , "not in" )
283
+ CMP_OPS_SYMS = (">" , "<" , ">=" , "<=" , "==" , "!=" , "in" , "not in" )
284
284
_cmp_ops_funcs = (
285
285
operator .gt ,
286
286
operator .lt ,
@@ -291,13 +291,13 @@ def _not_in(x, y):
291
291
_in ,
292
292
_not_in ,
293
293
)
294
- _cmp_ops_dict = dict (zip (_cmp_ops_syms , _cmp_ops_funcs ))
294
+ _cmp_ops_dict = dict (zip (CMP_OPS_SYMS , _cmp_ops_funcs ))
295
295
296
- _bool_ops_syms = ("&" , "|" , "and" , "or" )
296
+ BOOL_OPS_SYMS = ("&" , "|" , "and" , "or" )
297
297
_bool_ops_funcs = (operator .and_ , operator .or_ , operator .and_ , operator .or_ )
298
- _bool_ops_dict = dict (zip (_bool_ops_syms , _bool_ops_funcs ))
298
+ _bool_ops_dict = dict (zip (BOOL_OPS_SYMS , _bool_ops_funcs ))
299
299
300
- _arith_ops_syms = ("+" , "-" , "*" , "/" , "**" , "//" , "%" )
300
+ ARITH_OPS_SYMS = ("+" , "-" , "*" , "/" , "**" , "//" , "%" )
301
301
_arith_ops_funcs = (
302
302
operator .add ,
303
303
operator .sub ,
@@ -307,12 +307,12 @@ def _not_in(x, y):
307
307
operator .floordiv ,
308
308
operator .mod ,
309
309
)
310
- _arith_ops_dict = dict (zip (_arith_ops_syms , _arith_ops_funcs ))
310
+ _arith_ops_dict = dict (zip (ARITH_OPS_SYMS , _arith_ops_funcs ))
311
311
312
- _special_case_arith_ops_syms = ("**" , "//" , "%" )
312
+ SPECIAL_CASE_ARITH_OPS_SYMS = ("**" , "//" , "%" )
313
313
_special_case_arith_ops_funcs = (operator .pow , operator .floordiv , operator .mod )
314
314
_special_case_arith_ops_dict = dict (
315
- zip (_special_case_arith_ops_syms , _special_case_arith_ops_funcs )
315
+ zip (SPECIAL_CASE_ARITH_OPS_SYMS , _special_case_arith_ops_funcs )
316
316
)
317
317
318
318
_binary_ops_dict = {}
@@ -530,9 +530,9 @@ def __init__(self, lhs, rhs):
530
530
_cast_inplace (com .flatten (self ), acceptable_dtypes , np .float_ )
531
531
532
532
533
- _unary_ops_syms = ("+" , "-" , "~" , "not" )
533
+ UNARY_OPS_SYMS = ("+" , "-" , "~" , "not" )
534
534
_unary_ops_funcs = (operator .pos , operator .neg , operator .invert , operator .invert )
535
- _unary_ops_dict = dict (zip (_unary_ops_syms , _unary_ops_funcs ))
535
+ _unary_ops_dict = dict (zip (UNARY_OPS_SYMS , _unary_ops_funcs ))
536
536
537
537
538
538
class UnaryOp (Op ):
@@ -561,7 +561,7 @@ def __init__(self, op: str, operand):
561
561
except KeyError as err :
562
562
raise ValueError (
563
563
f"Invalid unary operator { repr (op )} , "
564
- f"valid operators are { _unary_ops_syms } "
564
+ f"valid operators are { UNARY_OPS_SYMS } "
565
565
) from err
566
566
567
567
def __call__ (self , env ):
@@ -602,7 +602,7 @@ class FuncNode:
602
602
def __init__ (self , name : str ):
603
603
from pandas .core .computation .check import NUMEXPR_INSTALLED , NUMEXPR_VERSION
604
604
605
- if name not in _mathops or (
605
+ if name not in MATHOPS or (
606
606
NUMEXPR_INSTALLED
607
607
and NUMEXPR_VERSION < LooseVersion ("2.6.9" )
608
608
and name in ("floor" , "ceil" )
0 commit comments