Skip to content

TST: rename fixtures named 'indices' to 'index' #35024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def _create_mi_with_dt64tz_level():


@pytest.fixture(params=indices_dict.keys())
def indices(request):
def index(request):
"""
Fixture for many "simple" kinds of indices.

Expand All @@ -423,7 +423,7 @@ def indices(request):


# Needed to generate cartesian product of indices
index_fixture2 = indices
index_fixture2 = index


# ----------------------------------------------------------------
Expand Down Expand Up @@ -478,11 +478,11 @@ def _create_series(index):


@pytest.fixture
def series_with_simple_index(indices):
def series_with_simple_index(index):
"""
Fixture for tests on series with changing types of indices.
"""
return _create_series(indices)
return _create_series(index)


_narrow_dtypes = [
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/base/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def test_searchsorted(index_or_series_obj):
assert 0 <= index <= len(obj)


def test_access_by_position(indices):
index = indices
def test_access_by_position(index):

if len(index) == 0:
pytest.skip("Test doesn't make sense on empty data")
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,13 @@ def test_metadata_propagation(self):
self.check_metadata(v1 & v2)
self.check_metadata(v1 | v2)

def test_head_tail(self, indices):
def test_head_tail(self, index):
# GH5370

o = self._construct(shape=len(indices))
o = self._construct(shape=len(index))

axis = o._get_axis_name(0)
setattr(o, axis, indices)
setattr(o, axis, index)

o.head()

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

# neg index
self._compare(o.head(-3), o.head(len(indices) - 3))
self._compare(o.tail(-3), o.tail(len(indices) - 3))
self._compare(o.head(-3), o.head(len(index) - 3))
self._compare(o.tail(-3), o.tail(len(index) - 3))

def test_sample(self):
# Fixes issue: 2419
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/generic/test_to_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

class TestDataFrameToXArray:
@td.skip_if_no("xarray", "0.10.0")
def test_to_xarray_index_types(self, indices):
if isinstance(indices, pd.MultiIndex):
def test_to_xarray_index_types(self, index):
if isinstance(index, pd.MultiIndex):
pytest.skip("MultiIndex is tested separately")
if len(indices) == 0:
if len(index) == 0:
pytest.skip("Test doesn't make sense for empty index")

from xarray import Dataset
Expand All @@ -31,7 +31,7 @@ def test_to_xarray_index_types(self, indices):
}
)

df.index = indices[:3]
df.index = index[:3]
df.index.name = "foo"
df.columns.name = "bar"
result = df.to_xarray()
Expand Down Expand Up @@ -93,17 +93,17 @@ def test_to_xarray(self):

class TestSeriesToXArray:
@td.skip_if_no("xarray", "0.10.0")
def test_to_xarray_index_types(self, indices):
if isinstance(indices, pd.MultiIndex):
def test_to_xarray_index_types(self, index):
if isinstance(index, pd.MultiIndex):
pytest.skip("MultiIndex is tested separately")

from xarray import DataArray

s = Series(range(len(indices)), index=indices, dtype="int64")
s = Series(range(len(index)), index=index, dtype="int64")
s.index.name = "foo"
result = s.to_xarray()
repr(result)
assert len(result) == len(indices)
assert len(result) == len(index)
assert len(result.coords) == 1
tm.assert_almost_equal(list(result.coords.keys()), ["foo"])
assert isinstance(result, DataArray)
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/indexes/categorical/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestCategoricalIndex(Base):
_holder = CategoricalIndex

@pytest.fixture
def indices(self, request):
def index(self, request):
return tm.makeCategoricalIndex(100)

def create_index(self, categories=None, ordered=False):
Expand Down Expand Up @@ -354,7 +354,7 @@ def test_identical(self):
assert ci1.identical(ci1.copy())
assert not ci1.identical(ci2)

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

result = CategoricalIndex(indices.values, copy=True)
tm.assert_index_equal(indices, result)
assert _base(indices.values) is not _base(result.values)
result = CategoricalIndex(index.values, copy=True)
tm.assert_index_equal(index, result)
assert _base(index.values) is not _base(result.values)

result = CategoricalIndex(indices.values, copy=False)
assert _base(indices.values) is _base(result.values)
result = CategoricalIndex(index.values, copy=False)
assert _base(index.values) is _base(result.values)

def test_equals_categorical(self):
ci1 = CategoricalIndex(["a", "b"], categories=["a", "b"], ordered=True)
Expand Down
Loading