@@ -2373,22 +2373,30 @@ def test_is_monotonic(self):
23732373 i = MultiIndex .from_product ([np .arange (10 ),
23742374 np .arange (10 )], names = ['one' , 'two' ])
23752375 assert i .is_monotonic
2376+ assert i .is_strictly_monotonic_increasing
23762377 assert Index (i .values ).is_monotonic
2378+ assert i .is_strictly_monotonic_increasing
23772379
23782380 i = MultiIndex .from_product ([np .arange (10 , 0 , - 1 ),
23792381 np .arange (10 )], names = ['one' , 'two' ])
23802382 assert not i .is_monotonic
2383+ assert not i .is_strictly_monotonic_increasing
23812384 assert not Index (i .values ).is_monotonic
2385+ assert not Index (i .values ).is_strictly_monotonic_increasing
23822386
23832387 i = MultiIndex .from_product ([np .arange (10 ),
23842388 np .arange (10 , 0 , - 1 )],
23852389 names = ['one' , 'two' ])
23862390 assert not i .is_monotonic
2391+ assert not i .is_strictly_monotonic_increasing
23872392 assert not Index (i .values ).is_monotonic
2393+ assert not Index (i .values ).is_strictly_monotonic_increasing
23882394
23892395 i = MultiIndex .from_product ([[1.0 , np .nan , 2.0 ], ['a' , 'b' , 'c' ]])
23902396 assert not i .is_monotonic
2397+ assert not i .is_strictly_monotonic_increasing
23912398 assert not Index (i .values ).is_monotonic
2399+ assert not Index (i .values ).is_strictly_monotonic_increasing
23922400
23932401 # string ordering
23942402 i = MultiIndex (levels = [['foo' , 'bar' , 'baz' , 'qux' ],
@@ -2398,6 +2406,8 @@ def test_is_monotonic(self):
23982406 names = ['first' , 'second' ])
23992407 assert not i .is_monotonic
24002408 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
24012411
24022412 i = MultiIndex (levels = [['bar' , 'baz' , 'foo' , 'qux' ],
24032413 ['mom' , 'next' , 'zenith' ]],
@@ -2406,6 +2416,8 @@ def test_is_monotonic(self):
24062416 names = ['first' , 'second' ])
24072417 assert i .is_monotonic
24082418 assert Index (i .values ).is_monotonic
2419+ assert i .is_strictly_monotonic_increasing
2420+ assert Index (i .values ).is_strictly_monotonic_increasing
24092421
24102422 # mixed levels, hits the TypeError
24112423 i = MultiIndex (
@@ -2416,6 +2428,20 @@ def test_is_monotonic(self):
24162428 names = ['household_id' , 'asset_id' ])
24172429
24182430 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
24192445
24202446 def test_reconstruct_sort (self ):
24212447
0 commit comments