@@ -1397,25 +1397,32 @@ def test_bitwise_operators() -> None:
1397
1397
check (assert_type (s ^ 3 , "pd.Series[int]" ), pd .Series , np .integer )
1398
1398
check (assert_type (3 ^ s , "pd.Series[int]" ), pd .Series , np .integer )
1399
1399
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_ )
1402
1400
check (assert_type (s & s2 , "pd.Series[int]" ), pd .Series , np .integer )
1403
1401
check (assert_type (s2 & s , "pd.Series[int]" ), pd .Series , np .integer )
1404
1402
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_ )
1407
1403
check (assert_type (s | s2 , "pd.Series[int]" ), pd .Series , np .integer )
1408
1404
check (assert_type (s2 | s , "pd.Series[int]" ), pd .Series , np .integer )
1409
1405
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_ )
1412
1406
check (assert_type (s ^ s2 , "pd.Series[int]" ), pd .Series , np .integer )
1413
1407
check (assert_type (s2 ^ s , "pd.Series[int]" ), pd .Series , np .integer )
1414
1408
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
+
1415
1421
1416
1422
def test_logical_operators () -> None :
1417
1423
# GH 380
1418
1424
df = pd .DataFrame ({"a" : [1 , 2 , 3 ], "b" : [2 , 3 , 4 ]})
1425
+
1419
1426
check (
1420
1427
assert_type ((df ["a" ] >= 2 ) & (df ["b" ] >= 2 ), "pd.Series[bool]" ),
1421
1428
pd .Series ,
@@ -1432,41 +1439,50 @@ def test_logical_operators() -> None:
1432
1439
np .bool_ ,
1433
1440
)
1434
1441
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
+
1440
1443
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
+
1446
1445
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
+
1452
1447
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
+
1458
1449
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
+
1464
1451
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
+ )
1470
1486
1471
1487
1472
1488
def test_AnyArrayLike_and_clip () -> None :
0 commit comments