js8544 commented on issue #38029:
URL: https://github.com/apache/arrow/issues/38029#issuecomment-1749728618

   This is because `pairwise_diff` calls the `subtract` kernel which wraps 
around on overflow:
   ```python
   >>> a = pa.array([0, 1, 0], type=pa.uint32())
   >>> b = pa.array([1, 0, 1], type=pa.uint32())
   >>> pc.subtract(a, b)
   <pyarrow.lib.UInt32Array object at 0xffff9fd68b20>
   [
     4294967295,
     1,
     4294967295
   ]
   ```
   If you are sure your inputs within the range of int32, you can cast the 
array to pa.int32() first.
   
   If the function outputs signed results, large diffs such as the one for `a = 
pa.array([0, 4294967295], type=pa.uint32())` can never be correctly computed. 
So the output has to be unsigned for the sake of correctness.
   
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to