Skip to content

Commit 3e1842c

Browse files
simonjayhawkinsquintusdias
authored andcommitted
DEPR: remove .ix tests from tests/indexing/test_floats.py (pandas-dev#27533)
1 parent a87f059 commit 3e1842c

File tree

1 file changed

+39
-111
lines changed

1 file changed

+39
-111
lines changed

pandas/tests/indexing/test_floats.py

+39-111
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
from warnings import catch_warnings
2-
31
import numpy as np
42
import pytest
53

64
from pandas import DataFrame, Float64Index, Index, Int64Index, RangeIndex, Series
75
import pandas.util.testing as tm
86
from pandas.util.testing import assert_almost_equal, assert_series_equal
97

10-
ignore_ix = pytest.mark.filterwarnings("ignore:\\n.ix:FutureWarning")
11-
128

139
class TestFloatIndexers:
1410
def check(self, result, original, indexer, getitem):
@@ -62,7 +58,6 @@ def test_scalar_error(self):
6258
with pytest.raises(TypeError, match=msg):
6359
s.iloc[3.0] = 0
6460

65-
@ignore_ix
6661
def test_scalar_non_numeric(self):
6762

6863
# GH 4892
@@ -86,11 +81,7 @@ def test_scalar_non_numeric(self):
8681
]:
8782

8883
# getting
89-
for idxr, getitem in [
90-
(lambda x: x.ix, False),
91-
(lambda x: x.iloc, False),
92-
(lambda x: x, True),
93-
]:
84+
for idxr, getitem in [(lambda x: x.iloc, False), (lambda x: x, True)]:
9485

9586
# gettitem on a DataFrame is a KeyError as it is indexing
9687
# via labels on the columns
@@ -106,9 +97,8 @@ def test_scalar_non_numeric(self):
10697
"Cannot index by location index with a"
10798
" non-integer key".format(klass=type(i), kind=str(float))
10899
)
109-
with catch_warnings(record=True):
110-
with pytest.raises(error, match=msg):
111-
idxr(s)[3.0]
100+
with pytest.raises(error, match=msg):
101+
idxr(s)[3.0]
112102

113103
# label based can be a TypeError or KeyError
114104
if s.index.inferred_type in ["string", "unicode", "mixed"]:
@@ -158,10 +148,9 @@ def test_scalar_non_numeric(self):
158148
s2.loc[3.0] = 10
159149
assert s2.index.is_object()
160150

161-
for idxr in [lambda x: x.ix, lambda x: x]:
151+
for idxr in [lambda x: x]:
162152
s2 = s.copy()
163-
with catch_warnings(record=True):
164-
idxr(s2)[3.0] = 0
153+
idxr(s2)[3.0] = 0
165154
assert s2.index.is_object()
166155

167156
# fallsback to position selection, series only
@@ -175,15 +164,14 @@ def test_scalar_non_numeric(self):
175164
with pytest.raises(TypeError, match=msg):
176165
s[3.0]
177166

178-
@ignore_ix
179167
def test_scalar_with_mixed(self):
180168

181169
s2 = Series([1, 2, 3], index=["a", "b", "c"])
182170
s3 = Series([1, 2, 3], index=["a", "b", 1.5])
183171

184172
# lookup in a pure stringstr
185173
# with an invalid indexer
186-
for idxr in [lambda x: x.ix, lambda x: x, lambda x: x.iloc]:
174+
for idxr in [lambda x: x, lambda x: x.iloc]:
187175

188176
msg = (
189177
r"cannot do label indexing"
@@ -193,9 +181,8 @@ def test_scalar_with_mixed(self):
193181
klass=str(Index), kind=str(float)
194182
)
195183
)
196-
with catch_warnings(record=True):
197-
with pytest.raises(TypeError, match=msg):
198-
idxr(s2)[1.0]
184+
with pytest.raises(TypeError, match=msg):
185+
idxr(s2)[1.0]
199186

200187
with pytest.raises(KeyError, match=r"^1$"):
201188
s2.loc[1.0]
@@ -220,23 +207,6 @@ def test_scalar_with_mixed(self):
220207
expected = 2
221208
assert result == expected
222209

223-
# mixed index so we have label
224-
# indexing
225-
for idxr in [lambda x: x.ix]:
226-
with catch_warnings(record=True):
227-
228-
msg = (
229-
r"cannot do label indexing"
230-
r" on {klass} with these indexers \[1\.0\] of"
231-
r" {kind}".format(klass=str(Index), kind=str(float))
232-
)
233-
with pytest.raises(TypeError, match=msg):
234-
idxr(s3)[1.0]
235-
236-
result = idxr(s3)[1]
237-
expected = 2
238-
assert result == expected
239-
240210
msg = "Cannot index by location index with a non-integer key"
241211
with pytest.raises(TypeError, match=msg):
242212
s3.iloc[1.0]
@@ -247,7 +217,6 @@ def test_scalar_with_mixed(self):
247217
expected = 3
248218
assert result == expected
249219

