Skip to content

Conversation

@simonjayhawkins
Copy link
Member

No description provided.


# 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
>>>

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