Skip to content

Commit dd0fc1c

Browse files
committed
CLN: Remove StringMixin from pandas.core.computation
1 parent d3a1912 commit dd0fc1c

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

Diff for: pandas/core/computation/expr.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import pandas as pd
1515
from pandas.core import common as com
16-
from pandas.core.base import StringMixin
1716
from pandas.core.computation.common import (
1817
_BACKTICK_QUOTED_STRING, _remove_spaces_column_name)
1918
from pandas.core.computation.ops import (
@@ -701,7 +700,7 @@ def __init__(self, env, engine, parser, preparser=lambda x: x):
701700
super().__init__(env, engine, parser, preparser=preparser)
702701

703702

704-
class Expr(StringMixin):
703+
class Expr:
705704

706705
"""Object encapsulating an expression.
707706
@@ -732,7 +731,7 @@ def assigner(self):
732731
def __call__(self):
733732
return self.terms(self.env)
734733

735-
def __str__(self):
734+
def __repr__(self):
736735
return printing.pprint_thing(self.terms)
737736

738737
def __len__(self):

Diff for: pandas/core/computation/ops.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from pandas.core.dtypes.common import is_list_like, is_scalar
1414

15-
from pandas.core.base import StringMixin
1615
import pandas.core.common as com
1716
from pandas.core.computation.common import _ensure_decoded, _result_type_many
1817
from pandas.core.computation.scope import _DEFAULT_GLOBALS
@@ -46,7 +45,7 @@ def __init__(self, name, is_local):
4645
super().__init__(msg.format(name))
4746

4847

49-
class Term(StringMixin):
48+
class Term:
5049

5150
def __new__(cls, name, env, side=None, encoding=None):
5251
klass = Constant if not isinstance(name, str) else cls
@@ -67,7 +66,7 @@ def __init__(self, name, env, side=None, encoding=None):
6766
def local_name(self):
6867
return self.name.replace(_LOCAL_TAG, '')
6968

70-
def __str__(self):
69+
def __repr__(self):
7170
return pprint_thing(self.name)
7271

7372
def __call__(self, *args, **kwargs):
@@ -166,16 +165,14 @@ def _resolve_name(self):
166165
def name(self):
167166
return self.value
168167

169-
def __str__(self):
170-
# in python 2 str() of float
171-
# can truncate shorter than repr()
168+
def __repr__(self):
172169
return repr(self.name)
173170

174171

175172
_bool_op_map = {'not': '~', 'and': '&', 'or': '|'}
176173

177174

178-
class Op(StringMixin):
175+
class Op:
179176

180177
"""Hold an operator of arbitrary arity
181178
"""
@@ -188,7 +185,7 @@ def __init__(self, op, operands, *args, **kwargs):
188185
def __iter__(self):
189186
return iter(self.operands)
190187

191-
def __str__(self):
188+
def __repr__(self):
192189
"""Print a generic n-ary operator and its operands using infix
193190
notation"""
194191
# recurse over the operands
@@ -506,7 +503,7 @@ def __call__(self, env):
506503
operand = self.operand(env)
507504
return self.func(operand)
508505

509-
def __str__(self):
506+
def __repr__(self):
510507
return pprint_thing('{0}({1})'.format(self.op, self.operand))
511508

512509
@property
@@ -531,7 +528,7 @@ def __call__(self, env):
531528
with np.errstate(all='ignore'):
532529
return self.func.func(*operands)
533530

534-
def __str__(self):
531+
def __repr__(self):
535532
operands = map(str, self.operands)
536533
return pprint_thing('{0}({1})'.format(self.op, ','.join(operands)))
537534

Diff for: pandas/core/computation/pytables.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pandas.core.dtypes.common import is_list_like
1212

1313
import pandas as pd
14-
from pandas.core.base import StringMixin
1514
import pandas.core.common as com
1615
from pandas.core.computation import expr, ops
1716
from pandas.core.computation.common import _ensure_decoded
@@ -36,7 +35,7 @@ class Term(ops.Term):
3635

3736
def __new__(cls, name, env, side=None, encoding=None):
3837
klass = Constant if not isinstance(name, str) else cls
39-
supr_new = StringMixin.__new__
38+
supr_new = object.__new__
4039
return supr_new(klass)
4140

4241
def __init__(self, name, env, side=None, encoding=None):
@@ -230,7 +229,7 @@ def convert_values(self):
230229

231230
class FilterBinOp(BinOp):
232231

233-
def __str__(self):
232+
def __repr__(self):
234233
return pprint_thing("[Filter : [{lhs}] -> [{op}]"
235234
.format(lhs=self.filter[0], op=self.filter[1]))
236235

@@ -302,7 +301,7 @@ def evaluate(self):
302301

303302
class ConditionBinOp(BinOp):
304303

305-
def __str__(self):
304+
def __repr__(self):
306305
return pprint_thing("[Condition : [{cond}]]"
307306
.format(cond=self.condition))
308307

@@ -549,7 +548,7 @@ def __init__(self, where, queryables=None, encoding=None, scope_level=0):
549548
encoding=encoding)
550549
self.terms = self.parse()
551550

552-
def __str__(self):
551+
def __repr__(self):
553552
if self.terms is not None:
554553
return pprint_thing(self.terms)
555554
return pprint_thing(self.expr)

0 commit comments

Comments
 (0)