Skip to content

Commit 8b5b8b2

Browse files
committed
enhance test for Infinity/NegInfinity object in test_algos
1 parent 1147e67 commit 8b5b8b2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pandas/tests/test_algos.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,19 +1271,38 @@ def test_infinity_sort():
12711271
NegInf = libalgos.NegInfinity()
12721272

12731273
ref_nums = [NegInf, float("-inf"), -1e100, 0, 1e100, float("inf"), Inf]
1274-
1274+
ref_objects = [NegInf, 'A', 'Ac', 'B', 'C', 'D', 'a','z', Inf]
1275+
12751276
assert all(Inf >= x for x in ref_nums)
12761277
assert all(Inf > x or x is Inf for x in ref_nums)
12771278
assert Inf >= Inf and Inf == Inf
1279+
assert Inf >= libalgos.Infinity() and Inf == libalgos.Infinity()
12781280
assert not Inf < Inf and not Inf > Inf
1281+
assert not Inf < libalgos.Infinity() and not Inf > libalgos.Infinity()
1282+
assert libalgos.Infinity() == libalgos.Infinity()
1283+
assert not libalgos.Infinity() != libalgos.Infinity()
12791284

12801285
assert all(NegInf <= x for x in ref_nums)
12811286
assert all(NegInf < x or x is NegInf for x in ref_nums)
12821287
assert NegInf <= NegInf and NegInf == NegInf
1288+
assert (NegInf <= libalgos.NegInfinity() and
1289+
NegInf == libalgos.NegInfinity())
12831290
assert not NegInf < NegInf and not NegInf > NegInf
1291+
assert (not NegInf < libalgos.NegInfinity() and not
1292+
NegInf > libalgos.NegInfinity())
1293+
assert libalgos.NegInfinity() == libalgos.NegInfinity()
1294+
assert not libalgos.NegInfinity() != libalgos.NegInfinity()
1295+
1296+
assert Inf > np.nan and Inf >= np.nan and Inf != np.nan
1297+
assert not Inf < np.nan and not Inf <= np.nan
1298+
assert NegInf < np.nan and NegInf <= np.nan and NegInf != np.nan
1299+
assert (not NegInf > np.nan and not NegInf >= np.nan and not
1300+
NegInf == np.nan)
12841301

12851302
for perm in permutations(ref_nums):
12861303
assert sorted(perm) == ref_nums
1304+
for perm in permutations(ref_objects):
1305+
assert sorted(perm) == ref_objects
12871306

12881307
# smoke tests
12891308
np.array([libalgos.Infinity()] * 32).argsort()

0 commit comments

Comments
 (0)