Skip to content

BUG: Inconsistent behavior in Index.difference #35231

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
Jul 16, 2020

Conversation

simonjayhawkins
Copy link
Member

@simonjayhawkins simonjayhawkins added Index Related to the Index class or subclasses Numeric Operations Arithmetic, Comparison, and Logical operations Bug labels Jul 11, 2020
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Generally this looks good to me.

But can you check how well Float64Index equals is covered in the tests?
For example, you added an assert that floats and strings are not equal, but if we preserve behaviour, we should ensure that float / ints and float / object ints keep evaluating to True:

In [18]: pd.Index([1, 2]).equals(pd.Index([1., 2.])) 
Out[18]: True

In [20]: pd.Index([1, 2]).equals(pd.Index([1., 2.], dtype=object)) 
Out[20]: True

(both of those will work fine as well with the new implementaiton, I think (since array_equivalent right now doesn't check the exact dtype for those, only equality), but just want to ensure it is tested)

@simonjayhawkins
Copy link
Member Author

Thanks @jorisvandenbossche for reviewing this. have extended an existing test


i2 = Float64Index([1.0, np.nan])
assert i.equals(i2)
i4 = Float64Index([1.0, np.nan])
Copy link
Contributor

Choose a reason for hiding this comment

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

possible to paramaterize?


def test_float64_index_equals():
# https://github.com/pandas-dev/pandas/issues/35217
float_index = pd.Index([1.0, 2, 3])
Copy link
Contributor

Choose a reason for hiding this comment

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

ideally parameterize


def test_float64_index_difference():
# https://github.com/pandas-dev/pandas/issues/35217
float_index = pd.Index([1.0, 2, 3])
Copy link
Contributor

Choose a reason for hiding this comment

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

same

@jreback jreback added this to the 1.1 milestone Jul 13, 2020
@TomAugspurger
Copy link
Contributor

@simonjayhawkins are you able to update here?

@simonjayhawkins
Copy link
Member Author

@simonjayhawkins are you able to update here?

i've parameterised the additional tests added in response to #35231 (review)

not sure parameterise makes sense for the issue regression tests (parameterise on order i.e index.equals(other) and other.equals(index) or include the indexes in the parameterisation?)

have pushed changes but not yet appearing here.

@simonjayhawkins
Copy link
Member Author

have pushed changes but not yet appearing here.

The changes are now showing, but ci not running.

@simonjayhawkins
Copy link
Member Author

azure and travis triggered, but not github actions. will push another empty commit later if github actions doesn't run.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

All green.

@jreback
Copy link
Contributor

jreback commented Jul 15, 2020

lgtm. can merge on green.

@simonjayhawkins simonjayhawkins merged commit 1b16a79 into pandas-dev:master Jul 16, 2020
@simonjayhawkins simonjayhawkins deleted the index-equals branch July 16, 2020 09:57
fangchenli pushed a commit to fangchenli/pandas that referenced this pull request Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Index Related to the Index class or subclasses Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inconsistent behavior in Index.difference
4 participants