Skip to content

Commit 863ac93

Browse files
committed
TST: Add a new test to ensure that boolean comparisons are errstate-protected.
1 parent 6932851 commit 863ac93

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/frame/test_operators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,15 @@ def test_comp(func):
929929
test_comp(operator.ge)
930930
test_comp(operator.le)
931931

932+
def test_comparison_protected_from_errstate(self):
933+
missing_df = tm.makeDataFrame()
934+
missing_df.iloc[0]['A'] = np.nan
935+
with np.errstate(invalid='ignore'):
936+
expected = missing_df.values < 0
937+
with np.errstate(invalid='raise'):
938+
result = (missing_df < 0).values
939+
self.assert_numpy_array_equal(result, expected)
940+
932941
def test_string_comparison(self):
933942
df = DataFrame([{"a": 1, "b": "foo"}, {"a": 2, "b": "bar"}])
934943
mask_a = df.a > 1

0 commit comments

Comments
 (0)