Skip to content

Commit 83f7235

Browse files
calvhfeefladder
authored andcommitted
TST: Test inequality w/ complex dtypes (GH28050) (pandas-dev#43159)
* TST: Test inequality w/ complex dtypes (GH28050) Should raise TypeError * Add test for complex dtype comparison using '<' * Refactor code to reduce repetition Remove https link to issue (keep issue number) Save match message in variable for multiple use * Combine arange call with DataFrame call in test
1 parent 22c44d0 commit 83f7235

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/tests/dtypes/test_dtypes.py

+12
Original file line numberDiff line numberDiff line change
@@ -1095,3 +1095,15 @@ def test_period_dtype_compare_to_string():
10951095
dtype = PeriodDtype(freq="M")
10961096
assert (dtype == "period[M]") is True
10971097
assert (dtype != "period[M]") is False
1098+
1099+
1100+
def test_compare_complex_dtypes():
1101+
# GH 28050
1102+
df = pd.DataFrame(np.arange(5).astype(np.complex128))
1103+
msg = "'<' not supported between instances of 'complex' and 'complex'"
1104+
1105+
with pytest.raises(TypeError, match=msg):
1106+
df < df.astype(object)
1107+
1108+
with pytest.raises(TypeError, match=msg):
1109+
df.lt(df.astype(object))

0 commit comments

Comments
 (0)