Skip to content
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

TST: inline empty_frame = DataFrame({}) fixture #24886

Merged
merged 5 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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: 0 additions & 8 deletions pandas/tests/frame/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,6 @@ def timezone_frame():
return df


@pytest.fixture
def empty_frame():
"""
Fixture for empty DataFrame
"""
return DataFrame({})


@pytest.fixture
def datetime_series():
"""
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,9 @@ def test_operators_timedelta64(self):
assert df['off1'].dtype == 'timedelta64[ns]'
assert df['off2'].dtype == 'timedelta64[ns]'

def test_sum_corner(self, empty_frame):
def test_sum_corner(self):
empty_frame = DataFrame({})

axis0 = empty_frame.sum(0)
axis1 = empty_frame.sum(1)
assert isinstance(axis0, Series)
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def test_tab_completion(self):
assert key not in dir(df)
assert isinstance(df.__getitem__('A'), pd.DataFrame)

def test_not_hashable(self, empty_frame):
def test_not_hashable(self):
empty_frame = DataFrame({})

df = self.klass([1])
pytest.raises(TypeError, hash, df)
pytest.raises(TypeError, hash, empty_frame)
Expand Down Expand Up @@ -171,7 +173,8 @@ def test_get_agg_axis(self, float_frame):

pytest.raises(ValueError, float_frame._get_agg_axis, 2)

def test_nonzero(self, float_frame, float_string_frame, empty_frame):
def test_nonzero(self, float_frame, float_string_frame):
empty_frame = DataFrame({})
assert empty_frame.empty

assert not float_frame.empty
Expand Down
12 changes: 9 additions & 3 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ def test_apply_mixed_datetimelike(self):
result = df.apply(lambda x: x, axis=1)
assert_frame_equal(result, df)

def test_apply_empty(self, float_frame, empty_frame):
def test_apply_empty(self, float_frame):
# empty
empty_frame = DataFrame({})

applied = empty_frame.apply(np.sqrt)
assert applied.empty

Expand All @@ -97,8 +99,10 @@ def test_apply_empty(self, float_frame, empty_frame):
result = expected.apply(lambda x: x['a'], axis=1)
assert_frame_equal(expected, result)

def test_apply_with_reduce_empty(self, empty_frame):
def test_apply_with_reduce_empty(self):
# reduce with an empty DataFrame
empty_frame = DataFrame({})

x = []
result = empty_frame.apply(x.append, axis=1, result_type='expand')
assert_frame_equal(result, empty_frame)
Expand All @@ -116,7 +120,9 @@ def test_apply_with_reduce_empty(self, empty_frame):
# Ensure that x.append hasn't been called
assert x == []

def test_apply_deprecate_reduce(self, empty_frame):
def test_apply_deprecate_reduce(self):
empty_frame = DataFrame({})

x = []
with tm.assert_produces_warning(FutureWarning):
empty_frame.apply(x.append, axis=1, reduce=True)
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/frame/test_block_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ def test_copy(self, float_frame, float_string_frame):
copy = float_string_frame.copy()
assert copy._data is not float_string_frame._data

def test_pickle(self, float_string_frame, empty_frame, timezone_frame):
def test_pickle(self, float_string_frame, timezone_frame):
empty_frame = DataFrame({})

unpickled = tm.round_trip_pickle(float_string_frame)
assert_frame_equal(float_string_frame, unpickled)

Expand Down
9 changes: 0 additions & 9 deletions pandas/tests/series/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from pandas import Series
import pandas.util.testing as tm


Expand Down Expand Up @@ -32,11 +31,3 @@ def object_series():
s = tm.makeObjectSeries()
s.name = 'objects'
return s


@pytest.fixture
def empty_series():
"""
Fixture for empty Series
"""
return Series([], index=[])
4 changes: 3 additions & 1 deletion pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def test_scalar_conversion(self):
assert int(Series([1.])) == 1
assert long(Series([1.])) == 1

def test_constructor(self, datetime_series, empty_series):
def test_constructor(self, datetime_series):
empty_series = Series([], index=[])

assert datetime_series.index.is_all_dates

# Pass in Series
Expand Down