GH-50072:[Python] Add tests for replace_with_mask kernel#50102
Open
AnkitAhlawat7742 wants to merge 2 commits into
Open
GH-50072:[Python] Add tests for replace_with_mask kernel#50102AnkitAhlawat7742 wants to merge 2 commits into
AnkitAhlawat7742 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Python-level unit tests for the pyarrow.compute.replace_with_mask kernel to cover typical usage patterns that previously lacked coverage, as requested in GH-50072.
Changes:
- Added parameterized tests covering basic replacement behavior across several scalar/array types (ints, strings, floats) including nulls in values and mask.
- Added coverage for
ChunkedArrayinputs. - Added negative tests for invalid mask length and incorrect replacement counts.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pa.array([10.5, 20.5]), pa.array([10.5, 2.2, 20.5, 4.4])), | ||
| ]) | ||
| def test_replace_with_mask(arr, mask, replacements, expected): | ||
| """Test with various data types """ |
Comment on lines
+1348
to
+1352
| # Replacement count not match mask true count | ||
| (pa.array([1, 2, 3]), pa.array([True, True, False]), | ||
| pa.array([10]), "expected 2.*but got 1"), | ||
| # Mask length not match | ||
| (pa.array([1, 2, 3]), pa.array([True, False]), pa.array([10]), None), |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix : #50072
Rationale for this change
The
replace_with_maskcompute function in PyArrow currently has no Python-level tests for regular use cases.This PR adds test cases for standard usage of
replace_with_maskto ensure the function works correctly.What changes are included in this PR?
Added parameterized test cases in
python/pyarrow/tests/test_compute.pyAre these changes tested?
Yes, Manually
Are there any user-facing changes?
No user-facing changes.