-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
PERF: ArrowExtensionArray.searchsorted #50447
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
sorter: NumpySorter = None, | ||
) -> npt.NDArray[np.intp] | np.intp: | ||
if self._hasna: | ||
raise ValueError( |
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.
Is this the same error the base class would raise? Are there tests for this?
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.
No, the base class raises:
TypeError: boolean value of NA is ambiguous
The ArrowExtensionArray.searchsorted
method added here is pretty much a copy of BaseMaskedArray.searchsorted
. I will add a test. (I'll add one for BaseMaskedArray as well - I don't see it being tested there)
"which is impossible with NAs present." | ||
) | ||
with pytest.raises(ValueError, match=err_msg): | ||
print(arr_with_na.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.
Could you remove this print?
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.
oops, removed. thx
@@ -438,6 +438,18 @@ def test_searchsorted(self, data_for_sorting, as_series): | |||
sorter = np.array([1, 2, 0]) | |||
assert data_for_sorting.searchsorted(a, sorter=sorter) == 0 | |||
|
|||
# arr containing na value |
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.
I think since this is applicable to pandas specific masked arrays + arrow array, this test should live in those specific test files. Technically these base extension tests should be passable for any EA developer who might not define searchsorted
to error in this way
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.
Makes sense, I've moved the tests.
Thanks @lukemanley |
doc/source/whatsnew/v2.0.0.rst
file if fixing a bug or adding a new feature.Perf improvement in
ArrowExtensionArray.searchsorted
: