Skip to content

Commit

Permalink
Review (jreback)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Aug 31, 2018
1 parent f74b29f commit 39b251d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
26 changes: 13 additions & 13 deletions pandas/tests/series/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@


@pytest.fixture
def ts():
ts = tm.makeTimeSeries()
ts.name = 'ts'
return ts
def datetime_series():
s = tm.makeTimeSeries()
s.name = 'ts'
return s


@pytest.fixture
def series():
series = tm.makeStringSeries()
series.name = 'series'
return series
def string_series():
s = tm.makeStringSeries()
s.name = 'series'
return s


@pytest.fixture
def objSeries():
objSeries = tm.makeObjectSeries()
objSeries.name = 'objects'
return objSeries
def object_series():
s = tm.makeObjectSeries()
s.name = 'objects'
return s


@pytest.fixture
def empty():
def empty_series():
return Series([], index=[])
32 changes: 16 additions & 16 deletions pandas/tests/series/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
import pandas.util.testing as tm


class TestSeriesAlterAxes():
class TestSeriesAlterAxes(object):

def test_setindex(self, series):
def test_setindex(self, string_series):
# wrong type
pytest.raises(TypeError, setattr, series, 'index', None)
pytest.raises(TypeError, setattr, string_series, 'index', None)

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

# works
series.index = np.arange(len(series))
assert isinstance(series.index, Index)
string_series.index = np.arange(len(string_series))
assert isinstance(string_series.index, Index)

# Renaming

def test_rename(self, ts):
def test_rename(self, datetime_series):
ts = datetime_series
renamer = lambda x: x.strftime('%Y%m%d')
renamed = ts.rename(renamer)
assert renamed.index[0] == renamer(ts.index[0])
Expand Down Expand Up @@ -99,12 +100,12 @@ def test_set_name(self):
assert s.name is None
assert s is not s2

def test_rename_inplace(self, ts):
def test_rename_inplace(self, datetime_series):
renamer = lambda x: x.strftime('%Y%m%d')
expected = renamer(ts.index[0])
expected = renamer(datetime_series.index[0])

ts.rename(renamer, inplace=True)
assert ts.index[0] == expected
datetime_series.rename(renamer, inplace=True)
assert datetime_series.index[0] == expected

def test_set_index_makes_timeseries(self):
idx = tm.makeDateIndex(10)
Expand Down Expand Up @@ -221,11 +222,10 @@ def test_reorder_levels(self):
expected = Series(np.arange(6), index=e_idx)
tm.assert_series_equal(result, expected)

def test_rename_axis_inplace(self, ts):
def test_rename_axis_inplace(self, datetime_series):
# GH 15704
series = ts.copy()
expected = series.rename_axis('foo')
result = series.copy()
expected = datetime_series.rename_axis('foo')
result = datetime_series
no_return = result.rename_axis('foo', inplace=True)

assert no_return is None
Expand Down

0 comments on commit 39b251d

Please sign in to comment.