def assert_stat_op_calc(opname, alternative, frame, has_skipna=True,<EOL>check_dtype=True, check_dates=False,<EOL>check_less_precise=False, skipna_alternative=None):
f = getattr(frame, opname)<EOL>if check_dates:<EOL><INDENT>df = DataFrame({'<STR_LIT:b>': date_range('<STR_LIT>', periods=<NUM_LIT:2>)})<EOL>result = getattr(df, opname)()<EOL>assert isinstance(result, Series)<EOL>df['<STR_LIT:a>'] = lrange(len(df))<EOL>result = getattr(df, opname)()<EOL>assert isinstance(result, Series)<EOL>assert len(result)<EOL><DEDENT>if has_skipna:<EOL><INDENT>def wrapper(x):<EOL><INDENT>return alternative(x.values)<EOL><DEDENT>skipna_wrapper = tm._make_skipna_wrapper(alternative,<EOL>skipna_alternative)<EOL>result0 = f(axis=<NUM_LIT:0>, skipna=False)<EOL>result1 = f(axis=<NUM_LIT:1>, skipna=False)<EOL>tm.assert_series_equal(result0, frame.apply(wrapper),<EOL>check_dtype=check_dtype,<EOL>check_less_precise=check_less_precise)<EOL>tm.assert_series_equal(result1, frame.apply(wrapper, axis=<NUM_LIT:1>),<EOL>check_dtype=False,<EOL>check_less_precise=check_less_precise)<EOL><DEDENT>else:<EOL><INDENT>skipna_wrapper = alternative<EOL><DEDENT>result0 = f(axis=<NUM_LIT:0>)<EOL>result1 = f(axis=<NUM_LIT:1>)<EOL>tm.assert_series_equal(result0, frame.apply(skipna_wrapper),<EOL>check_dtype=check_dtype,<EOL>check_less_precise=check_less_precise)<EOL>if opname in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>expected = frame.apply(skipna_wrapper, axis=<NUM_LIT:1>)<EOL>tm.assert_series_equal(result1, expected, check_dtype=False,<EOL>check_less_precise=check_less_precise)<EOL><DEDENT>if check_dtype:<EOL><INDENT>lcd_dtype = frame.values.dtype<EOL>assert lcd_dtype == result0.dtype<EOL>assert lcd_dtype == result1.dtype<EOL><DEDENT>with pytest.raises(ValueError, match='<STR_LIT>'):<EOL><INDENT>f(axis=<NUM_LIT:2>)<EOL><DEDENT>if has_skipna:<EOL><INDENT>all_na = frame * np.NaN<EOL>r0 = getattr(all_na, opname)(axis=<NUM_LIT:0>)<EOL>r1 = getattr(all_na, opname)(axis=<NUM_LIT:1>)<EOL>if opname in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>unit = <NUM_LIT:1> if opname == '<STR_LIT>' else <NUM_LIT:0>  <EOL>expected = pd.Series(unit, index=r0.index, dtype=r0.dtype)<EOL>tm.assert_series_equal(r0, expected)<EOL>expected = pd.Series(unit, index=r1.index, dtype=r1.dtype)<EOL>tm.assert_series_equal(r1, expected)<EOL><DEDENT><DEDENT>
Check that operator opname works as advertised on frame

Parameters
----------
opname : string
    Name of the operator to test on frame
alternative : function
    Function that opname is tested against; i.e. "frame.opname()" should
    equal "alternative(frame)".
frame : DataFrame
    The object that the tests are executed on
has_skipna : bool, default True
    Whether the method "opname" has the kwarg "skip_na"
check_dtype : bool, default True
    Whether the dtypes of the result of "frame.opname()" and
    "alternative(frame)" should be checked.
check_dates : bool, default false
    Whether opname should be tested on a Datetime Series
check_less_precise : bool, default False
    Whether results should only be compared approximately;
    passed on to tm.assert_series_equal
skipna_alternative : function, default None
    NaN-safe version of alternative