|
3 | 3 | import numpy as np
|
4 | 4 | import pytest
|
5 | 5 |
|
6 |
| -from pandas._libs import iNaT |
7 | 6 | from pandas._libs.algos import Infinity, NegInfinity
|
8 | 7 | import pandas.util._test_decorators as td
|
9 | 8 |
|
@@ -206,91 +205,6 @@ def test_rank_signature(self):
|
206 | 205 | with pytest.raises(ValueError, match=msg):
|
207 | 206 | s.rank("average")
|
208 | 207 |
|
209 |
| - @pytest.mark.parametrize( |
210 |
| - "contents,dtype", |
211 |
| - [ |
212 |
| - ( |
213 |
| - [ |
214 |
| - -np.inf, |
215 |
| - -50, |
216 |
| - -1, |
217 |
| - -1e-20, |
218 |
| - -1e-25, |
219 |
| - -1e-50, |
220 |
| - 0, |
221 |
| - 1e-40, |
222 |
| - 1e-20, |
223 |
| - 1e-10, |
224 |
| - 2, |
225 |
| - 40, |
226 |
| - np.inf, |
227 |
| - ], |
228 |
| - "float64", |
229 |
| - ), |
230 |
| - ( |
231 |
| - [ |
232 |
| - -np.inf, |
233 |
| - -50, |
234 |
| - -1, |
235 |
| - -1e-20, |
236 |
| - -1e-25, |
237 |
| - -1e-45, |
238 |
| - 0, |
239 |
| - 1e-40, |
240 |
| - 1e-20, |
241 |
| - 1e-10, |
242 |
| - 2, |
243 |
| - 40, |
244 |
| - np.inf, |
245 |
| - ], |
246 |
| - "float32", |
247 |
| - ), |
248 |
| - ([np.iinfo(np.uint8).min, 1, 2, 100, np.iinfo(np.uint8).max], "uint8"), |
249 |
| - pytest.param( |
250 |
| - [ |
251 |
| - np.iinfo(np.int64).min, |
252 |
| - -100, |
253 |
| - 0, |
254 |
| - 1, |
255 |
| - 9999, |
256 |
| - 100000, |
257 |
| - 1e10, |
258 |
| - np.iinfo(np.int64).max, |
259 |
| - ], |
260 |
| - "int64", |
261 |
| - marks=pytest.mark.xfail( |
262 |
| - reason="iNaT is equivalent to minimum value of dtype" |
263 |
| - "int64 pending issue GH#16674" |
264 |
| - ), |
265 |
| - ), |
266 |
| - ([NegInfinity(), "1", "A", "BA", "Ba", "C", Infinity()], "object"), |
267 |
| - ], |
268 |
| - ) |
269 |
| - def test_rank_inf(self, contents, dtype): |
270 |
| - dtype_na_map = { |
271 |
| - "float64": np.nan, |
272 |
| - "float32": np.nan, |
273 |
| - "int64": iNaT, |
274 |
| - "object": None, |
275 |
| - } |
276 |
| - # Insert nans at random positions if underlying dtype has missing |
277 |
| - # value. Then adjust the expected order by adding nans accordingly |
278 |
| - # This is for testing whether rank calculation is affected |
279 |
| - # when values are interwined with nan values. |
280 |
| - values = np.array(contents, dtype=dtype) |
281 |
| - exp_order = np.array(range(len(values)), dtype="float64") + 1.0 |
282 |
| - if dtype in dtype_na_map: |
283 |
| - na_value = dtype_na_map[dtype] |
284 |
| - nan_indices = np.random.choice(range(len(values)), 5) |
285 |
| - values = np.insert(values, nan_indices, na_value) |
286 |
| - exp_order = np.insert(exp_order, nan_indices, np.nan) |
287 |
| - # shuffle the testing array and expected results in the same way |
288 |
| - random_order = np.random.permutation(len(values)) |
289 |
| - iseries = Series(values[random_order]) |
290 |
| - exp = Series(exp_order[random_order], dtype="float64") |
291 |
| - iranks = iseries.rank() |
292 |
| - tm.assert_series_equal(iranks, exp) |
293 |
| - |
294 | 208 | def test_rank_tie_methods(self):
|
295 | 209 | s = self.s
|
296 | 210 |
|
|
0 commit comments