@@ -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' ],
@@ -2398,6 +2406,8 @@ def test_is_monotonic(self):
2398
2406
names = ['first' , 'second' ])
2399
2407
assert not i .is_monotonic
2400
2408
assert not Index (i .values ).is_monotonic
2409
+ assert not i .is_strictly_monotonic_increasing
2410
+ assert not Index (i .values ).is_strictly_monotonic_increasing
2401
2411
2402
2412
i = MultiIndex (levels = [['bar' , 'baz' , 'foo' , 'qux' ],
2403
2413
['mom' , 'next' , 'zenith' ]],
@@ -2406,6 +2416,8 @@ def test_is_monotonic(self):
2406
2416
names = ['first' , 'second' ])
2407
2417
assert i .is_monotonic
2408
2418
assert Index (i .values ).is_monotonic
2419
+ assert i .is_strictly_monotonic_increasing
2420
+ assert Index (i .values ).is_strictly_monotonic_increasing
2409
2421
2410
2422
# mixed levels, hits the TypeError
2411
2423
i = MultiIndex (
@@ -2416,6 +2428,20 @@ def test_is_monotonic(self):
2416
2428
names = ['household_id' , 'asset_id' ])
2417
2429
2418
2430
assert not i .is_monotonic
2431
+ assert not i .is_strictly_monotonic_increasing
2432
+
2433
+ def test_is_strictly_monotonic (self ):
2434
+ idx = pd .MultiIndex (levels = [['bar' , 'baz' ], ['mom' , 'next' ]],
2435
+ labels = [[0 , 0 , 1 , 1 ], [0 , 0 , 0 , 1 ]])
2436
+ assert idx .is_monotonic_increasing
2437
+ assert not idx .is_strictly_monotonic_increasing
2438
+
2439
+ @pytest .mark .xfail (reason = "buggy MultiIndex.is_monotonic_decresaing." )
2440
+ def test_is_strictly_monotonic_decreasing (self ):
2441
+ idx = pd .MultiIndex (levels = [['baz' , 'bar' ], ['next' , 'mom' ]],
2442
+ labels = [[0 , 0 , 1 , 1 ], [0 , 0 , 0 , 1 ]])
2443
+ assert idx .is_monotonic_decreasing
2444
+ assert not idx .is_strictly_monotonic_decreasing
2419
2445
2420
2446
def test_reconstruct_sort (self ):
2421
2447
0 commit comments