Skip to content

Commit

Permalink
TST: Test inequality w/ complex dtypes (GH28050) (pandas-dev#43159)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
calvh authored Aug 22, 2021
1 parent cbec30e commit 49279c9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,3 +1095,15 @@ def test_period_dtype_compare_to_string():
dtype = PeriodDtype(freq="M")
assert (dtype == "period[M]") is True
assert (dtype != "period[M]") is False


def test_compare_complex_dtypes():
# GH 28050
df = pd.DataFrame(np.arange(5).astype(np.complex128))
msg = "'<' not supported between instances of 'complex' and 'complex'"

with pytest.raises(TypeError, match=msg):
df < df.astype(object)

with pytest.raises(TypeError, match=msg):
df.lt(df.astype(object))

0 comments on commit 49279c9

Please sign in to comment.