Skip to content

Commit 52337a0

Browse files
authored
gh:610 - added warnings (#611)
* added warning * Update test_series.py
1 parent 15717ba commit 52337a0

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

tests/test_series.py

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,25 +1397,32 @@ def test_bitwise_operators() -> None:
13971397
check(assert_type(s ^ 3, "pd.Series[int]"), pd.Series, np.integer)
13981398
check(assert_type(3 ^ s, "pd.Series[int]"), pd.Series, np.integer)
13991399

1400-
check(assert_type(s & [1, 2, 3, 4], "pd.Series[bool]"), pd.Series, np.bool_)
1401-
check(assert_type([1, 2, 3, 4] & s, "pd.Series[bool]"), pd.Series, np.bool_)
14021400
check(assert_type(s & s2, "pd.Series[int]"), pd.Series, np.integer)
14031401
check(assert_type(s2 & s, "pd.Series[int]"), pd.Series, np.integer)
14041402

1405-
check(assert_type(s | [1, 2, 3, 4], "pd.Series[bool]"), pd.Series, np.bool_)
1406-
check(assert_type([1, 2, 3, 4] | s, "pd.Series[bool]"), pd.Series, np.bool_)
14071403
check(assert_type(s | s2, "pd.Series[int]"), pd.Series, np.integer)
14081404
check(assert_type(s2 | s, "pd.Series[int]"), pd.Series, np.integer)
14091405

1410-
check(assert_type(s ^ [1, 2, 3, 4], "pd.Series[bool]"), pd.Series, np.bool_)
1411-
check(assert_type([1, 2, 3, 4] ^ s, "pd.Series[bool]"), pd.Series, np.bool_)
14121406
check(assert_type(s ^ s2, "pd.Series[int]"), pd.Series, np.integer)
14131407
check(assert_type(s2 ^ s, "pd.Series[int]"), pd.Series, np.integer)
14141408

1409+
with pytest_warns_bounded(
1410+
FutureWarning, match="Logical Ops(and, or, xor) is deprecated", lower="2.1"
1411+
):
1412+
check(assert_type(s & [1, 2, 3, 4], "pd.Series[bool]"), pd.Series, np.bool_)
1413+
check(assert_type([1, 2, 3, 4] & s, "pd.Series[bool]"), pd.Series, np.bool_)
1414+
1415+
check(assert_type(s | [1, 2, 3, 4], "pd.Series[bool]"), pd.Series, np.bool_)
1416+
check(assert_type([1, 2, 3, 4] | s, "pd.Series[bool]"), pd.Series, np.bool_)
1417+
1418+
check(assert_type(s ^ [1, 2, 3, 4], "pd.Series[bool]"), pd.Series, np.bool_)
1419+
check(assert_type([1, 2, 3, 4] ^ s, "pd.Series[bool]"), pd.Series, np.bool_)
1420+
14151421

14161422
def test_logical_operators() -> None:
14171423
# GH 380
14181424
df = pd.DataFrame({"a": [1, 2, 3], "b": [2, 3, 4]})
1425+
14191426
check(
14201427
assert_type((df["a"] >= 2) & (df["b"] >= 2), "pd.Series[bool]"),
14211428
pd.Series,
@@ -1432,41 +1439,50 @@ def test_logical_operators() -> None:
14321439
np.bool_,
14331440
)
14341441
check(assert_type((df["a"] >= 2) & True, "pd.Series[bool]"), pd.Series, np.bool_)
1435-
check(
1436-
assert_type((df["a"] >= 2) & [True, False, True], "pd.Series[bool]"),
1437-
pd.Series,
1438-
np.bool_,
1439-
)
1442+
14401443
check(assert_type((df["a"] >= 2) | True, "pd.Series[bool]"), pd.Series, np.bool_)
1441-
check(
1442-
assert_type((df["a"] >= 2) | [True, False, True], "pd.Series[bool]"),
1443-
pd.Series,
1444-
np.bool_,
1445-
)
1444+
14461445
check(assert_type((df["a"] >= 2) ^ True, "pd.Series[bool]"), pd.Series, np.bool_)
1447-
check(
1448-
assert_type((df["a"] >= 2) ^ [True, False, True], "pd.Series[bool]"),
1449-
pd.Series,
1450-
np.bool_,
1451-
)
1446+
14521447
check(assert_type(True & (df["a"] >= 2), "pd.Series[bool]"), pd.Series, np.bool_)
1453-
check(
1454-
assert_type([True, False, True] & (df["a"] >= 2), "pd.Series[bool]"),
1455-
pd.Series,
1456-
np.bool_,
1457-
)
1448+
14581449
check(assert_type(True | (df["a"] >= 2), "pd.Series[bool]"), pd.Series, np.bool_)
1459-
check(
1460-
assert_type([True, False, True] | (df["a"] >= 2), "pd.Series[bool]"),
1461-
pd.Series,
1462-
np.bool_,
1463-
)
1450+
14641451
check(assert_type(True ^ (df["a"] >= 2), "pd.Series[bool]"), pd.Series, np.bool_)
1465-
check(
1466-
assert_type([True, False, True] ^ (df["a"] >= 2), "pd.Series[bool]"),
1467-
pd.Series,
1468-
np.bool_,
1469-
)
1452+
1453+
with pytest_warns_bounded(
1454+
FutureWarning, match="Logical Ops(and, or, xor) is deprecated", lower="2.1"
1455+
):
1456+
check(
1457+
assert_type((df["a"] >= 2) ^ [True, False, True], "pd.Series[bool]"),
1458+
pd.Series,
1459+
np.bool_,
1460+
)
1461+
check(
1462+
assert_type((df["a"] >= 2) & [True, False, True], "pd.Series[bool]"),
1463+
pd.Series,
1464+
np.bool_,
1465+
)
1466+
check(
1467+
assert_type((df["a"] >= 2) | [True, False, True], "pd.Series[bool]"),
1468+
pd.Series,
1469+
np.bool_,
1470+
)
1471+
check(
1472+
assert_type([True, False, True] & (df["a"] >= 2), "pd.Series[bool]"),
1473+
pd.Series,
1474+
np.bool_,
1475+
)
1476+
check(
1477+
assert_type([True, False, True] | (df["a"] >= 2), "pd.Series[bool]"),
1478+
pd.Series,
1479+
np.bool_,
1480+
)
1481+
check(
1482+
assert_type([True, False, True] ^ (df["a"] >= 2), "pd.Series[bool]"),
1483+
pd.Series,
1484+
np.bool_,
1485+
)
14701486

14711487

14721488
def test_AnyArrayLike_and_clip() -> None:

0 commit comments

Comments
 (0)