kylebarron opened a new issue, #43792:
URL: https://github.com/apache/arrow/issues/43792

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   pyarrow seems to be applying some upcasting when importing data via the 
buffer protocol. This was unexpected behavior to me and could be considered a 
bug.
   
   pyarrow seems to cast:
   
   - `float32` -> `float64`
   - `int32` -> `int64`
   - `uint64` -> `int64`
   
   As expected:
   
   ```
   import numpy as np
   import pyarrow as pa
   
   arr = np.array([1.0, 2.0, 3.0], dtype=np.float64)
   pa.array(memoryview(arr))
   # <pyarrow.lib.DoubleArray object at 0x1232429e0>
   # [
   #   1,
   #   2,
   #   3
   # ]
   ```
   
   Unexpected casts:
   
   ```py
   arr = np.array([1.0, 2.0, 3.0], dtype=np.float32)
   pa.array(memoryview(arr))
   # <pyarrow.lib.DoubleArray object at 0x1232e0a00>
   # [
   #   1,
   #   2,
   #   3
   # ]
   
   arr = np.array(object=[1.0, 2.0, 3.0], dtype=np.uint64)
   pa.array(memoryview(arr))
   # <pyarrow.lib.Int64Array object at 0x1232e26e0>
   # [
   #   1,
   #   2,
   #   3
   # ]
   
   arr = np.array(object=[1.0, 2.0, 3.0], dtype=np.uint32)
   pa.array(memoryview(arr))
   # <pyarrow.lib.Int64Array object at 0x1232e1de0>
   # [
   #   1,
   #   2,
   #   3
   # ]
   ```
   
   ### Component(s)
   
   Python


-- 
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: issues-unsubscr...@arrow.apache.org.apache.org

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

Reply via email to