pitrou commented on code in PR #48085:
URL: https://github.com/apache/arrow/pull/48085#discussion_r2769319375
##########
python/pyarrow/tests/test_array.py:
##########
@@ -4398,3 +4399,67 @@ def test_non_cpu_array():
arr.tolist()
with pytest.raises(NotImplementedError):
arr.validate(full=True)
+
+
[email protected]
+def int_arrays():
+ arr1 = pa.array([-1, 2, -3])
+ arr2 = pa.array([2, 4, 5])
+
+ return arr1, arr2
+
+
[email protected]
+def float_arrays():
+ arr1 = pa.array([-1.1, 2.2, -3.3])
+ arr2 = pa.array([2.2, 4.4, 5.5])
+
+ return arr1, arr2
+
+
+def test_arithmetic_dunders(float_arrays):
+ # GH-32007
+ arr1, arr2 = float_arrays
+
+ assert (arr1 + arr2).equals(pc.add_checked(arr1, arr2))
Review Comment:
If we really want to assert the "checked" aspect, then we should also
include a case where overflow occurs.
##########
python/pyarrow/tests/test_scalars.py:
##########
@@ -995,3 +995,55 @@ def test_map_scalar_with_empty_values():
s = pa.scalar(v, type=map_type)
assert s.as_py(maps_as_pydicts="strict") == v
+
+
[email protected]
Review Comment:
Same comments here.
##########
python/pyarrow/array.pxi:
##########
@@ -229,6 +235,25 @@ def array(object obj, type=None, mask=None, size=None,
from_pandas=None,
>>> arr = pa.array(range(1024), type=pa.dictionary(pa.int8(), pa.int64()))
>>> arr.type.index_type
DataType(int16)
+
+ >>> arr1 = pa.array([1, 2, 3], type=pa.int8())
+ >>> arr2 = pa.array([4, 5, 6], type=pa.int8())
+ >>> arr1 + arr2
+ <pyarrow.lib.Int8Array object at ...>
+ [
+ 5,
+ 7,
+ 9
+ ]
+
+ >>> val = pa.scalar(42)
+ >>> val - arr1
Review Comment:
Can I simply call `arr1 - 42` or would that not work?
##########
python/pyarrow/tests/test_array.py:
##########
@@ -4398,3 +4399,67 @@ def test_non_cpu_array():
arr.tolist()
with pytest.raises(NotImplementedError):
arr.validate(full=True)
+
+
[email protected]
Review Comment:
I don't think these fixtures are useful and their names seem too generic to
me. Testing on a single example per test should be sufficient IMHO.
--
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]