-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: assert_index_equal ignoring names when check_order is false #47330
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
Conversation
pandas/core/indexes/api.py
Outdated
) | ||
else: | ||
index = Index(array_sorted, name=index.name, dtype=index.dtype) | ||
except TypeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe only have the safe_sort call in the try block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit tricky, since array_sorted does not exist in the except block and we don't want to caste the Index again to an Index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with an else
block we would only cast if the safe_sort succeeded? (i.e. Index values are unique)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much. I am always forgetting that...
Changed the code
doc/source/whatsnew/v1.5.0.rst
Outdated
@@ -935,7 +935,7 @@ Other | |||
|
|||
.. ***DO NOT USE THIS SECTION*** | |||
|
|||
- | |||
- Bug in :func:`.assert_index_equal` with ``names=True`` and ``check_order=False`` not checking names not (:issue:`47328`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO NOT USE THIS SECTION
yep. this is ok here, in previous release notes the assert_* always go in the other section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked 1.3 notes to be sure there
Co-authored-by: Simon Hawkins <[email protected]>
------- | ||
Index | ||
""" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
following on from #47329 (comment)
is our use of safe_sort
here, actually safe? i.e. we don't reach any of the cases that raise in safe_sort
) and the try is not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None inside a mixed index still raises a TypeError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets adressed in #47331, we can probably remove the try there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @phofl lgtm ex conflicts and ci failures.
# Conflicts: # pandas/_testing/asserters.py
Resolved conflicts |
Thanks @phofl |
…das-dev#47330) * BUG: assert_index_equal ignoring names when check_order is false * Update doc/source/whatsnew/v1.5.0.rst Co-authored-by: Simon Hawkins <[email protected]> * Move index creation to else block * Remove dtypes Co-authored-by: Simon Hawkins <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.This should get merged after #47325 (will probably have a conflict then)