Skip to content

Commit 46fc9dc

Browse files
committed
Fixed problem with span op comparison tests
1 parent cfacbb8 commit 46fc9dc

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

text_extensions_for_pandas/array/span.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ def __eq__(self, other):
446446
"'{}' and '{}'".format(type(self), type(other)))
447447

448448
def __ne__(self, other):
449+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
450+
# Rely on pandas to unbox and dispatch to us.
451+
return NotImplemented
449452
return ~(self == other)
450453

451454
def __hash__(self):

text_extensions_for_pandas/array/test_span.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,15 @@ def _compare_other(self, s, data, op_name, other):
542542
# Compare with scalar
543543
other = data[0]
544544

545-
# TODO check result
546-
op(data, other)
547-
548-
@pytest.mark.skip("assert result is NotImplemented")
549-
def test_direct_arith_with_series_returns_not_implemented(self, data):
550-
pass
545+
result = op(data, other)
546+
547+
if op_name in ["__gt__", "__ne__"]:
548+
assert not result[0]
549+
assert result[1:].all()
550+
elif op_name in ["__lt__", "__eq__"]:
551+
assert not result.all()
552+
else:
553+
raise NotImplementedError("Unknown Operation Comparison")
551554

552555

553556
class TestPandasReshaping(base.BaseReshapingTests):

text_extensions_for_pandas/array/test_token_span.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,15 @@ def _compare_other(self, s, data, op_name, other):
560560
# Compare with scalar
561561
other = data[0]
562562

563-
# TODO check result
564-
op(data, other)
563+
result = op(data, other)
565564

566-
@pytest.mark.skip("assert result is NotImplemented")
567-
def test_direct_arith_with_series_returns_not_implemented(self, data):
568-
pass
565+
if op_name in ["__gt__", "__ne__"]:
566+
assert not result[0]
567+
assert result[1:].all()
568+
elif op_name in ["__lt__", "__eq__"]:
569+
assert not result.all()
570+
else:
571+
raise NotImplementedError("Unknown Operation Comparison")
569572

570573

571574
class TestPandasReshaping(base.BaseReshapingTests):

0 commit comments

Comments
 (0)