Skip to content

TST: Remove subset of singleton fixtures #24873

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
get rid of float_frame_with_na fixture
  • Loading branch information
jbrockmendel committed Jan 22, 2019
commit 26ebc215544557b366576f93f5aaadb9ce984020
14 changes: 0 additions & 14 deletions pandas/tests/frame/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@ def float_frame():
return DataFrame(tm.getSeriesData())


@pytest.fixture
def float_frame_with_na():
"""
Fixture for DataFrame of floats with index of unique strings

Columns are ['A', 'B', 'C', 'D']; some entries are missing
"""
df = DataFrame(tm.getSeriesData())
# set some NAs
df.loc[5:10] = np.nan
df.loc[15:20, -2:] = np.nan
return df


@pytest.fixture
def bool_frame_with_na():
"""
Expand Down
55 changes: 36 additions & 19 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,9 @@ def test_reduce_mixed_frame(self):
np.array([2, 150, 'abcde'], dtype=object))
tm.assert_series_equal(test, df.T.sum(axis=1))

def test_count(self, float_frame_with_na, float_frame, float_string_frame):
def test_count(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

f = lambda s: notna(s).sum()
assert_stat_op_calc('count', f, float_frame_with_na, has_skipna=False,
check_dtype=False, check_dates=True)
Expand Down Expand Up @@ -740,8 +742,9 @@ def test_count(self, float_frame_with_na, float_frame, float_string_frame):
expected = Series(0, index=[])
tm.assert_series_equal(result, expected)

def test_nunique(self, float_frame_with_na, float_frame,
float_string_frame):
def test_nunique(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

f = lambda s: len(algorithms.unique1d(s.dropna()))
assert_stat_op_calc('nunique', f, float_frame_with_na,
has_skipna=False, check_dtype=False,
Expand All @@ -758,8 +761,9 @@ def test_nunique(self, float_frame_with_na, float_frame,
tm.assert_series_equal(df.nunique(axis=1, dropna=False),
Series({0: 1, 1: 3, 2: 2}))

def test_sum(self, float_frame_with_na, mixed_float_frame,
float_frame, float_string_frame):
def test_sum(self, mixed_float_frame, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

assert_stat_op_api('sum', float_frame, float_string_frame,
has_numeric_only=True)
assert_stat_op_calc('sum', np.sum, float_frame_with_na,
Expand Down Expand Up @@ -792,20 +796,24 @@ def test_stat_operators_attempt_obj_array(self, method):
if method in ['sum', 'prod']:
tm.assert_series_equal(result, expected)

def test_mean(self, float_frame_with_na, float_frame, float_string_frame):
def test_mean(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

assert_stat_op_calc('mean', np.mean, float_frame_with_na,
check_dates=True)
assert_stat_op_api('mean', float_frame, float_string_frame)

def test_product(self, float_frame_with_na, float_frame,
float_string_frame):
def test_product(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

assert_stat_op_calc('product', np.prod, float_frame_with_na)
assert_stat_op_api('product', float_frame, float_string_frame)

# TODO: Ensure warning isn't emitted in the first place
@pytest.mark.filterwarnings("ignore:All-NaN:RuntimeWarning")
def test_median(self, float_frame_with_na, float_frame,
float_string_frame):
def test_median(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

def wrapper(x):
if isna(x).any():
return np.nan
Expand All @@ -815,8 +823,9 @@ def wrapper(x):
check_dates=True)
assert_stat_op_api('median', float_frame, float_string_frame)

def test_min(self, float_frame_with_na, int_frame,
float_frame, float_string_frame):
def test_min(self, int_frame, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", RuntimeWarning)
assert_stat_op_calc('min', np.min, float_frame_with_na,
Expand Down Expand Up @@ -874,8 +883,9 @@ def test_cummax(self):
cummax_xs = datetime_frame.cummax(axis=1)
assert np.shape(cummax_xs) == np.shape(datetime_frame)

def test_max(self, float_frame_with_na, int_frame,
float_frame, float_string_frame):
def test_max(self, int_frame, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", RuntimeWarning)
assert_stat_op_calc('max', np.max, float_frame_with_na,
Expand All @@ -884,12 +894,14 @@ def test_max(self, float_frame_with_na, int_frame,
assert_stat_op_api('max', float_frame, float_string_frame)

def test_mad(self, float_frame_with_na, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()

f = lambda x: np.abs(x - x.mean()).mean()
assert_stat_op_calc('mad', f, float_frame_with_na)
assert_stat_op_api('mad', float_frame, float_string_frame)

def test_var_std(self, float_frame_with_na, float_frame,
float_string_frame):
def test_var_std(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()
datetime_frame = DataFrame(tm.getTimeSeriesData())

alt = lambda x: np.var(x, ddof=1)
Expand Down Expand Up @@ -1013,7 +1025,8 @@ def test_cumprod(self):
df.cumprod(0)
df.cumprod(1)

def test_sem(self, float_frame_with_na, float_frame, float_string_frame):
def test_sem(self, float_frame, float_string_frame):
float_frame_with_na = tm.get_float_frame_with_na()
datetime_frame = DataFrame(tm.getTimeSeriesData())

alt = lambda x: np.std(x, ddof=1) / np.sqrt(len(x))
Expand All @@ -1034,9 +1047,11 @@ def test_sem(self, float_frame_with_na, float_frame, float_string_frame):
assert not (result < 0).any()

@td.skip_if_no_scipy
def test_skew(self, float_frame_with_na, float_frame, float_string_frame):
def test_skew(self, float_frame, float_string_frame):
from scipy.stats import skew

float_frame_with_na = tm.get_float_frame_with_na()

def alt(x):
if len(x) < 3:
return np.nan
Expand All @@ -1046,9 +1061,11 @@ def alt(x):
assert_stat_op_api('skew', float_frame, float_string_frame)

@td.skip_if_no_scipy
def test_kurt(self, float_frame_with_na, float_frame, float_string_frame):
def test_kurt(self, float_frame, float_string_frame):
from scipy.stats import kurtosis

float_frame_with_na = tm.get_float_frame_with_na()

def alt(x):
if len(x) < 4:
return np.nan
Expand Down