Skip to content
Prev Previous commit
Next Next commit
flake8 fixups
  • Loading branch information
jbrockmendel committed Jan 26, 2019
commit 2a2d0af48a9713c7b6c16f4430a95d801d10913c
16 changes: 7 additions & 9 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def test_stat_op_api(self, float_frame, float_string_frame):
assert_stat_op_api('median', float_frame, float_string_frame)

try:
from scipy.stats import skew, kurtosis
from scipy.stats import skew, kurtosis # noqa:F401
assert_stat_op_api('skew', float_frame, float_string_frame)
assert_stat_op_api('kurt', float_frame, float_string_frame)
except ImportError:
Expand All @@ -739,19 +739,19 @@ def var(x):
return np.var(x, ddof=1)

def std(x):
return x: np.std(x, ddof=1)
return np.std(x, ddof=1)

def sem(x):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are all these for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These get passed to assert_stat_op_calc. In the status quo these are defined in separate test methods and are mostly named alt

return np.std(x, ddof=1) / np.sqrt(len(x))

def skew(x):
from scipy.stats import skew
def skewness(x):
from scipy.stats import skew # noqa:F811
if len(x) < 3:
return np.nan
return skew(x, bias=False)

def kurt(x):
from scipy.stats import kurtosis
from scipy.stats import kurtosis # noqa:F811
if len(x) < 4:
return np.nan
return kurtosis(x, bias=False)
Expand All @@ -770,20 +770,18 @@ def kurt(x):
check_dates=True)
assert_stat_op_calc('product', np.prod, float_frame_with_na)


assert_stat_op_calc('mad', mad, float_frame_with_na)
assert_stat_op_calc('var', var, float_frame_with_na)
assert_stat_op_calc('std', std, float_frame_with_na)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a future pass should parameterize this test

assert_stat_op_calc('sem', sem, float_frame_with_na)


assert_stat_op_calc('count', count, float_frame_with_na,
has_skipna=False, check_dtype=False,
check_dates=True)

try:
from scipy import skew, kurtosis
assert_stat_op_calc('skew', skew, float_frame_with_na)
from scipy import skew, kurtosis # noqa:F401
assert_stat_op_calc('skew', skewness, float_frame_with_na)
assert_stat_op_calc('kurt', kurt, float_frame_with_na)
except ImportError:
pass
Expand Down