@@ -2373,22 +2373,30 @@ def test_is_monotonic(self):
2373
2373
i = MultiIndex .from_product ([np .arange (10 ),
2374
2374
np .arange (10 )], names = ['one' , 'two' ])
2375
2375
assert i .is_monotonic
2376
+ assert i .is_strictly_monotonic_increasing
2376
2377
assert Index (i .values ).is_monotonic
2378
+ assert i .is_strictly_monotonic_increasing
2377
2379
2378
2380
i = MultiIndex .from_product ([np .arange (10 , 0 , - 1 ),
2379
2381
np .arange (10 )], names = ['one' , 'two' ])
2380
2382
assert not i .is_monotonic
2383
+ assert not i .is_strictly_monotonic_increasing
2381
2384
assert not Index (i .values ).is_monotonic
2385
+ assert not Index (i .values ).is_strictly_monotonic_increasing
2382
2386
2383
2387
i = MultiIndex .from_product ([np .arange (10 ),
2384
2388
np .arange (10 , 0 , - 1 )],
2385
2389
names = ['one' , 'two' ])
2386
2390
assert not i .is_monotonic
2391
+ assert not i .is_strictly_monotonic_increasing
2387
2392
assert not Index (i .values ).is_monotonic
2393
+ assert not Index (i .values ).is_strictly_monotonic_increasing
2388
2394
2389
2395
i = MultiIndex .from_product ([[1.0 , np .nan , 2.0 ], ['a' , 'b' , 'c' ]])
2390
2396
assert not i .is_monotonic
2397
+ assert not i .is_strictly_monotonic_increasing
2391
2398
assert not Index (i .values ).is_monotonic
2399
+ assert not Index (i .values ).is_strictly_monotonic_increasing
2392
2400
2393
2401
# string ordering
2394
2402
i = MultiIndex (levels = [['foo' , 'bar' , 'baz' , 'qux' ],
@@ -2397,15 +2405,17 @@ def test_is_monotonic(self):
2397
2405
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
2398
2406
names = ['first' , 'second' ])
2399
2407
assert not i .is_monotonic
2400
- assert not Index (i .values ).is_monotonic
2408
+ assert not i .is_strictly_monotonic_increasing
2409
+ assert not Index (i .values ).is_strictly_monotonic_increasing
2401
2410
2402
2411
i = MultiIndex (levels = [['bar' , 'baz' , 'foo' , 'qux' ],
2403
2412
['mom' , 'next' , 'zenith' ]],
2404
2413
labels = [[0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 3 ],
2405
2414
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
2406
2415
names = ['first' , 'second' ])
2407
2416
assert i .is_monotonic
2408
- assert Index (i .values ).is_monotonic
2417
+ assert i .is_strictly_monotonic_increasing
2418
+ assert Index (i .values ).is_strictly_monotonic_increasing
2409
2419
2410
2420
# mixed levels, hits the TypeError
2411
2421
i = MultiIndex (
@@ -2416,6 +2426,20 @@ def test_is_monotonic(self):
2416
2426
names = ['household_id' , 'asset_id' ])
2417
2427
2418
2428
assert not i .is_monotonic
2429
+ assert not i .is_strictly_monotonic_increasing
2430
+
2431
+ def test_is_strictly_monotonic (self ):
2432
+ idx = pd .MultiIndex (levels = [['bar' , 'baz' ], ['mom' , 'next' ]],
2433
+ labels = [[0 , 0 , 1 , 1 ], [0 , 0 , 0 , 1 ]])
2434
+ assert idx .is_monotonic_increasing
2435
+ assert not idx .is_strictly_monotonic_increasing
2436
+
2437
+ @pytest .mark .xfail (reason = "buggy MultiIndex.is_monotonic_decresaing." )
2438
+ def test_is_strictly_monotonic_decreasing (self ):
2439
+ idx = pd .MultiIndex (levels = [['baz' , 'bar' ], ['next' , 'mom' ]],
2440
+ labels = [[0 , 0 , 1 , 1 ], [0 , 0 , 0 , 1 ]])
2441
+ assert idx .is_monotonic_decreasing
2442
+ assert not idx .is_strictly_monotonic_decreasing
2419
2443
2420
2444
def test_reconstruct_sort (self ):
2421
2445
0 commit comments