Skip to content

Commit c917d81

Browse files
committed
Review (jreback)
1 parent f74b29f commit c917d81

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

pandas/tests/series/conftest.py

+31-13
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,44 @@
66

77

88
@pytest.fixture
9-
def ts():
10-
ts = tm.makeTimeSeries()
11-
ts.name = 'ts'
12-
return ts
9+
def datetime_series():
10+
"""
11+
Fixture for Series of floats with DatetimeIndex
12+
13+
See pandas.util.testing.makeTimeSeries
14+
"""
15+
s = tm.makeTimeSeries()
16+
s.name = 'ts'
17+
return s
1318

1419

1520
@pytest.fixture
16-
def series():
17-
series = tm.makeStringSeries()
18-
series.name = 'series'
19-
return series
21+
def string_series():
22+
"""
23+
Fixture for Series of floats with Index of unique strings
24+
25+
See pandas.util.testing.makeStringSeries
26+
"""
27+
s = tm.makeStringSeries()
28+
s.name = 'series'
29+
return s
2030

2131

2232
@pytest.fixture
23-
def objSeries():
24-
objSeries = tm.makeObjectSeries()
25-
objSeries.name = 'objects'
26-
return objSeries
33+
def object_series():
34+
"""
35+
Fixture for Series of dtype datetime64[ns] with Index of unique strings
36+
37+
See pandas.util.testing.makeObjectSeries
38+
"""
39+
s = tm.makeObjectSeries()
40+
s.name = 'objects'
41+
return s
2742

2843

2944
@pytest.fixture
30-
def empty():
45+
def empty_series():
46+
"""
47+
Fixture for empty Series
48+
"""
3149
return Series([], index=[])

pandas/tests/series/test_alter_axes.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,24 @@
1313
import pandas.util.testing as tm
1414

1515

16-
class TestSeriesAlterAxes():
16+
class TestSeriesAlterAxes(object):
1717

18-
def test_setindex(self, series):
18+
def test_setindex(self, string_series):
1919
# wrong type
20-
pytest.raises(TypeError, setattr, series, 'index', None)
20+
pytest.raises(TypeError, setattr, string_series, 'index', None)
2121

2222
# wrong length
23-
pytest.raises(Exception, setattr, series, 'index',
24-
np.arange(len(series) - 1))
23+
pytest.raises(Exception, setattr, string_series, 'index',
24+
np.arange(len(string_series) - 1))
2525

2626
# works
27-
series.index = np.arange(len(series))
28-
assert isinstance(series.index, Index)
27+
string_series.index = np.arange(len(string_series))
28+
assert isinstance(string_series.index, Index)
2929

3030
# Renaming
3131

32-
def test_rename(self, ts):
32+
def test_rename(self, datetime_series):
33+
ts = datetime_series
3334
renamer = lambda x: x.strftime('%Y%m%d')
3435
renamed = ts.rename(renamer)
3536
assert renamed.index[0] == renamer(ts.index[0])
@@ -99,12 +100,12 @@ def test_set_name(self):
99100
assert s.name is None
100101
assert s is not s2
101102

102-
def test_rename_inplace(self, ts):
103+
def test_rename_inplace(self, datetime_series):
103104
renamer = lambda x: x.strftime('%Y%m%d')
104-
expected = renamer(ts.index[0])
105+
expected = renamer(datetime_series.index[0])
105106

106-
ts.rename(renamer, inplace=True)
107-
assert ts.index[0] == expected
107+
datetime_series.rename(renamer, inplace=True)
108+
assert datetime_series.index[0] == expected
108109

109110
def test_set_index_makes_timeseries(self):
110111
idx = tm.makeDateIndex(10)
@@ -221,11 +222,10 @@ def test_reorder_levels(self):
221222
expected = Series(np.arange(6), index=e_idx)
222223
tm.assert_series_equal(result, expected)
223224

224-
def test_rename_axis_inplace(self, ts):
225+
def test_rename_axis_inplace(self, datetime_series):
225226
# GH 15704
226-
series = ts.copy()
227-
expected = series.rename_axis('foo')
228-
result = series.copy()
227+
expected = datetime_series.rename_axis('foo')
228+
result = datetime_series
229229
no_return = result.rename_axis('foo', inplace=True)
230230

231231
assert no_return is None

0 commit comments

Comments
 (0)