|
4 | 4 | from datetime import datetime
|
5 | 5 | from distutils.version import LooseVersion
|
6 | 6 | from functools import partial
|
7 |
| -import operator as op |
| 7 | +import operator |
8 | 8 |
|
9 | 9 | import numpy as np
|
10 | 10 |
|
|
18 | 18 |
|
19 | 19 | from pandas.io.formats.printing import pprint_thing, pprint_thing_encoded
|
20 | 20 |
|
21 |
| -_reductions = "sum", "prod" |
| 21 | +_reductions = ("sum", "prod") |
22 | 22 |
|
23 | 23 | _unary_math_ops = (
|
24 | 24 | "sin",
|
@@ -273,20 +273,37 @@ def _not_in(x, y):
|
273 | 273 | return x not in y
|
274 | 274 |
|
275 | 275 |
|
276 |
| -_cmp_ops_syms = ">", "<", ">=", "<=", "==", "!=", "in", "not in" |
277 |
| -_cmp_ops_funcs = op.gt, op.lt, op.ge, op.le, op.eq, op.ne, _in, _not_in |
| 276 | +_cmp_ops_syms = (">", "<", ">=", "<=", "==", "!=", "in", "not in") |
| 277 | +_cmp_ops_funcs = ( |
| 278 | + operator.gt, |
| 279 | + operator.lt, |
| 280 | + operator.ge, |
| 281 | + operator.le, |
| 282 | + operator.eq, |
| 283 | + operator.ne, |
| 284 | + _in, |
| 285 | + _not_in, |
| 286 | +) |
278 | 287 | _cmp_ops_dict = dict(zip(_cmp_ops_syms, _cmp_ops_funcs))
|
279 | 288 |
|
280 |
| -_bool_ops_syms = "&", "|", "and", "or" |
281 |
| -_bool_ops_funcs = op.and_, op.or_, op.and_, op.or_ |
| 289 | +_bool_ops_syms = ("&", "|", "and", "or") |
| 290 | +_bool_ops_funcs = (operator.and_, operator.or_, operator.and_, operator.or_) |
282 | 291 | _bool_ops_dict = dict(zip(_bool_ops_syms, _bool_ops_funcs))
|
283 | 292 |
|
284 |
| -_arith_ops_syms = "+", "-", "*", "/", "**", "//", "%" |
285 |
| -_arith_ops_funcs = (op.add, op.sub, op.mul, op.truediv, op.pow, op.floordiv, op.mod) |
| 293 | +_arith_ops_syms = ("+", "-", "*", "/", "**", "//", "%") |
| 294 | +_arith_ops_funcs = ( |
| 295 | + operator.add, |
| 296 | + operator.sub, |
| 297 | + operator.mul, |
| 298 | + operator.truediv, |
| 299 | + operator.pow, |
| 300 | + operator.floordiv, |
| 301 | + operator.mod, |
| 302 | +) |
286 | 303 | _arith_ops_dict = dict(zip(_arith_ops_syms, _arith_ops_funcs))
|
287 | 304 |
|
288 |
| -_special_case_arith_ops_syms = "**", "//", "%" |
289 |
| -_special_case_arith_ops_funcs = op.pow, op.floordiv, op.mod |
| 305 | +_special_case_arith_ops_syms = ("**", "//", "%") |
| 306 | +_special_case_arith_ops_funcs = (operator.pow, operator.floordiv, operator.mod) |
290 | 307 | _special_case_arith_ops_dict = dict(
|
291 | 308 | zip(_special_case_arith_ops_syms, _special_case_arith_ops_funcs)
|
292 | 309 | )
|
@@ -371,7 +388,7 @@ def __call__(self, env):
|
371 | 388 | """
|
372 | 389 | # handle truediv
|
373 | 390 | if self.op == "/" and env.scope["truediv"]:
|
374 |
| - self.func = op.truediv |
| 391 | + self.func = operator.truediv |
375 | 392 |
|
376 | 393 | # recurse over the left/right nodes
|
377 | 394 | left = self.lhs(env)
|
@@ -502,8 +519,8 @@ def __init__(self, lhs, rhs, truediv, *args, **kwargs):
|
502 | 519 | _cast_inplace(com.flatten(self), acceptable_dtypes, np.float_)
|
503 | 520 |
|
504 | 521 |
|
505 |
| -_unary_ops_syms = "+", "-", "~", "not" |
506 |
| -_unary_ops_funcs = op.pos, op.neg, op.invert, op.invert |
| 522 | +_unary_ops_syms = ("+", "-", "~", "not") |
| 523 | +_unary_ops_funcs = (operator.pos, operator.neg, operator.invert, operator.invert) |
507 | 524 | _unary_ops_dict = dict(zip(_unary_ops_syms, _unary_ops_funcs))
|
508 | 525 |
|
509 | 526 |
|
|
0 commit comments