Skip to content

Commit 0632168

Browse files
committed
CLN: cleaning core/common.py
partial on #12503 Author: Jeff Reback <[email protected]> Closes #12804 from jreback/types and squashes the following commits: 6e2e187 [Jeff Reback] TST: relocate tests to pandas/tests/formats,types faf581a [Jeff Reback] CLN: extension dtypes need to be refernced directly bd1fde4 [Jeff Reback] CLN: move pprint_thing to printing 2081048 [Jeff Reback] CLN: add formats/printing.py, strip from common.py 3b027af [Jeff Reback] CLN: move core/formats.py and core/style.py to formats ae5e8fb [Jeff Reback] CLN: remove _pickle_array, _unpkckle_array from common.py b42a2c9 [Jeff Reback] CLN: move diff, take to algorithms.py a214e82 [Jeff Reback] CLN: move com.mask_missing to missing e77be39 [Jeff Reback] CLN: move ABC to types/generic.py 534dcc7 [Jeff Reback] CLN: create pandas/types CLN: move core/dtypes.py -> types
1 parent 3ac8c85 commit 0632168

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1976
-1887
lines changed

ci/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RET=0
88

99
if [ "$LINT" ]; then
1010
echo "Linting"
11-
for path in 'core' 'indexes' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
11+
for path in 'core' 'indexes' 'types' 'formats' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
1212
do
1313
echo "linting -> pandas/$path"
1414
flake8 pandas/$path --filename '*.py'

pandas/computation/engines.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
from pandas import compat
99
from pandas.compat import DeepChainMap, map
10-
from pandas.core import common as com
10+
import pandas.core.common as com
11+
import pandas.formats.printing as printing
1112
from pandas.computation.align import _align, _reconstruct_object
1213
from pandas.computation.ops import (UndefinedVariableError,
1314
_mathops, _reductions)
@@ -55,7 +56,7 @@ def convert(self):
5556
5657
Defaults to return the expression as a string.
5758
"""
58-
return com.pprint_thing(self.expr)
59+
return printing.pprint_thing(self.expr)
5960

6061
def evaluate(self):
6162
"""Run the engine on the expression

