Upload hf_env/lib/python3.14/site-packages/pandas/tests/arithmetic/test_array_ops.py with huggingface_hub
Browse files
hf_env/lib/python3.14/site-packages/pandas/tests/arithmetic/test_array_ops.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import operator
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
import pandas._testing as tm
|
| 7 |
+
from pandas.core.ops.array_ops import (
|
| 8 |
+
comparison_op,
|
| 9 |
+
na_logical_op,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_na_logical_op_2d():
|
| 14 |
+
left = np.arange(8).reshape(4, 2)
|
| 15 |
+
right = left.astype(object)
|
| 16 |
+
right[0, 0] = np.nan
|
| 17 |
+
|
| 18 |
+
# Check that we fall back to the vec_binop branch
|
| 19 |
+
with pytest.raises(TypeError, match="unsupported operand type"):
|
| 20 |
+
operator.or_(left, right)
|
| 21 |
+
|
| 22 |
+
result = na_logical_op(left, right, operator.or_)
|
| 23 |
+
expected = right
|
| 24 |
+
tm.assert_numpy_array_equal(result, expected)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_object_comparison_2d():
|
| 28 |
+
left = np.arange(9).reshape(3, 3).astype(object)
|
| 29 |
+
right = left.T
|
| 30 |
+
|
| 31 |
+
result = comparison_op(left, right, operator.eq)
|
| 32 |
+
expected = np.eye(3).astype(bool)
|
| 33 |
+
tm.assert_numpy_array_equal(result, expected)
|
| 34 |
+
|
| 35 |
+
# Ensure that cython doesn't raise on non-writeable arg, which
|
| 36 |
+
# we can get from np.broadcast_to
|
| 37 |
+
right.flags.writeable = False
|
| 38 |
+
result = comparison_op(left, right, operator.ne)
|
| 39 |
+
tm.assert_numpy_array_equal(result, ~expected)
|