Skip to content

CLN: cleaning core/common.py #12804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RET=0

if [ "$LINT" ]; then
echo "Linting"
for path in 'core' 'indexes' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
for path in 'core' 'indexes' 'types' 'formats' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
do
echo "linting -> pandas/$path"
flake8 pandas/$path --filename '*.py'
Expand Down
5 changes: 3 additions & 2 deletions pandas/computation/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

from pandas import compat
from pandas.compat import DeepChainMap, map
from pandas.core import common as com
import pandas.core.common as com
import pandas.formats.printing as printing
from pandas.computation.align import _align, _reconstruct_object
from pandas.computation.ops import (UndefinedVariableError,
_mathops, _reductions)
Expand Down Expand Up @@ -55,7 +56,7 @@ def convert(self):

Defaults to return the expression as a string.
"""
return com.pprint_thing(self.expr)
return printing.pprint_thing(self.expr)

def evaluate(self):
"""Run the engine on the expression
Expand Down
4 changes: 2 additions & 2 deletions pandas/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import warnings
import tokenize
from pandas.core import common as com
from pandas.formats.printing import pprint_thing
from pandas.computation import _NUMEXPR_INSTALLED
from pandas.computation.expr import Expr, _parsers, tokenize_string
from pandas.computation.scope import _ensure_scope
Expand Down Expand Up @@ -108,7 +108,7 @@ def _convert_expression(expr):
ValueError
* If the expression is empty.
"""
s = com.pprint_thing(expr)
s = pprint_thing(expr)
_check_expression(s)
return s

Expand Down
3 changes: 2 additions & 1 deletion pandas/computation/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pandas.compat import StringIO, lmap, zip, reduce, string_types
from pandas.core.base import StringMixin
from pandas.core import common as com
import pandas.formats.printing as printing
from pandas.tools.util import compose
from pandas.computation.ops import (_cmp_ops_syms, _bool_ops_syms,
_arith_ops_syms, _unary_ops_syms, is_term)
Expand Down Expand Up @@ -716,7 +717,7 @@ def __call__(self):
return self.terms(self.env)

def __unicode__(self):
return com.pprint_thing(self.terms)
return printing.pprint_thing(self.terms)

def __len__(self):
return len(self.expr)
Expand Down
21 changes: 11 additions & 10 deletions pandas/computation/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pandas as pd
from pandas.compat import PY3, string_types, text_type
import pandas.core.common as com
from pandas.formats.printing import pprint_thing, pprint_thing_encoded
import pandas.lib as lib
from pandas.core.base import StringMixin
from pandas.computation.common import _ensure_decoded, _result_type_many
Expand Down Expand Up @@ -62,7 +63,7 @@ def local_name(self):
return self.name.replace(_LOCAL_TAG, '')

def __unicode__(self):
return com.pprint_thing(self.name)
return pprint_thing(self.name)

def __call__(self, *args, **kwargs):
return self.value
Expand Down Expand Up @@ -118,9 +119,9 @@ def type(self):

@property
def raw(self):
return com.pprint_thing('{0}(name={1!r}, type={2})'
''.format(self.__class__.__name__, self.name,
self.type))
return pprint_thing('{0}(name={1!r}, type={2})'
''.format(self.__class__.__name__, self.name,
self.type))

@property
def is_datetime(self):
Expand Down Expand Up @@ -186,9 +187,9 @@ def __unicode__(self):
"""Print a generic n-ary operator and its operands using infix
notation"""
# recurse over the operands
parened = ('({0})'.format(com.pprint_thing(opr))
parened = ('({0})'.format(pprint_thing(opr))
for opr in self.operands)
return com.pprint_thing(' {0} '.format(self.op).join(parened))
return pprint_thing(' {0} '.format(self.op).join(parened))

@property
def return_type(self):
Expand Down Expand Up @@ -390,10 +391,10 @@ def convert_values(self):
"""
def stringify(value):
if self.encoding is not None:
encoder = partial(com.pprint_thing_encoded,
encoder = partial(pprint_thing_encoded,
encoding=self.encoding)
else:
encoder = com.pprint_thing
encoder = pprint_thing
return encoder(value)

lhs, rhs = self.lhs, self.rhs
Expand Down Expand Up @@ -491,7 +492,7 @@ def __call__(self, env):
return self.func(operand)

def __unicode__(self):
return com.pprint_thing('{0}({1})'.format(self.op, self.operand))
return pprint_thing('{0}({1})'.format(self.op, self.operand))

@property
def return_type(self):
Expand All @@ -516,7 +517,7 @@ def __call__(self, env):

def __unicode__(self):
operands = map(str, self.operands)
return com.pprint_thing('{0}({1})'.format(self.op, ','.join(operands)))
return pprint_thing('{0}({1})'.format(self.op, ','.join(operands)))


class FuncNode(object):
Expand Down
17 changes: 9 additions & 8 deletions pandas/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from datetime import datetime, timedelta
import numpy as np
import pandas as pd
import pandas.core.common as com
from pandas.compat import u, string_types, DeepChainMap
from pandas.core.base import StringMixin
import pandas.core.common as com
from pandas.formats.printing import pprint_thing, pprint_thing_encoded
from pandas.computation import expr, ops
from pandas.computation.ops import is_term, UndefinedVariableError
from pandas.computation.expr import BaseExprVisitor
Expand Down Expand Up @@ -169,10 +170,10 @@ def convert_value(self, v):

def stringify(value):
if self.encoding is not None:
encoder = partial(com.pprint_thing_encoded,
encoder = partial(pprint_thing_encoded,
encoding=self.encoding)
else:
encoder = com.pprint_thing
encoder = pprint_thing
return encoder(value)

kind = _ensure_decoded(self.kind)
Expand Down Expand Up @@ -224,8 +225,8 @@ def convert_values(self):
class FilterBinOp(BinOp):

def __unicode__(self):
return com.pprint_thing("[Filter : [{0}] -> "
"[{1}]".format(self.filter[0], self.filter[1]))
return pprint_thing("[Filter : [{0}] -> "
"[{1}]".format(self.filter[0], self.filter[1]))

def invert(self):
""" invert the filter """
Expand Down Expand Up @@ -296,7 +297,7 @@ def evaluate(self):
class ConditionBinOp(BinOp):

def __unicode__(self):
return com.pprint_thing("[Condition : [{0}]]".format(self.condition))
return pprint_thing("[Condition : [{0}]]".format(self.condition))

def invert(self):
""" invert the condition """
Expand Down Expand Up @@ -571,8 +572,8 @@ def convert(v):

def __unicode__(self):
if self.terms is not None:
return com.pprint_thing(self.terms)
return com.pprint_thing(self.expr)
return pprint_thing(self.terms)
return pprint_thing(self.expr)

def evaluate(self):
""" create and return the numexpr condition and filter """
Expand Down
Loading