-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: avoid _internal_get_values in pandas._testing #32570
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
CLN: avoid _internal_get_values in pandas._testing #32570
Conversation
@@ -1038,7 +1038,8 @@ def assert_extension_array_equal( | |||
|
|||
if hasattr(left, "asi8") and type(right) == type(left): | |||
# Avoid slow object-dtype comparisons | |||
assert_numpy_array_equal(left.asi8, right.asi8) | |||
# np.asarray for case where we have a np.MaskedArray | |||
assert_numpy_array_equal(np.asarray(left.asi8), np.asarray(right.asi8)) |
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.
How can asi8
ever return a MaskedArray?
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.
we have one test where we pass a MaskedArray to the constructor (I think DTI)
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.
we have one test where we pass a MaskedArray to the constructor (I think DTI)
But shouldn't that be converted to a normal array upon construction?
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.
id have no problem with enforcing this, but AFAIK we dont at the moment
obj=str(obj), | ||
) | ||
elif is_extension_array_dtype(left.dtype) or is_extension_array_dtype(right.dtype): | ||
assert_extension_array_equal(left._values, right._values) |
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.
assert_extension_array_equal doesn't work for categorical?
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.
We have kwargs check_categorical
and check_category_ordered
and a categorical-specific check at the end of assert_series_equal
. xref #32571 trying to cut down on these
thanks |
check_dtype=check_dtype, | ||
obj=str(obj), | ||
) | ||
elif is_extension_array_dtype(left.dtype) or is_extension_array_dtype(right.dtype): |
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.
Before this was "and", and now it is "or". That seems to cause issues in geopandas in case you specify check_dtype=False
(in which case you can eg have an EA dtype and object dtype with equal values)
7 more usages left after this