Skip to content

Commit b88faa0

Browse files
authored
TST: rename fixtures named 'indices' to 'index' (#35024)
1 parent a347e76 commit b88faa0

21 files changed

+543
-562
lines changed

pandas/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def _create_mi_with_dt64tz_level():
408408

409409

410410
@pytest.fixture(params=indices_dict.keys())
411-
def indices(request):
411+
def index(request):
412412
"""
413413
Fixture for many "simple" kinds of indices.
414414
@@ -423,7 +423,7 @@ def indices(request):
423423

424424

425425
# Needed to generate cartesian product of indices
426-
index_fixture2 = indices
426+
index_fixture2 = index
427427

428428

429429
# ----------------------------------------------------------------
@@ -478,11 +478,11 @@ def _create_series(index):
478478

479479

480480
@pytest.fixture
481-
def series_with_simple_index(indices):
481+
def series_with_simple_index(index):
482482
"""
483483
Fixture for tests on series with changing types of indices.
484484
"""
485-
return _create_series(indices)
485+
return _create_series(index)
486486

487487

488488
_narrow_dtypes = [

pandas/tests/base/test_misc.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ def test_searchsorted(index_or_series_obj):
173173
assert 0 <= index <= len(obj)
174174

175175

176-
def test_access_by_position(indices):
177-
index = indices
176+
def test_access_by_position(index):
178177

179178
if len(index) == 0:
180179
pytest.skip("Test doesn't make sense on empty data")

pandas/tests/generic/test_generic.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ def test_metadata_propagation(self):
251251
self.check_metadata(v1 & v2)
252252
self.check_metadata(v1 | v2)
253253

254-
def test_head_tail(self, indices):
254+
def test_head_tail(self, index):
255255
# GH5370
256256

257-
o = self._construct(shape=len(indices))
257+
o = self._construct(shape=len(index))
258258

259259
axis = o._get_axis_name(0)
260-
setattr(o, axis, indices)
260+
setattr(o, axis, index)
261261

262262
o.head()
263263

@@ -273,8 +273,8 @@ def test_head_tail(self, indices):
273273
self._compare(o.tail(len(o) + 1), o)
274274

275275
# neg index
276-
self._compare(o.head(-3), o.head(len(indices) - 3))
277-
self._compare(o.tail(-3), o.tail(len(indices) - 3))
276+
self._compare(o.head(-3), o.head(len(index) - 3))
277+
self._compare(o.tail(-3), o.tail(len(index) - 3))
278278

279279
def test_sample(self):
280280
# Fixes issue: 2419

pandas/tests/generic/test_to_xarray.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
class TestDataFrameToXArray:
1212
@td.skip_if_no("xarray", "0.10.0")
13-
def test_to_xarray_index_types(self, indices):
14-
if isinstance(indices, pd.MultiIndex):
13+
def test_to_xarray_index_types(self, index):
14+
if isinstance(index, pd.MultiIndex):
1515
pytest.skip("MultiIndex is tested separately")
16-
if len(indices) == 0:
16+
if len(index) == 0:
1717
pytest.skip("Test doesn't make sense for empty index")
1818

1919
from xarray import Dataset
@@ -31,7 +31,7 @@ def test_to_xarray_index_types(self, indices):
3131
}
3232
)
3333

34-
df.index = indices[:3]
34+
df.index = index[:3]
3535
df.index.name = "foo"
3636
df.columns.name = "bar"
3737
result = df.to_xarray()
@@ -93,17 +93,17 @@ def test_to_xarray(self):
9393

9494
class TestSeriesToXArray:
9595
@td.skip_if_no("xarray", "0.10.0")
96-
def test_to_xarray_index_types(self, indices):
97-
if isinstance(indices, pd.MultiIndex):
96+
def test_to_xarray_index_types(self, index):
97+
if isinstance(index, pd.MultiIndex):
9898
pytest.skip("MultiIndex is tested separately")
9999

100100
from xarray import DataArray
101101

102-
s = Series(range(len(indices)), index=indices, dtype="int64")
102+
s = Series(range(len(index)), index=index, dtype="int64")
103103
s.index.name = "foo"
104104
result = s.to_xarray()
105105
repr(result)
106-
assert len(result) == len(indices)
106+
assert len(result) == len(index)
107107
assert len(result.coords) == 1
108108
tm.assert_almost_equal(list(result.coords.keys()), ["foo"])
109109
assert isinstance(result, DataArray)

pandas/tests/indexes/categorical/test_category.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TestCategoricalIndex(Base):
1515
_holder = CategoricalIndex
1616

1717
@pytest.fixture
18-
def indices(self, request):
18+
def index(self, request):
1919
return tm.makeCategoricalIndex(100)
2020

2121
def create_index(self, categories=None, ordered=False):
@@ -354,7 +354,7 @@ def test_identical(self):
354354
assert ci1.identical(ci1.copy())
355355
assert not ci1.identical(ci2)
356356

357-
def test_ensure_copied_data(self, indices):
357+
def test_ensure_copied_data(self, index):
358358
# gh-12309: Check the "copy" argument of each
359359
# Index.__new__ is honored.
360360
#
@@ -364,12 +364,12 @@ def test_ensure_copied_data(self, indices):
364364
# FIXME: is this test still meaningful?
365365
_base = lambda ar: ar if getattr(ar, "base", None) is None else ar.base
366366

367-
result = CategoricalIndex(indices.values, copy=True)
368-
tm.assert_index_equal(indices, result)
369-
assert _base(indices.values) is not _base(result.values)
367+
result = CategoricalIndex(index.values, copy=True)
368+
tm.assert_index_equal(index, result)
369+
assert _base(index.values) is not _base(result.values)
370370

371-
result = CategoricalIndex(indices.values, copy=False)
372-
assert _base(indices.values) is _base(result.values)
371+
result = CategoricalIndex(index.values, copy=False)
372+
assert _base(index.values) is _base(result.values)
373373

374374
def test_equals_categorical(self):
375375
ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)

0 commit comments

Comments
 (0)