9
9
def test_is_monotonic_increasing ():
10
10
i = MultiIndex .from_product ([np .arange (10 ),
11
11
np .arange (10 )], names = ['one' , 'two' ])
12
- assert i .is_monotonic
13
- assert i ._is_strictly_monotonic_increasing
14
- assert Index (i .values ).is_monotonic
15
- assert i ._is_strictly_monotonic_increasing
12
+ assert i .is_monotonic is True
13
+ assert i ._is_strictly_monotonic_increasing is True
14
+ assert Index (i .values ).is_monotonic is True
15
+ assert i ._is_strictly_monotonic_increasing is True
16
16
17
17
i = MultiIndex .from_product ([np .arange (10 , 0 , - 1 ),
18
18
np .arange (10 )], names = ['one' , 'two' ])
19
- assert not i .is_monotonic
20
- assert not i ._is_strictly_monotonic_increasing
21
- assert not Index (i .values ).is_monotonic
22
- assert not Index (i .values )._is_strictly_monotonic_increasing
19
+ assert i .is_monotonic is False
20
+ assert i ._is_strictly_monotonic_increasing is False
21
+ assert Index (i .values ).is_monotonic is False
22
+ assert Index (i .values )._is_strictly_monotonic_increasing is False
23
23
24
24
i = MultiIndex .from_product ([np .arange (10 ),
25
25
np .arange (10 , 0 , - 1 )],
26
26
names = ['one' , 'two' ])
27
- assert not i .is_monotonic
28
- assert not i ._is_strictly_monotonic_increasing
29
- assert not Index (i .values ).is_monotonic
30
- assert not Index (i .values )._is_strictly_monotonic_increasing
27
+ assert i .is_monotonic is False
28
+ assert i ._is_strictly_monotonic_increasing is False
29
+ assert Index (i .values ).is_monotonic is False
30
+ assert Index (i .values )._is_strictly_monotonic_increasing is False
31
31
32
32
i = MultiIndex .from_product ([[1.0 , np .nan , 2.0 ], ['a' , 'b' , 'c' ]])
33
- assert not i .is_monotonic
34
- assert not i ._is_strictly_monotonic_increasing
35
- assert not Index (i .values ).is_monotonic
36
- assert not Index (i .values )._is_strictly_monotonic_increasing
33
+ assert i .is_monotonic is False
34
+ assert i ._is_strictly_monotonic_increasing is False
35
+ assert Index (i .values ).is_monotonic is False
36
+ assert Index (i .values )._is_strictly_monotonic_increasing is False
37
37
38
38
# string ordering
39
39
i = MultiIndex (levels = [['foo' , 'bar' , 'baz' , 'qux' ],
40
40
['one' , 'two' , 'three' ]],
41
41
labels = [[0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 3 ],
42
42
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
43
43
names = ['first' , 'second' ])
44
- assert not i .is_monotonic
45
- assert not Index (i .values ).is_monotonic
46
- assert not i ._is_strictly_monotonic_increasing
47
- assert not Index (i .values )._is_strictly_monotonic_increasing
44
+ assert i .is_monotonic is False
45
+ assert Index (i .values ).is_monotonic is False
46
+ assert i ._is_strictly_monotonic_increasing is False
47
+ assert Index (i .values )._is_strictly_monotonic_increasing is False
48
48
49
49
i = MultiIndex (levels = [['bar' , 'baz' , 'foo' , 'qux' ],
50
50
['mom' , 'next' , 'zenith' ]],
51
51
labels = [[0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 3 ],
52
52
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
53
53
names = ['first' , 'second' ])
54
- assert i .is_monotonic
55
- assert Index (i .values ).is_monotonic
56
- assert i ._is_strictly_monotonic_increasing
57
- assert Index (i .values )._is_strictly_monotonic_increasing
54
+ assert i .is_monotonic is True
55
+ assert Index (i .values ).is_monotonic is True
56
+ assert i ._is_strictly_monotonic_increasing is True
57
+ assert Index (i .values )._is_strictly_monotonic_increasing is True
58
58
59
59
# mixed levels, hits the TypeError
60
60
i = MultiIndex (
@@ -64,67 +64,67 @@ def test_is_monotonic_increasing():
64
64
labels = [[0 , 1 , 1 , 2 , 2 , 2 , 3 ], [4 , 2 , 0 , 0 , 1 , 3 , - 1 ]],
65
65
names = ['household_id' , 'asset_id' ])
66
66
67
- assert not i .is_monotonic
68
- assert not i ._is_strictly_monotonic_increasing
67
+ assert i .is_monotonic is False
68
+ assert i ._is_strictly_monotonic_increasing is False
69
69
70
70
# empty
71
71
i = MultiIndex .from_arrays ([[], []])
72
- assert i .is_monotonic
73
- assert Index (i .values ).is_monotonic
74
- assert i ._is_strictly_monotonic_increasing
75
- assert Index (i .values )._is_strictly_monotonic_increasing
72
+ assert i .is_monotonic is True
73
+ assert Index (i .values ).is_monotonic is True
74
+ assert i ._is_strictly_monotonic_increasing is True
75
+ assert Index (i .values )._is_strictly_monotonic_increasing is True
76
76
77
77
78
78
def test_is_monotonic_decreasing ():
79
79
i = MultiIndex .from_product ([np .arange (9 , - 1 , - 1 ),
80
80
np .arange (9 , - 1 , - 1 )],
81
81
names = ['one' , 'two' ])
82
- assert i .is_monotonic_decreasing
83
- assert i ._is_strictly_monotonic_decreasing
84
- assert Index (i .values ).is_monotonic_decreasing
85
- assert i ._is_strictly_monotonic_decreasing
82
+ assert i .is_monotonic_decreasing is True
83
+ assert i ._is_strictly_monotonic_decreasing is True
84
+ assert Index (i .values ).is_monotonic_decreasing is True
85
+ assert i ._is_strictly_monotonic_decreasing is True
86
86
87
87
i = MultiIndex .from_product ([np .arange (10 ),
88
88
np .arange (10 , 0 , - 1 )],
89
89
names = ['one' , 'two' ])
90
- assert not i .is_monotonic_decreasing
91
- assert not i ._is_strictly_monotonic_decreasing
92
- assert not Index (i .values ).is_monotonic_decreasing
93
- assert not Index (i .values )._is_strictly_monotonic_decreasing
90
+ assert i .is_monotonic_decreasing is False
91
+ assert i ._is_strictly_monotonic_decreasing is False
92
+ assert Index (i .values ).is_monotonic_decreasing is False
93
+ assert Index (i .values )._is_strictly_monotonic_decreasing is False
94
94
95
95
i = MultiIndex .from_product ([np .arange (10 , 0 , - 1 ),
96
96
np .arange (10 )], names = ['one' , 'two' ])
97
- assert not i .is_monotonic_decreasing
98
- assert not i ._is_strictly_monotonic_decreasing
99
- assert not Index (i .values ).is_monotonic_decreasing
100
- assert not Index (i .values )._is_strictly_monotonic_decreasing
97
+ assert i .is_monotonic_decreasing is False
98
+ assert i ._is_strictly_monotonic_decreasing is False
99
+ assert Index (i .values ).is_monotonic_decreasing is False
100
+ assert Index (i .values )._is_strictly_monotonic_decreasing is False
101
101
102
102
i = MultiIndex .from_product ([[2.0 , np .nan , 1.0 ], ['c' , 'b' , 'a' ]])
103
- assert not i .is_monotonic_decreasing
104
- assert not i ._is_strictly_monotonic_decreasing
105
- assert not Index (i .values ).is_monotonic_decreasing
106
- assert not Index (i .values )._is_strictly_monotonic_decreasing
103
+ assert i .is_monotonic_decreasing is False
104
+ assert i ._is_strictly_monotonic_decreasing is False
105
+ assert Index (i .values ).is_monotonic_decreasing is False
106
+ assert Index (i .values )._is_strictly_monotonic_decreasing is False
107
107
108
108
# string ordering
109
109
i = MultiIndex (levels = [['qux' , 'foo' , 'baz' , 'bar' ],
110
110
['three' , 'two' , 'one' ]],
111
111
labels = [[0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 3 ],
112
112
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
113
113
names = ['first' , 'second' ])
114
- assert not i .is_monotonic_decreasing
115
- assert not Index (i .values ).is_monotonic_decreasing
116
- assert not i ._is_strictly_monotonic_decreasing
117
- assert not Index (i .values )._is_strictly_monotonic_decreasing
114
+ assert i .is_monotonic_decreasing is False
115
+ assert Index (i .values ).is_monotonic_decreasing is False
116
+ assert i ._is_strictly_monotonic_decreasing is False
117
+ assert Index (i .values )._is_strictly_monotonic_decreasing is False
118
118
119
119
i = MultiIndex (levels = [['qux' , 'foo' , 'baz' , 'bar' ],
120
120
['zenith' , 'next' , 'mom' ]],
121
121
labels = [[0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 3 ],
122
122
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
123
123
names = ['first' , 'second' ])
124
- assert i .is_monotonic_decreasing
125
- assert Index (i .values ).is_monotonic_decreasing
126
- assert i ._is_strictly_monotonic_decreasing
127
- assert Index (i .values )._is_strictly_monotonic_decreasing
124
+ assert i .is_monotonic_decreasing is True
125
+ assert Index (i .values ).is_monotonic_decreasing is True
126
+ assert i ._is_strictly_monotonic_decreasing is True
127
+ assert Index (i .values )._is_strictly_monotonic_decreasing is True
128
128
129
129
# mixed levels, hits the TypeError
130
130
i = MultiIndex (
@@ -134,29 +134,29 @@ def test_is_monotonic_decreasing():
134
134
labels = [[0 , 1 , 1 , 2 , 2 , 2 , 3 ], [4 , 2 , 0 , 0 , 1 , 3 , - 1 ]],
135
135
names = ['household_id' , 'asset_id' ])
136
136
137
- assert not i .is_monotonic_decreasing
138
- assert not i ._is_strictly_monotonic_decreasing
137
+ assert i .is_monotonic_decreasing is False
138
+ assert i ._is_strictly_monotonic_decreasing is False
139
139
140
140
# empty
141
141
i = MultiIndex .from_arrays ([[], []])
142
- assert i .is_monotonic_decreasing
143
- assert Index (i .values ).is_monotonic_decreasing
144
- assert i ._is_strictly_monotonic_decreasing
145
- assert Index (i .values )._is_strictly_monotonic_decreasing
142
+ assert i .is_monotonic_decreasing is True
143
+ assert Index (i .values ).is_monotonic_decreasing is True
144
+ assert i ._is_strictly_monotonic_decreasing is True
145
+ assert Index (i .values )._is_strictly_monotonic_decreasing is True
146
146
147
147
148
148
def test_is_strictly_monotonic_increasing ():
149
149
idx = pd .MultiIndex (levels = [['bar' , 'baz' ], ['mom' , 'next' ]],
150
150
labels = [[0 , 0 , 1 , 1 ], [0 , 0 , 0 , 1 ]])
151
- assert idx .is_monotonic_increasing
152
- assert not idx ._is_strictly_monotonic_increasing
151
+ assert idx .is_monotonic_increasing is True
152
+ assert idx ._is_strictly_monotonic_increasing is False
153
153
154
154
155
155
def test_is_strictly_monotonic_decreasing ():
156
156
idx = pd .MultiIndex (levels = [['baz' , 'bar' ], ['next' , 'mom' ]],
157
157
labels = [[0 , 0 , 1 , 1 ], [0 , 0 , 0 , 1 ]])
158
- assert idx .is_monotonic_decreasing
159
- assert not idx ._is_strictly_monotonic_decreasing
158
+ assert idx .is_monotonic_decreasing is True
159
+ assert idx ._is_strictly_monotonic_decreasing is False
160
160
161
161
162
162
def test_searchsorted_monotonic (indices ):
0 commit comments