Skip to content

Commit d3c09fb

Browse files
authored
Merge pull request #222 from frreiss/branch-abc
Minor: Address review comments from #218
2 parents b75c406 + d308343 commit d3c09fb

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

text_extensions_for_pandas/array/span.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232
from pandas.api.types import is_bool_dtype
3333
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
3434
try:
35-
from pandas.core.dtypes.generic import ABCIndexClass
35+
from pandas.core.dtypes.generic import ABCIndex
3636
except ImportError:
3737
# ABCIndexClass changed to ABCIndex in Pandas 1.3
3838
# noinspection PyUnresolvedReferences
39-
from pandas.core.dtypes.generic import ABCIndex
40-
ABCIndexClass = ABCIndex
39+
from pandas.core.dtypes.generic import ABCIndexClass as ABCIndex
4140
from pandas.core.indexers import check_array_indexer
4241

4342
# Internal imports
@@ -82,7 +81,7 @@ def __add__(self, other) -> Union["Span", "SpanArray"]:
8281
:param other: Span or SpanArray
8382
:return: minimal span (or array of spans) that covers both inputs.
8483
"""
85-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
84+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
8685
# Rely on pandas to unbox and dispatch to us.
8786
return NotImplemented
8887

@@ -523,7 +522,7 @@ def __eq__(self, other):
523522
524523
:return: Returns a boolean mask indicating which rows match `other`.
525524
"""
526-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
525+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
527526
# Rely on pandas to unbox and dispatch to us.
528527
return NotImplemented
529528
if isinstance(other, Span):
@@ -550,7 +549,7 @@ def __eq__(self, other):
550549
"'{}' and '{}'".format(type(self), type(other)))
551550

552551
def __ne__(self, other):
553-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
552+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
554553
# Rely on pandas to unbox and dispatch to us.
555554
return NotImplemented
556555
return ~(self == other)
@@ -760,7 +759,7 @@ def __lt__(self, other):
760759
`other`. span1 < span2 if span1.end <= span2.begin and both spans are over
761760
the same target text.
762761
"""
763-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
762+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
764763
# Rely on pandas to unbox and dispatch to us.
765764
return NotImplemented
766765
elif not isinstance(other, (Span, SpanArray)):
@@ -772,7 +771,7 @@ def __lt__(self, other):
772771
return np.logical_and(offsets_mask, text_mask)
773772

774773
def __gt__(self, other):
775-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
774+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
776775
# Rely on pandas to unbox and dispatch to us.
777776
return NotImplemented
778777
if isinstance(other, (SpanArray, Span)):

text_extensions_for_pandas/array/tensor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
from pandas.compat import set_function_name
3232
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
3333
try:
34-
from pandas.core.dtypes.generic import ABCIndexClass
34+
from pandas.core.dtypes.generic import ABCIndex
3535
except ImportError:
3636
# ABCIndexClass changed to ABCIndex in Pandas 1.3
3737
# noinspection PyUnresolvedReferences
38-
from pandas.core.dtypes.generic import ABCIndex
39-
ABCIndexClass = ABCIndex
38+
from pandas.core.dtypes.generic import ABCIndexClass as ABCIndex
4039
from pandas.core.indexers import check_array_indexer, validate_indices
4140

4241
""" Begin Patching of ExtensionArrayFormatter """
@@ -219,7 +218,7 @@ def _create_method(cls, op, coerce_to_dtype=True, result_dtype=None):
219218
def _binop(self, other):
220219
lvalues = self._tensor
221220

222-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
221+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
223222
# Rely on pandas to unbox and dispatch to us.
224223
return NotImplemented
225224

text_extensions_for_pandas/array/token_span.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@
3131
from pandas.api.types import is_bool_dtype
3232
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
3333
try:
34-
from pandas.core.dtypes.generic import ABCIndexClass
34+
from pandas.core.dtypes.generic import ABCIndex
3535
except ImportError:
3636
# ABCIndexClass changed to ABCIndex in Pandas 1.3
3737
# noinspection PyUnresolvedReferences
38-
from pandas.core.dtypes.generic import ABCIndex
39-
ABCIndexClass = ABCIndex
38+
from pandas.core.dtypes.generic import ABCIndexClass as ABCIndex
4039

4140
from pandas.core.indexers import check_array_indexer
4241

@@ -504,7 +503,7 @@ def __eq__(self, other):
504503
505504
:return: Returns a boolean mask indicating which rows match `other`.
506505
"""
507-
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
506+
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
508507
# Rely on pandas to unbox and dispatch to us.
509508
return NotImplemented
510509
elif (isinstance(other, TokenSpanArray) and len(self) == len(other)

0 commit comments

Comments
 (0)