|
1 | 1 | import numpy as np |
2 | | -import pytest |
3 | 2 |
|
4 | 3 | import pandas as pd |
5 | | -from pandas import Index, IntervalIndex, MultiIndex |
6 | | -from pandas.api.types import is_scalar |
| 4 | +from pandas import Index, MultiIndex |
7 | 5 |
|
8 | 6 |
|
9 | 7 | def test_is_monotonic_increasing(): |
@@ -176,55 +174,3 @@ def test_is_strictly_monotonic_decreasing(): |
176 | 174 | ) |
177 | 175 | assert idx.is_monotonic_decreasing is True |
178 | 176 | assert idx._is_strictly_monotonic_decreasing is False |
179 | | - |
180 | | - |
181 | | -def test_searchsorted_monotonic(indices): |
182 | | - # GH17271 |
183 | | - # not implemented for tuple searches in MultiIndex |
184 | | - # or Intervals searches in IntervalIndex |
185 | | - if isinstance(indices, (MultiIndex, IntervalIndex)): |
186 | | - return |
187 | | - |
188 | | - # nothing to test if the index is empty |
189 | | - if indices.empty: |
190 | | - return |
191 | | - value = indices[0] |
192 | | - |
193 | | - # determine the expected results (handle dupes for 'right') |
194 | | - expected_left, expected_right = 0, (indices == value).argmin() |
195 | | - if expected_right == 0: |
196 | | - # all values are the same, expected_right should be length |
197 | | - expected_right = len(indices) |
198 | | - |
199 | | - # test _searchsorted_monotonic in all cases |
200 | | - # test searchsorted only for increasing |
201 | | - if indices.is_monotonic_increasing: |
202 | | - ssm_left = indices._searchsorted_monotonic(value, side="left") |
203 | | - assert is_scalar(ssm_left) |
204 | | - assert expected_left == ssm_left |
205 | | - |
206 | | - ssm_right = indices._searchsorted_monotonic(value, side="right") |
207 | | - assert is_scalar(ssm_right) |
208 | | - assert expected_right == ssm_right |
209 | | - |
210 | | - ss_left = indices.searchsorted(value, side="left") |
211 | | - assert is_scalar(ss_left) |
212 | | - assert expected_left == ss_left |
213 | | - |
214 | | - ss_right = indices.searchsorted(value, side="right") |
215 | | - assert is_scalar(ss_right) |
216 | | - assert expected_right == ss_right |
217 | | - |
218 | | - elif indices.is_monotonic_decreasing: |
219 | | - ssm_left = indices._searchsorted_monotonic(value, side="left") |
220 | | - assert is_scalar(ssm_left) |
221 | | - assert expected_left == ssm_left |
222 | | - |
223 | | - ssm_right = indices._searchsorted_monotonic(value, side="right") |
224 | | - assert is_scalar(ssm_right) |
225 | | - assert expected_right == ssm_right |
226 | | - |
227 | | - else: |
228 | | - # non-monotonic should raise. |
229 | | - with pytest.raises(ValueError): |
230 | | - indices._searchsorted_monotonic(value, side="left") |
0 commit comments