Skip to content

Commit d250d64

Browse files
committed
CLN: More autopep8
1 parent 822178e commit d250d64

24 files changed

+183
-86
lines changed

pandas/compat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def wrapper(cls):
245245

246246

247247
class _OrderedDict(dict):
248+
248249
"""Dictionary that remembers insertion order"""
249250
# An inherited dict maps keys to values.
250251
# The inherited dict provides __getitem__, __len__, __contains__, and get.
@@ -505,6 +506,7 @@ def viewitems(self):
505506

506507

507508
class _Counter(dict):
509+
508510
"""Dict subclass for counting hashable objects. Sometimes called a bag
509511
or multiset. Elements are stored as dictionary keys and their counts
510512
are stored as dictionary values.

pandas/computation/engines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
class AbstractEngine(object):
13+
1314
"""Object serving as a base class for all engines."""
1415

1516
__metaclass__ = abc.ABCMeta
@@ -73,6 +74,7 @@ def _evaluate(self):
7374

7475

7576
class NumExprEngine(AbstractEngine):
77+
7678
"""NumExpr engine class"""
7779
has_neg_frac = True
7880

@@ -105,6 +107,7 @@ def _evaluate(self):
105107

106108

107109
class PythonEngine(AbstractEngine):
110+
108111
"""Evaluate an expression in Python space.
109112
110113
Mostly for testing purposes.

pandas/computation/expr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def _raw_hex_id(obj, pad_size=2):
7070

7171

7272
class Scope(StringMixin):
73+
7374
"""Object to hold scope, with a few bells to deal with some custom syntax
7475
added by pandas.
7576
@@ -324,6 +325,7 @@ def _node_not_implemented(node_name, cls):
324325
"""Return a function that raises a NotImplementedError with a passed node
325326
name.
326327
"""
328+
327329
def f(self, *args, **kwargs):
328330
raise NotImplementedError("{0!r} nodes are not "
329331
"implemented".format(node_name))
@@ -356,6 +358,7 @@ def _op_maker(op_class, op_symbol):
356358
-------
357359
f : callable
358360
"""
361+
359362
def f(self, node, *args, **kwargs):
360363
"""Return a partial function with an Op subclass with an operator
361364
already passed.
@@ -389,6 +392,7 @@ def f(cls):
389392
@disallow(_unsupported_nodes)
390393
@add_ops(_op_classes)
391394
class BaseExprVisitor(ast.NodeVisitor):
395+
392396
"""Custom ast walker. Parsers of other engines should subclass this class
393397
if necessary.
394398
@@ -710,19 +714,22 @@ def visitor(x, y):
710714
(_boolop_nodes | frozenset(['BoolOp', 'Attribute', 'In', 'NotIn',
711715
'Tuple'])))
712716
class PandasExprVisitor(BaseExprVisitor):
717+
713718
def __init__(self, env, engine, parser,
714719
preparser=lambda x: _replace_locals(_replace_booleans(x))):
715720
super(PandasExprVisitor, self).__init__(env, engine, parser, preparser)
716721

717722

718723
@disallow(_unsupported_nodes | _python_not_supported | frozenset(['Not']))
719724
class PythonExprVisitor(BaseExprVisitor):
725+
720726
def __init__(self, env, engine, parser, preparser=lambda x: x):
721727
super(PythonExprVisitor, self).__init__(env, engine, parser,
722728
preparser=preparser)
723729

724730

725731
class Expr(StringMixin):
732+
726733
"""Object encapsulating an expression.
727734
728735
Parameters
@@ -734,6 +741,7 @@ class Expr(StringMixin):
734741
truediv : bool, optional, default True
735742
level : int, optional, default 2
736743
"""
744+
737745
def __init__(self, expr, engine='numexpr', parser='pandas', env=None,
738746
truediv=True, level=2):
739747
self.expr = expr

pandas/computation/ops.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828

2929
class UndefinedVariableError(NameError):
30+
3031
"""NameError subclass for local variables."""
32+
3133
def __init__(self, *args):
3234
msg = 'name {0!r} is not defined'
3335
subbed = _TAG_RE.sub('', args[0])
@@ -51,6 +53,7 @@ def _possibly_update_key(d, value, old_key, new_key=None):
5153

5254

5355
class Term(StringMixin):
56+
5457
def __new__(cls, name, env, side=None, encoding=None):
5558
klass = Constant if not isinstance(name, string_types) else cls
5659
supr_new = super(Term, klass).__new__
@@ -195,6 +198,7 @@ def ndim(self):
195198

196199

197200
class Constant(Term):
201+
198202
def __init__(self, value, env, side=None, encoding=None):
199203
super(Constant, self).__init__(value, env, side=side,
200204
encoding=encoding)
@@ -211,8 +215,10 @@ def name(self):
211215

212216

213217
class Op(StringMixin):
218+
214219
"""Hold an operator of unknown arity
215220
"""
221+
216222
def __init__(self, op, operands, *args, **kwargs):
217223
self.op = _bool_op_map.get(op, op)
218224
self.operands = operands
@@ -328,6 +334,7 @@ def is_term(obj):
328334

329335

330336
class BinOp(Op):
337+
331338
"""Hold a binary operator and its operands
332339
333340
Parameters
@@ -336,6 +343,7 @@ class BinOp(Op):
336343
left : Term or Op
337344
right : Term or Op
338345
"""
346+
339347
def __init__(self, op, lhs, rhs, **kwargs):
340348
super(BinOp, self).__init__(op, (lhs, rhs))
341349
self.lhs = lhs
@@ -452,6 +460,7 @@ def _disallow_scalar_only_bool_ops(self):
452460

453461

454462
class Div(BinOp):
463+
455464
"""Div operator to special case casting.
456465
457466
Parameters
@@ -462,6 +471,7 @@ class Div(BinOp):
462471
Whether or not to use true division. With Python 3 this happens
463472
regardless of the value of ``truediv``.
464473
"""
474+
465475
def __init__(self, lhs, rhs, truediv=True, *args, **kwargs):
466476
super(Div, self).__init__('/', lhs, rhs, *args, **kwargs)
467477

@@ -475,6 +485,7 @@ def __init__(self, lhs, rhs, truediv=True, *args, **kwargs):
475485

476486

477487
class UnaryOp(Op):
488+
478489
"""Hold a unary operator and its operands
479490
480491
Parameters
@@ -489,6 +500,7 @@ class UnaryOp(Op):
489500
ValueError
490501
* If no function associated with the passed operator token is found.
491502
"""
503+
492504
def __init__(self, op, operand):
493505
super(UnaryOp, self).__init__(op, (operand,))
494506
self.operand = operand

pandas/computation/pytables.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, gbls=None, lcls=None, queryables=None, level=1):
3030

3131

3232
class Term(ops.Term):
33+
3334
def __new__(cls, name, env, side=None, encoding=None):
3435
klass = Constant if not isinstance(name, string_types) else cls
3536
supr_new = StringMixin.__new__
@@ -57,6 +58,7 @@ def value(self):
5758

5859

5960
class Constant(Term):
61+
6062
def __init__(self, value, env, side=None, encoding=None):
6163
super(Constant, self).__init__(value, env, side=side,
6264
encoding=encoding)
@@ -292,9 +294,9 @@ def __unicode__(self):
292294

293295
def invert(self):
294296
""" invert the condition """
295-
#if self.condition is not None:
297+
# if self.condition is not None:
296298
# self.condition = "~(%s)" % self.condition
297-
#return self
299+
# return self
298300
raise NotImplementedError("cannot use an invert condition when "
299301
"passing to numexpr")
300302

0 commit comments

Comments
 (0)