@@ -159,6 +159,41 @@ def test_logical_operators_bool_dtype_with_int(self):
159
159
expected = s_tft
160
160
assert_series_equal (res , expected )
161
161
162
+ def test_logical_ops_bool_dtype_with_ndarray (self ):
163
+ # make sure we operate on ndarray the same as Series
164
+ left = pd .Series ([True , True , True , False , True ])
165
+ right = [True , False , None , True , np .nan ]
166
+
167
+ expected = pd .Series ([True , False , False , False , False ])
168
+ result = left & right
169
+ tm .assert_series_equal (result , expected )
170
+ result = left & np .array (right )
171
+ tm .assert_series_equal (result , expected )
172
+ result = left & pd .Index (right )
173
+ tm .assert_series_equal (result , expected )
174
+ result = left & pd .Series (right )
175
+ tm .assert_series_equal (result , expected )
176
+
177
+ expected = pd .Series ([True , True , True , True , True ])
178
+ result = left | right
179
+ tm .assert_series_equal (result , expected )
180
+ result = left | np .array (right )
181
+ tm .assert_series_equal (result , expected )
182
+ result = left | pd .Index (right )
183
+ tm .assert_series_equal (result , expected )
184
+ result = left | pd .Series (right )
185
+ tm .assert_series_equal (result , expected )
186
+
187
+ expected = pd .Series ([False , True , True , True , True ])
188
+ result = left ^ right
189
+ tm .assert_series_equal (result , expected )
190
+ result = left ^ np .array (right )
191
+ tm .assert_series_equal (result , expected )
192
+ result = left ^ pd .Index (right )
193
+ tm .assert_series_equal (result , expected )
194
+ result = left ^ pd .Series (right )
195
+ tm .assert_series_equal (result , expected )
196
+
162
197
def test_logical_operators_int_dtype_with_bool_dtype_and_reindex (self ):
163
198
# GH#9016: support bitwise op for integer types
164
199
0 commit comments