|
10 | 10 |
|
11 | 11 | import numpy as np
|
12 | 12 |
|
13 |
| -from pandas.compat import lmap |
| 13 | +from pandas.compat import iteritems, lmap |
14 | 14 |
|
15 | 15 | import pandas as pd
|
16 |
| -from pandas import compat |
17 | 16 | from pandas.core import common as com
|
18 | 17 | from pandas.core.base import StringMixin
|
19 | 18 | from pandas.core.computation.common import (
|
@@ -301,7 +300,7 @@ def f(self, node, *args, **kwargs):
|
301 | 300 | def add_ops(op_classes):
|
302 | 301 | """Decorator to add default implementation of ops."""
|
303 | 302 | def f(cls):
|
304 |
| - for op_attr_name, op_class in compat.iteritems(op_classes): |
| 303 | + for op_attr_name, op_class in iteritems(op_classes): |
305 | 304 | ops = getattr(cls, '{name}_ops'.format(name=op_attr_name))
|
306 | 305 | ops_map = getattr(cls, '{name}_op_nodes_map'.format(
|
307 | 306 | name=op_attr_name))
|
@@ -590,9 +589,7 @@ def visit_Attribute(self, node, **kwargs):
|
590 | 589 | raise ValueError("Invalid Attribute context {name}"
|
591 | 590 | .format(name=ctx.__name__))
|
592 | 591 |
|
593 |
| - def visit_Call_35(self, node, side=None, **kwargs): |
594 |
| - """ in 3.5 the starargs attribute was changed to be more flexible, |
595 |
| - #11097 """ |
| 592 | + def visit_Call(self, node, side=None, **kwargs): |
596 | 593 |
|
597 | 594 | if isinstance(node.func, ast.Attribute):
|
598 | 595 | res = self.visit_Attribute(node.func)
|
@@ -641,58 +638,6 @@ def visit_Call_35(self, node, side=None, **kwargs):
|
641 | 638 |
|
642 | 639 | return self.const_type(res(*new_args, **kwargs), self.env)
|
643 | 640 |
|
644 |
| - def visit_Call_legacy(self, node, side=None, **kwargs): |
645 |
| - |
646 |
| - # this can happen with: datetime.datetime |
647 |
| - if isinstance(node.func, ast.Attribute): |
648 |
| - res = self.visit_Attribute(node.func) |
649 |
| - elif not isinstance(node.func, ast.Name): |
650 |
| - raise TypeError("Only named functions are supported") |
651 |
| - else: |
652 |
| - try: |
653 |
| - res = self.visit(node.func) |
654 |
| - except UndefinedVariableError: |
655 |
| - # Check if this is a supported function name |
656 |
| - try: |
657 |
| - res = FuncNode(node.func.id) |
658 |
| - except ValueError: |
659 |
| - # Raise original error |
660 |
| - raise |
661 |
| - |
662 |
| - if res is None: |
663 |
| - raise ValueError("Invalid function call {func}" |
664 |
| - .format(func=node.func.id)) |
665 |
| - if hasattr(res, 'value'): |
666 |
| - res = res.value |
667 |
| - |
668 |
| - if isinstance(res, FuncNode): |
669 |
| - args = [self.visit(targ) for targ in node.args] |
670 |
| - |
671 |
| - if node.starargs is not None: |
672 |
| - args += self.visit(node.starargs) |
673 |
| - |
674 |
| - if node.keywords or node.kwargs: |
675 |
| - raise TypeError("Function \"{name}\" does not support keyword " |
676 |
| - "arguments".format(name=res.name)) |
677 |
| - |
678 |
| - return res(*args, **kwargs) |
679 |
| - |
680 |
| - else: |
681 |
| - args = [self.visit(targ).value for targ in node.args] |
682 |
| - if node.starargs is not None: |
683 |
| - args += self.visit(node.starargs).value |
684 |
| - |
685 |
| - keywords = {} |
686 |
| - for key in node.keywords: |
687 |
| - if not isinstance(key, ast.keyword): |
688 |
| - raise ValueError("keyword error in function call " |
689 |
| - "'{func}'".format(func=node.func.id)) |
690 |
| - keywords[key.arg] = self.visit(key.value).value |
691 |
| - if node.kwargs is not None: |
692 |
| - keywords.update(self.visit(node.kwargs).value) |
693 |
| - |
694 |
| - return self.const_type(res(*args, **keywords), self.env) |
695 |
| - |
696 | 641 | def translate_In(self, op):
|
697 | 642 | return op
|
698 | 643 |
|
@@ -734,14 +679,6 @@ def visitor(x, y):
|
734 | 679 | return reduce(visitor, operands)
|
735 | 680 |
|
736 | 681 |
|
737 |
| -# ast.Call signature changed on 3.5, |
738 |
| -# conditionally change which methods is named |
739 |
| -# visit_Call depending on Python version, #11097 |
740 |
| -if compat.PY35: |
741 |
| - BaseExprVisitor.visit_Call = BaseExprVisitor.visit_Call_35 |
742 |
| -else: |
743 |
| - BaseExprVisitor.visit_Call = BaseExprVisitor.visit_Call_legacy |
744 |
| - |
745 | 682 | _python_not_supported = frozenset(['Dict', 'BoolOp', 'In', 'NotIn'])
|
746 | 683 | _numexpr_supported_calls = frozenset(_reductions + _mathops)
|
747 | 684 |
|
|
0 commit comments