pandas/computation/eval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import warnings
77
import tokenize
8-
from pandas.core import common as com
8+
from pandas.formats.printing import pprint_thing
99
from pandas.computation import _NUMEXPR_INSTALLED
1010
from pandas.computation.expr import Expr, _parsers, tokenize_string
1111
from pandas.computation.scope import _ensure_scope
@@ -108,7 +108,7 @@ def _convert_expression(expr):
108108
ValueError
109109
* If the expression is empty.
110110
"""
111-
s = com.pprint_thing(expr)
111+
s = pprint_thing(expr)
112112
_check_expression(s)
113113
return s
114114

pandas/computation/expr.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pandas.compat import StringIO, lmap, zip, reduce, string_types
1212
from pandas.core.base import StringMixin
1313
from pandas.core import common as com
14+
import pandas.formats.printing as printing
1415
from pandas.tools.util import compose
1516
from pandas.computation.ops import (_cmp_ops_syms, _bool_ops_syms,
1617
_arith_ops_syms, _unary_ops_syms, is_term)
@@ -716,7 +717,7 @@ def __call__(self):
716717
return self.terms(self.env)
717718

718719
def __unicode__(self):
719-
return com.pprint_thing(self.terms)
720+
return printing.pprint_thing(self.terms)
720721

721722
def __len__(self):
722723
return len(self.expr)

pandas/computation/ops.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pandas as pd
1111
from pandas.compat import PY3, string_types, text_type
1212
import pandas.core.common as com
13+
from pandas.formats.printing import pprint_thing, pprint_thing_encoded
1314
import pandas.lib as lib
1415
from pandas.core.base import StringMixin
1516
from pandas.computation.common import _ensure_decoded, _result_type_many
@@ -62,7 +63,7 @@ def local_name(self):
6263
return self.name.replace(_LOCAL_TAG, '')
6364

6465
def __unicode__(self):
65-
return com.pprint_thing(self.name)
66+
return pprint_thing(self.name)
6667

6768
def __call__(self, *args, **kwargs):
6869
return self.value
@@ -118,9 +119,9 @@ def type(self):
118119

119120
@property
120121
def raw(self):
121-
return com.pprint_thing('{0}(name={1!r}, type={2})'
122-
''.format(self.__class__.__name__, self.name,
123-
self.type))
122+
return pprint_thing('{0}(name={1!r}, type={2})'
123+
''.format(self.__class__.__name__, self.name,
124+
self.type))
124125

125126
@property
126127
def is_datetime(self):
@@ -186,9 +187,9 @@ def __unicode__(self):
186187
"""Print a generic n-ary operator and its operands using infix
187188
notation"""
188189
# recurse over the operands
189-
parened = ('({0})'.format(com.pprint_thing(opr))
190+
parened = ('({0})'.format(pprint_thing(opr))
190191
for opr in self.operands)
191-
return com.pprint_thing(' {0} '.format(self.op).join(parened))
192+
return pprint_thing(' {0} '.format(self.op).join(parened))
192193

193194
@property
194195
def return_type(self):
@@ -390,10 +391,10 @@ def convert_values(self):
390391
"""
391392
def stringify(value):
392393
if self.encoding is not None:
393-
encoder = partial(com.pprint_thing_encoded,
394+
encoder = partial(pprint_thing_encoded,
394395
encoding=self.encoding)
395396
else:
396-
encoder = com.pprint_thing
397+
encoder = pprint_thing
397398
return encoder(value)
398399

399400
lhs, rhs = self.lhs, self.rhs
@@ -491,7 +492,7 @@ def __call__(self, env):
491492
return self.func(operand)
492493

493494
def __unicode__(self):
494-
return com.pprint_thing('{0}({1})'.format(self.op, self.operand))
495+
return pprint_thing('{0}({1})'.format(self.op, self.operand))
495496

496497
@property
497498
def return_type(self):
@@ -516,7 +517,7 @@ def __call__(self, env):
516517

517518
def __unicode__(self):
518519
operands = map(str, self.operands)
519-
return com.pprint_thing('{0}({1})'.format(self.op, ','.join(operands)))
520+
return pprint_thing('{0}({1})'.format(self.op, ','.join(operands)))
520521

521522

522523
class FuncNode(object):

pandas/computation/pytables.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
from datetime import datetime, timedelta
88
import numpy as np
99
import pandas as pd
10+
import pandas.core.common as com
1011
from pandas.compat import u, string_types, DeepChainMap
1112
from pandas.core.base import StringMixin
12-
import pandas.core.common as com
13+
from pandas.formats.printing import pprint_thing, pprint_thing_encoded
1314
from pandas.computation import expr, ops
1415
from pandas.computation.ops import is_term, UndefinedVariableError
1516
from pandas.computation.expr import BaseExprVisitor
@@ -169,10 +170,10 @@ def convert_value(self, v):
169170

170171
def stringify(value):
171172
if self.encoding is not None:
172-
encoder = partial(com.pprint_thing_encoded,
173+
encoder = partial(pprint_thing_encoded,
173174
encoding=self.encoding)
174175
else:
175-
encoder = com.pprint_thing
176+
encoder = pprint_thing
176177
return encoder(value)
177178

178179
kind = _ensure_decoded(self.kind)
@@ -224,8 +225,8 @@ def convert_values(self):
224225
class FilterBinOp(BinOp):
225226

226227
def __unicode__(self):
227-
return com.pprint_thing("[Filter : [{0}] -> "
228-
"[{1}]".format(self.filter[0], self.filter[1]))
228+
return pprint_thing("[Filter : [{0}] -> "
229+
"[{1}]".format(self.filter[0], self.filter[1]))
229230

230231
def invert(self):
231232
""" invert the filter """
@@ -296,7 +297,7 @@ def evaluate(self):
296297
class ConditionBinOp(BinOp):
297298

298299
def __unicode__(self):
299-
return com.pprint_thing("[Condition : [{0}]]".format(self.condition))
300+
return pprint_thing("[Condition : [{0}]]".format(self.condition))
300301

301302
def invert(self):
302303
""" invert the condition """
@@ -571,8 +572,8 @@ def convert(v):
571572

572573
def __unicode__(self):
573574
if self.terms is not None:
574-
return com.pprint_thing(self.terms)
575-
return com.pprint_thing(self.expr)
575+
return pprint_thing(self.terms)
576+
return pprint_thing(self.expr)
576577

577578
def evaluate(self):
578579
""" create and return the numexpr condition and filter """

0 commit comments

Comments
 (0)