-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: is_dtype_equal(dtype, "string[pyarrow]") raises if pyarrow not installed #44327
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
Changes from 3 commits
542032c
76ab6fa
c82d836
c35e162
cff657a
dce9db6
5abfa2e
fb0bd2a
f7b8888
2de4936
66327e7
9566360
0f35541
7ea6b15
9b0dc6c
b0a75fc
75a4b26
f5bedc6
9c68f5c
c550a00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -601,7 +601,8 @@ def is_dtype_equal(source, target) -> bool: | |
# is_dtype_equal(CDT, "category") and CDT == "category" | ||
try: | ||
src = get_dtype(source) | ||
if isinstance(src, ExtensionDtype): | ||
if isinstance(src, ExtensionDtype) or isinstance(src, np.dtype): | ||
|
||
return src == target | ||
except (TypeError, AttributeError): | ||
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. I think you can probably catch the ImportError here (so it always returns False if the above raises an ImportError) 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. Done |
||
return False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
from pandas.core.dtypes.common import ( | ||
is_categorical_dtype, | ||
is_dtype_equal, | ||
is_object_dtype, | ||
) | ||
|
||
|
@@ -150,6 +151,8 @@ def test_access_by_position(index): | |
assert index[-1] == index[size - 1] | ||
|
||
msg = f"index {size} is out of bounds for axis 0 with size {size}" | ||
|
||
assert not is_dtype_equal(index.dtype, "string[pyarrow]") | ||
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. can you move to the tests for is_dtype_equal, 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. Done |
||
with pytest.raises(IndexError, match=msg): | ||
index[size] | ||
msg = "single positional indexer is out-of-bounds" | ||
|
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.
can you add the example to the doc-string
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.
Done
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.
single isinstance call
isinstance(src, (ExtensionDtype, np.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.
Done