-
-
Notifications
You must be signed in to change notification settings - Fork 19k
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
Changes from 6 commits
f921559
48c3830
ed45d75
c03c28a
0ed5366
43d5f45
0f93543
504cc29
f3e88fa
09ecb16
240031e
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 |
---|---|---|
|
@@ -438,6 +438,19 @@ 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 commentThe 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 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. Makes sense, I've moved the tests. |
||
if arr._can_hold_na and arr.dtype.na_value is pd.NA: | ||
arr_with_na = pd.array([a, b, pd.NA], dtype=arr.dtype) | ||
if as_series: | ||
arr_with_na = pd.Series(arr_with_na) | ||
err_msg = ( | ||
"searchsorted requires array to be sorted, " | ||
"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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. oops, removed. thx |
||
arr_with_na.searchsorted(a) | ||
|
||
def test_where_series(self, data, na_value, as_frame): | ||
assert data[0] != data[1] | ||
cls = type(data) | ||
|
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:
The
ArrowExtensionArray.searchsorted
method added here is pretty much a copy ofBaseMaskedArray.searchsorted
. I will add a test. (I'll add one for BaseMaskedArray as well - I don't see it being tested there)