Skip to content

CLN: consistent signatures for equals methods #35636

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 8 commits into from
Aug 12, 2020

Conversation

simonjayhawkins
Copy link
Member

No description provided.

"""
Determines if two IntervalIndex objects contain the same elements.
"""
if self.is_(other):
return True

# if we can coerce to an II
# then we can compare
# if we can coerce to an IntervalIndex then we can compare
Copy link
Member Author

@simonjayhawkins simonjayhawkins Aug 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from #33940

Index and Series are consistent when it comes to not being equal with other array-likes:

not necessarily in this PR, but is this behaviour consistent with other Index types

>>> x = np.linspace(0, 100, num=3)
>>> x
array([  0.,  50., 100.])
>>>
>>> idx = pd.IntervalIndex.from_breaks(x)
>>> idx
IntervalIndex([(0.0, 50.0], (50.0, 100.0]],
              closed='right',
              dtype='interval[float64]')
>>>
>>> arr = idx.values
>>> arr
<IntervalArray>
[(0.0, 50.0], (50.0, 100.0]]
Length: 2, closed: right, dtype: interval[float64]
>>>
>>> idx.equals(arr)
True
>>>
>>> arr.equals(idx)
False
>>>

@@ -762,7 +762,8 @@ def equals(self, other: "ExtensionArray") -> bool:
"""
if not type(self) == type(other):
return False
elif not self.dtype == other.dtype:
other = cast(ExtensionArray, other)
if not self.dtype == other.dtype:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this is fine, though more consisten to use is_dtype_equal no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to break the if elif to get the cast in. so this is unchanged. but agreed is_dtype_equal would be more consistent so will update.

@jreback jreback added this to the 1.2 milestone Aug 12, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of places where codecov thinks we don't have tests, in a followup can remove / test if possible..

@jreback jreback merged commit 59ffa25 into pandas-dev:master Aug 12, 2020
@simonjayhawkins
Copy link
Member Author

couple of places where codecov thinks we don't have tests, in a followup can remove / test if possible..

the code added was from static analysis. (mypy is still testing but codecov thinks we don't have tests)

so in this case we don't want to remove.

dynamic type testing has become less necessary now we are using mypy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants