Skip to content

GH-50072:[Python] Add tests for replace_with_mask kernel#50102

Open
AnkitAhlawat7742 wants to merge 2 commits into
apache:mainfrom
AnkitAhlawat7742:add_rgulrTest_replacemask_krnl
Open

GH-50072:[Python] Add tests for replace_with_mask kernel#50102
AnkitAhlawat7742 wants to merge 2 commits into
apache:mainfrom
AnkitAhlawat7742:add_rgulrTest_replacemask_krnl

Conversation

@AnkitAhlawat7742
Copy link
Copy Markdown
Contributor

@AnkitAhlawat7742 AnkitAhlawat7742 commented Jun 5, 2026

Fix : #50072

Rationale for this change

The replace_with_mask compute function in PyArrow currently has no Python-level tests for regular use cases.
This PR adds test cases for standard usage of replace_with_mask to ensure the function works correctly.

What changes are included in this PR?

Added parameterized test cases in python/pyarrow/tests/test_compute.py

Are these changes tested?

Yes, Manually

Are there any user-facing changes?

No user-facing changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ChunkedArray inputs.
  • 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),
Copy link
Copy Markdown
Member

@raulcd raulcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minor comment from copilot about grammatically incorrect comments makes sense to apply. For the rest looks good to me.
@AlenkaF do you want to take a look?

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Add tests for regular replace_with_mask kernel usage

3 participants