-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Suppress FutureWarning when comparing object arrays #8512
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,6 +406,7 @@ def array_equivalent(left, right, strict_nan=False): | |
>>> array_equivalent(np.array([1, nan, 2]), np.array([1, 2, nan])) | ||
False | ||
""" | ||
|
||
left, right = np.asarray(left), np.asarray(right) | ||
if left.shape != right.shape: return False | ||
|
||
|
@@ -414,8 +415,8 @@ def array_equivalent(left, right, strict_nan=False): | |
|
||
if not strict_nan: | ||
# pd.isnull considers NaN and None to be equivalent. | ||
return ((left == right) | (pd.isnull(left) & pd.isnull(right))).all() | ||
|
||
return lib.array_equivalent_object(left.ravel(), right.ravel()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here, I think you need to do:
|
||
for left_value, right_value in zip(left, right): | ||
if left_value is tslib.NaT and right_value is not tslib.NaT: | ||
return False | ||
|
@@ -426,7 +427,6 @@ def array_equivalent(left, right, strict_nan=False): | |
else: | ||
if left_value != right_value: | ||
return False | ||
|
||
return True | ||
|
||
# NaNs can occur in float and complex arrays. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1047,7 +1047,7 @@ def equals(self, other): | |
if type(other) != Index: | ||
return other.equals(self) | ||
|
||
return array_equivalent(self, other) | ||
return array_equivalent(_values_from_object(self), _values_from_object(other)) | ||
|
||
def identical(self, other): | ||
"""Similar to equals, but check that other comparable attributes are | ||
|
@@ -2260,7 +2260,7 @@ def equals(self, other): | |
# return False | ||
|
||
try: | ||
return array_equivalent(self, other) | ||
return array_equivalent(_values_from_object(self), _values_from_object(other)) | ||
except TypeError: | ||
# e.g. fails in numpy 1.6 with DatetimeIndex #1681 | ||
return False | ||
|
@@ -4175,7 +4175,8 @@ def equals(self, other): | |
return True | ||
|
||
if not isinstance(other, MultiIndex): | ||
return array_equivalent(self.values, _ensure_index(other)) | ||
return array_equivalent(self.values, | ||
_values_from_object(_ensure_index(other))) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perfect |
||
if self.nlevels != other.nlevels: | ||
return False | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
yep, this is fine
is their an example in basics.rst as well?