Skip to content

Minor: Address review comments from #218 #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions text_extensions_for_pandas/array/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
from pandas.api.types import is_bool_dtype
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
try:
from pandas.core.dtypes.generic import ABCIndexClass
from pandas.core.dtypes.generic import ABCIndex
except ImportError:
# ABCIndexClass changed to ABCIndex in Pandas 1.3
# noinspection PyUnresolvedReferences
from pandas.core.dtypes.generic import ABCIndex
ABCIndexClass = ABCIndex
from pandas.core.dtypes.generic import ABCIndexClass as ABCIndex
from pandas.core.indexers import check_array_indexer

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

Expand Down Expand Up @@ -523,7 +522,7 @@ def __eq__(self, other):

:return: Returns a boolean mask indicating which rows match `other`.
"""
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
# Rely on pandas to unbox and dispatch to us.
return NotImplemented
if isinstance(other, Span):
Expand All @@ -550,7 +549,7 @@ def __eq__(self, other):
"'{}' and '{}'".format(type(self), type(other)))

def __ne__(self, other):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
# Rely on pandas to unbox and dispatch to us.
return NotImplemented
return ~(self == other)
Expand Down Expand Up @@ -760,7 +759,7 @@ def __lt__(self, other):
`other`. span1 < span2 if span1.end <= span2.begin and both spans are over
the same target text.
"""
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
# Rely on pandas to unbox and dispatch to us.
return NotImplemented
elif not isinstance(other, (Span, SpanArray)):
Expand All @@ -772,7 +771,7 @@ def __lt__(self, other):
return np.logical_and(offsets_mask, text_mask)

def __gt__(self, other):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
# Rely on pandas to unbox and dispatch to us.
return NotImplemented
if isinstance(other, (SpanArray, Span)):
Expand Down
7 changes: 3 additions & 4 deletions text_extensions_for_pandas/array/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
from pandas.compat import set_function_name
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
try:
from pandas.core.dtypes.generic import ABCIndexClass
from pandas.core.dtypes.generic import ABCIndex
except ImportError:
# ABCIndexClass changed to ABCIndex in Pandas 1.3
# noinspection PyUnresolvedReferences
from pandas.core.dtypes.generic import ABCIndex
ABCIndexClass = ABCIndex
from pandas.core.dtypes.generic import ABCIndexClass as ABCIndex
from pandas.core.indexers import check_array_indexer, validate_indices

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

if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
# Rely on pandas to unbox and dispatch to us.
return NotImplemented

Expand Down
7 changes: 3 additions & 4 deletions text_extensions_for_pandas/array/token_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
from pandas.api.types import is_bool_dtype
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
try:
from pandas.core.dtypes.generic import ABCIndexClass
from pandas.core.dtypes.generic import ABCIndex
except ImportError:
# ABCIndexClass changed to ABCIndex in Pandas 1.3
# noinspection PyUnresolvedReferences
from pandas.core.dtypes.generic import ABCIndex
ABCIndexClass = ABCIndex
from pandas.core.dtypes.generic import ABCIndexClass as ABCIndex

from pandas.core.indexers import check_array_indexer

Expand Down Expand Up @@ -504,7 +503,7 @@ def __eq__(self, other):

:return: Returns a boolean mask indicating which rows match `other`.
"""
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndex)):
# Rely on pandas to unbox and dispatch to us.
return NotImplemented
elif (isinstance(other, TokenSpanArray) and len(self) == len(other)
Expand Down