You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org> on 2024/10/14 23:25:51 UTC

[PR] GH-44231:[Python][Tests] Adding Test Cases for test_compute [arrow]

Isaac7777-cpu-school opened a new pull request, #44409:
URL: https://github.com/apache/arrow/pull/44409

   ### Rationale for this change
   
   This change is to address issue #44231 in which indicates that there is lacking coverage of the test cases for `test_compute.py`.
   
   ### What changes are included in this PR?
   
   #### Changes according to the issue:
   
   - Added negative values for `int8`, `int16`, `int32`, `int64`, `float`, `double`. I have also added in negative values for test cases in `pa.list_` and `pa.large_list_`
   - I have added `pa.decimal128` and `pa.decimal256` in `all_array_types`.
   
   #### Further changes:
   Apart from the problems mentioned in the issue, I have also extended some of the tests for `pa.decimal128` and `pa.decimal256`. Currently, the `numerical_arrow_types` does not contain decimal. However, some of the functions that are tested for the `numerical_arrow_types` should also be tested for both decimal types. Therefore, I have duplicated similar tests but rewritten using decimals.
   
   Looking to close #44231 
   
   ### Are these changes tested?
   
   Yes, these changes are tests by my fork repository CI. However, as I am new to open source contributing, I am not sure if I have missed anything. I apologise if I do so.
   
   ### Are there any user-facing changes?
   
   No.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1817988726


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   Hi, I was trying to address issue #44231 and I have only implemented test cases as @deanm0000 described in the issue. This is an additional thing that is required by him. Should I remove the relevant commits?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on PR #44409:
URL: https://github.com/apache/arrow/pull/44409#issuecomment-2422247077

   @kou I would like to merge this change into the main repository. How should I proceed?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "deanm0000 (via GitHub)" <gi...@apache.org>.
deanm0000 commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1820892185


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   Sorry for the delayed reply.
   
   You're right, I meant `multiply` not `multiple`. On my bad decimal assert, that's my fault I was just making a quick comment. I certainly wouldn't leave it with my wrong statement. @kou I'm not sure if it should be considered the same issue or not. The issue I raised was incomplete tests so it's a judgement call on how in the weeds the tests should be and how many more basic tests there ought to be before it is testing for the sake of testing. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "raulcd (via GitHub)" <gi...@apache.org>.
raulcd commented on PR #44409:
URL: https://github.com/apache/arrow/pull/44409#issuecomment-2422336528

   Hi @Isaac7777-cpu-school thanks for your PR.
   
   > I would like to merge this change into the main repository. How should I proceed?
   
   One committer (preferably expert on the area) has to review your PR, this might take some time as committers might be busy. The committers will ask any questions or request changes. If the reviewer agrees with the changes will approve the PR and merge to main.
   
   I've added a couple of possible reviewers that might be suited to take a look to the changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1807124325


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   I would like to ask if you mean `pc.multiply` as I can't see `multiple` in `pc`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #44409:
URL: https://github.com/apache/arrow/pull/44409#issuecomment-2483153952

   @deanm0000 @Isaac7777-cpu-school Sorry for the lack of response before, but I think this PR is misunderstanding that these functions are already tested on the C++ side quite thoroughly.
   
   For example, the fact that `test_compute.py` does not test negative values is irrelevant, given that the C++ tests do strive to test different kinds of inputs, and the Python compute functions in `pyarrow.compute` are just wrappers around the respective C++ functionality.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1817959621


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   @deanm0000 Should I open an issue for this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school closed pull request #44409: GH-44231: [Python] Add tests for test_compute
URL: https://github.com/apache/arrow/pull/44409


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "deanm0000 (via GitHub)" <gi...@apache.org>.
deanm0000 commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1806664416


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   It'd probably be good to add a test with auto inferred decimal precisions from mixed inputs. Something like 
   
   ```python
   a=pa.array([Decimal("1.232345"), Decimal("1.25"), Decimal("-100.25")])
   assert a.type==pa.decimal128(9,6)
   assert a.sum().as_py()==Decimal('-97.767655')
   ```
   
   polars has an issue which pyarrow doesn't where multiplying decimals causes the precision to double so this test too
   
   ```python
   b=pa.array([1,2,3])
   c=pc.multiple(a,b)
   assert c.type==pa.decimal128(9,6)
   ```
   
   It looks like when we divide it adds 20 decimal places so I'm not sure if that's intended 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1807125190


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   For the `assert` problem I suggested in the first comment, I believe it is the sole reason that causes the CI to fail.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on PR #44409:
URL: https://github.com/apache/arrow/pull/44409#issuecomment-2507040754

   > @deanm0000 @Isaac7777-cpu-school Sorry for the lack of response before, but I think this PR is misunderstanding that these functions are already tested on the C++ side.
   > 
   > For example, the fact that `test_compute.py` does not test negative values is irrelevant, given that the C++ tests may already test such inputs, and the Python compute functions in `pyarrow.compute` are just wrappers around the respective C++ functionality.
   > 
   > `test_compute.py` should therefore mostly exercise the wrapping logic. If there's really a need to improve the compute tests for more input values, it should therefore be done in the C++ side of Arrow, for example here for the decimal sum kernel:
   > 
   > https://github.com/apache/arrow/blob/152e878a2e79877ec461f96cefc97663f0bc581f/cpp/src/arrow/compute/kernels/aggregate_test.cc#L496-L535
   
   Hi, thank you for your reply. I guess I will close this PR for now and maybe work on improving the C++ side of testing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1811823334


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   @deanm0000 Hi, would you mind if I ask should I leave the tests be failing because of the additional decimal place when multiplying?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1822097046


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   How about using #44231 and this PR only for negative test values?
   How about creating a new issue and PR for decimal related tests? (This may need to improve decimal related implementation? I haven't checked the failure yet.)
   
   In general, small PRs are easy to review/merge.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "piratepanda805 (via GitHub)" <gi...@apache.org>.
piratepanda805 commented on PR #44409:
URL: https://github.com/apache/arrow/pull/44409#issuecomment-2415877945

   As a minor suggestion, squash the commits to have a cleaner commit history.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #44409:
URL: https://github.com/apache/arrow/pull/44409#issuecomment-2507305453

   @Isaac7777-cpu-school Thanks for the contribution! Please don't hesitate posting another PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1807118788


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   Thank you very much for your review. I have added the test cases you suggested into a separate function `test_decimal_compute`. However, I suspect that the assert `assert c.type==pa.decimal128(9,6)` may fail as it is adding 20 decimal places.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1817988355


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   Could you work on one problem per issue/pull request?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-44231: [Python] Add tests for test_compute [arrow]

Posted by "Isaac7777-cpu-school (via GitHub)" <gi...@apache.org>.
Isaac7777-cpu-school commented on code in PR #44409:
URL: https://github.com/apache/arrow/pull/44409#discussion_r1817959621


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -376,6 +386,57 @@ def test_sum_chunked_array(arrow_type):
     assert pc.sum(arr, min_count=0).as_py() == 0
 
 
+@pytest.mark.parametrize('arrow_type', decimal_arrow_types)
+def test_sum_decimal_array(arrow_type):

Review Comment:
   Should I open an issue for this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org