250-
@ignore_ix
251220
def test_scalar_integer(self):
252221

253222
# test how scalar float indexers work on int indexes
@@ -261,22 +230,13 @@ def test_scalar_integer(self):
261230
]:
262231

263232
# coerce to equal int
264-
for idxr, getitem in [
265-
(lambda x: x.ix, False),
266-
(lambda x: x.loc, False),
267-
(lambda x: x, True),
268-
]:
233+
for idxr, getitem in [(lambda x: x.loc, False), (lambda x: x, True)]:
269234

270-
with catch_warnings(record=True):
271-
result = idxr(s)[3.0]
235+
result = idxr(s)[3.0]
272236
self.check(result, s, 3, getitem)
273237

274238
# coerce to equal int
275-
for idxr, getitem in [
276-
(lambda x: x.ix, False),
277-
(lambda x: x.loc, False),
278-
(lambda x: x, True),
279-
]:
239+
for idxr, getitem in [(lambda x: x.loc, False), (lambda x: x, True)]:
280240

281241
if isinstance(s, Series):
282242

@@ -292,20 +252,18 @@ def compare(x, y):
292252
expected = Series(100.0, index=range(len(s)), name=3)
293253

294254
s2 = s.copy()
295-
with catch_warnings(record=True):
296-
idxr(s2)[3.0] = 100
255+
idxr(s2)[3.0] = 100
297256

298-
result = idxr(s2)[3.0]
299-
compare(result, expected)
257+
result = idxr(s2)[3.0]
258+
compare(result, expected)
300259

301-
result = idxr(s2)[3]
302-
compare(result, expected)
260+
result = idxr(s2)[3]
261+
compare(result, expected)
303262

304263
# contains
305264
# coerce to equal int
306265
assert 3.0 in s
307266

308-
@ignore_ix
309267
def test_scalar_float(self):
310268

311269
# scalar float indexers work on a float index
@@ -319,11 +277,7 @@ def test_scalar_float(self):
319277

320278
# assert all operations except for iloc are ok
321279
indexer = index[3]
322-
for idxr, getitem in [
323-
(lambda x: x.ix, False),
324-
(lambda x: x.loc, False),
325-
(lambda x: x, True),
326-
]:
280+
for idxr, getitem in [(lambda x: x.loc, False), (lambda x: x, True)]:
327281

328282
# getting
329283
result = idxr(s)[indexer]
@@ -332,14 +286,12 @@ def test_scalar_float(self):
332286
# setting
333287
s2 = s.copy()
334288

335-
with catch_warnings(record=True):
336-
result = idxr(s2)[indexer]
289+
result = idxr(s2)[indexer]
337290
self.check(result, s, 3, getitem)
338291

339292
# random integer is a KeyError
340-
with catch_warnings(record=True):
341-
with pytest.raises(KeyError, match=r"^3\.5$"):
342-
idxr(s)[3.5]
293+
with pytest.raises(KeyError, match=r"^3\.5$"):
294+
idxr(s)[3.5]
343295

344296
# contains
345297
assert 3.0 in s
@@ -365,7 +317,6 @@ def test_scalar_float(self):
365317
with pytest.raises(TypeError, match=msg):
366318
s2.iloc[3.0] = 0
367319

368-
@ignore_ix
369320
def test_slice_non_numeric(self):
370321

371322
# GH 4892
@@ -397,12 +348,7 @@ def test_slice_non_numeric(self):
397348
with pytest.raises(TypeError, match=msg):
398349
s.iloc[l]
399350

400-
for idxr in [
401-
lambda x: x.ix,
402-
lambda x: x.loc,
403-
lambda x: x.iloc,
404-
lambda x: x,
405-
]:
351+
for idxr in [lambda x: x.loc, lambda x: x.iloc, lambda x: x]:
406352

407353
msg = (
408354
"cannot do slice indexing"
@@ -414,9 +360,8 @@ def test_slice_non_numeric(self):
414360
kind_int=str(int),
415361
)
416362
)
417-
with catch_warnings(record=True):
418-
with pytest.raises(TypeError, match=msg):
419-
idxr(s)[l]
363+
with pytest.raises(TypeError, match=msg):
364+
idxr(s)[l]
420365

421366
# setitem
422367
for l in [slice(3.0, 4), slice(3, 4.0), slice(3.0, 4.0)]:
@@ -429,12 +374,7 @@ def test_slice_non_numeric(self):
429374
with pytest.raises(TypeError, match=msg):
430375
s.iloc[l] = 0
431376

