raulcd commented on code in PR #46618:
URL: https://github.com/apache/arrow/pull/46618#discussion_r2111535174
##########
python/pyarrow/tests/test_array.py:
##########
@@ -1664,6 +1664,16 @@ def test_floating_point_truncate_unsafe():
_check_cast_case(case, safe=False)
+def test_half_float_array_from_python():
+ # GH-46611
+ arr = pa.array([1.0, 2.0, 3, None], type=pa.float16())
Review Comment:
I don't know much about the Float16 implementation, could these truncations
vary in the future?
```diff
diff --git a/python/pyarrow/tests/test_array.py
b/python/pyarrow/tests/test_array.py
index ed80d716bb..1a964cda6c 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -1666,9 +1666,9 @@ def test_floating_point_truncate_unsafe():
def test_half_float_array_from_python():
# GH-46611
- arr = pa.array([1.0, 2.0, 3, None], type=pa.float16())
+ arr = pa.array([1.0, 2.0, 3, None, 12345.6789, 1.234567],
type=pa.float16())
assert arr.type == pa.float16()
- assert arr.to_pylist() == [1.0, 2.0, 3.0, None]
+ assert arr.to_pylist() == [1.0, 2.0, 3.0, None, 12344.0, 1.234375]
msg1 = "Could not convert 'a' with type str: tried to convert to
float16"
with pytest.raises(pa.ArrowInvalid, match=msg1):
arr = pa.array(['a', 3, None], type=pa.float16())
```
Happy to add something like this if we know the conversions/truncations are
stable.
--
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]