@@ -1271,19 +1271,38 @@ def test_infinity_sort():
1271
1271
NegInf = libalgos .NegInfinity ()
1272
1272
1273
1273
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
+
1275
1276
assert all (Inf >= x for x in ref_nums )
1276
1277
assert all (Inf > x or x is Inf for x in ref_nums )
1277
1278
assert Inf >= Inf and Inf == Inf
1279
+ assert Inf >= libalgos .Infinity () and Inf == libalgos .Infinity ()
1278
1280
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 ()
1279
1284
1280
1285
assert all (NegInf <= x for x in ref_nums )
1281
1286
assert all (NegInf < x or x is NegInf for x in ref_nums )
1282
1287
assert NegInf <= NegInf and NegInf == NegInf
1288
+ assert (NegInf <= libalgos .NegInfinity () and
1289
+ NegInf == libalgos .NegInfinity ())
1283
1290
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 )
1284
1301
1285
1302
for perm in permutations (ref_nums ):
1286
1303
assert sorted (perm ) == ref_nums
1304
+ for perm in permutations (ref_objects ):
1305
+ assert sorted (perm ) == ref_objects
1287
1306
1288
1307
# smoke tests
1289
1308
np .array ([libalgos .Infinity ()] * 32 ).argsort ()
0 commit comments