432-
for idxr in [
433-
lambda x: x.ix,
434-
lambda x: x.loc,
435-
lambda x: x.iloc,
436-
lambda x: x,
437-
]:
377+
for idxr in [lambda x: x.loc, lambda x: x.iloc, lambda x: x]:
438378
msg = (
439379
"cannot do slice indexing"
440380
r" on {klass} with these indexers"
@@ -445,11 +385,9 @@ def test_slice_non_numeric(self):
445385
kind_int=str(int),
446386
)
447387
)
448-
with catch_warnings(record=True):
449-
with pytest.raises(TypeError, match=msg):
450-
idxr(s)[l] = 0
388+
with pytest.raises(TypeError, match=msg):
389+
idxr(s)[l] = 0
451390

452-
@ignore_ix
453391
def test_slice_integer(self):
454392

455393
# same as above, but for Integer based indexes
@@ -468,10 +406,9 @@ def test_slice_integer(self):
468406
# getitem
469407
for l in [slice(3.0, 4), slice(3, 4.0), slice(3.0, 4.0)]:
470408

471-
for idxr in [lambda x: x.loc, lambda x: x.ix]:
409+
for idxr in [lambda x: x.loc]:
472410

473-
with catch_warnings(record=True):
474-
result = idxr(s)[l]
411+
result = idxr(s)[l]
475412

476413
# these are all label indexing
477414
# except getitem which is positional
@@ -494,9 +431,8 @@ def test_slice_integer(self):
494431
# getitem out-of-bounds
495432
for l in [slice(-6, 6), slice(-6.0, 6.0)]:
496433

497-
for idxr in [lambda x: x.loc, lambda x: x.ix]:
498-
with catch_warnings(record=True):
499-
result = idxr(s)[l]
434+
for idxr in [lambda x: x.loc]:
435+
result = idxr(s)[l]
500436

501437
# these are all label indexing
502438
# except getitem which is positional
@@ -523,10 +459,9 @@ def test_slice_integer(self):
523459
(slice(2.5, 3.5), slice(3, 4)),
524460
]:
525461

526-
for idxr in [lambda x: x.loc, lambda x: x.ix]:
462+
for idxr in [lambda x: x.loc]:
527463

528-
with catch_warnings(record=True):
529-
result = idxr(s)[l]
464+
result = idxr(s)[l]
530465
if oob:
531466
res = slice(0, 0)
532467
else:
@@ -546,11 +481,10 @@ def test_slice_integer(self):
546481
# setitem
547482
for l in [slice(3.0, 4), slice(3, 4.0), slice(3.0, 4.0)]:
548483

549-
for idxr in [lambda x: x.loc, lambda x: x.ix]:
484+
for idxr in [lambda x: x.loc]:
550485
sc = s.copy()
551-
with catch_warnings(record=True):
552-
idxr(sc)[l] = 0
553-
result = idxr(sc)[l].values.ravel()
486+
idxr(sc)[l] = 0
487+
result = idxr(sc)[l].values.ravel()
554488
assert (result == 0).all()
555489

556490
# positional indexing
@@ -585,7 +519,6 @@ def test_integer_positional_indexing(self):
585519
with pytest.raises(TypeError, match=msg):
586520
idxr(s)[l]
587521

588-
@ignore_ix
589522
def test_slice_integer_frame_getitem(self):
590523

591524
# similar to above, but on the getitem dim (of a DataFrame)
@@ -663,10 +596,7 @@ def f(idxr):
663596
s[l] = 0
664597

665598
f(lambda x: x.loc)
666-
with catch_warnings(record=True):
667-
f(lambda x: x.ix)
668599

669-
@ignore_ix
670600
def test_slice_float(self):
671601

672602
# same as above, but for floats
@@ -679,20 +609,18 @@ def test_slice_float(self):
679609
for l in [slice(3.0, 4), slice(3, 4.0), slice(3.0, 4.0)]:
680610

681611
expected = s.iloc[3:4]
682-
for idxr in [lambda x: x.ix, lambda x: x.loc, lambda x: x]:
612+
for idxr in [lambda x: x.loc, lambda x: x]:
683613

684614
# getitem
685-
with catch_warnings(record=True):
686-
result = idxr(s)[l]
615+
result = idxr(s)[l]
687616
if isinstance(s, Series):
688617
tm.assert_series_equal(result, expected)
689618
else:
690619
tm.assert_frame_equal(result, expected)
691620
# setitem
692621
s2 = s.copy()
693-
with catch_warnings(record=True):
694-
idxr(s2)[l] = 0
695-
result = idxr(s2)[l].values.ravel()
622+
idxr(s2)[l] = 0
623+
result = idxr(s2)[l].values.ravel()
696624
assert (result == 0).all()
697625

698626
def test_floating_index_doc_example(self):

0 commit comments

Comments
 (0)