@@ -524,6 +524,37 @@ def test_kleene_xor_scalar(self, other, expected):
524
524
a , pd .array ([True , False , None ], dtype = "boolean" )
525
525
)
526
526
527
+ @pytest .mark .parametrize (
528
+ "other" ,
529
+ [
530
+ True ,
531
+ False ,
532
+ # pd.NA
533
+ [True , False , None ] * 3 ,
534
+ ],
535
+ )
536
+ def test_no_masked_assumptions (self , other , all_logical_operators ):
537
+ # The logical operations should not assume that masked values are False!
538
+ a = pd .array ([True ] * 3 + [False ] * 3 + [None ] * 3 , dtype = "boolean" )
539
+ b = a .copy ()
540
+ if isinstance (other , list ):
541
+ other = pd .array (other , dtype = "boolean" )
542
+
543
+ # mutate the data inplace
544
+ a ._data [a ._mask ] = True
545
+
546
+ result = getattr (a , all_logical_operators )(other )
547
+ expected = getattr (b , all_logical_operators )(other )
548
+ tm .assert_extension_array_equal (result , expected )
549
+
550
+ if isinstance (other , BooleanArray ):
551
+ other ._data [other ._mask ] = True
552
+ a ._data [a ._mask ] = False
553
+
554
+ result = getattr (a , all_logical_operators )(other )
555
+ expected = getattr (b , all_logical_operators )(other )
556
+ tm .assert_extension_array_equal (result , expected )
557
+
527
558
528
559
class TestComparisonOps (BaseOpsUtil ):
529
560
def _compare_other (self , data , op_name , other ):
0 commit comments