bmschmidt opened a new issue, #45875:
URL: https://github.com/apache/arrow/issues/45875
### Describe the bug, including details regarding any error messages,
version, and platform.
Thanks to everyone who has contributed to this project.
I'm finding a discrepancy in behavior between creating an array directly and
casting it. The `safe` argument does not behave the same way in pa.array as in
`Array.cast`, although the docs make it seem that they should both allow
casting.
```python
import pyarrow as pa
# works, rounding to 100000000
pa.array([99999999]).cast(pa.float32(), safe=False)
# fails
pa.array([99999999], pa.float32(), safe=False)
```
Platforms:
* Python 3.12.5/OS X/pyarrow 19.0.1
Full output below.
```
Python 3.12.5 (main, Aug 14 2024, 04:32:18) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyarrow as pa; pa.array([99999999]).cast(pa.float32(), safe=False)
<pyarrow.lib.FloatArray object at 0x107a44100>
[
100000000
]
>>> pa.array([99999999], pa.float32(), safe=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyarrow/array.pxi", line 372, in pyarrow.lib.array
File "pyarrow/array.pxi", line 42, in pyarrow.lib._sequence_to_array
File "pyarrow/error.pxi", line 155, in
pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Integer value 99999999 is outside of the range
exactly representable by a IEEE 754 single precision value
>>> pa.__version__
'19.0.1'
```
### 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]