Skip to content

Commit 4543d07

Browse files
author
tp
committed
test changes
1 parent b0a7a0f commit 4543d07

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ def is_any_frame():
568568
result = None
569569

570570
f = self._is_cython_func(arg)
571-
if f:
571+
if f is not None:
572572
return getattr(self, f)(*args, **kwargs), None
573573

574574
# caller can react

pandas/tests/test_nanops.py

+26-22
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import pandas.core.nanops as nanops
1414
import pandas.util.testing as tm
1515
import pandas.util._test_decorators as td
16-
from pandas.compat.numpy import _np_version_under1p13
16+
from pandas.compat.numpy import (_np_version_under1p13, _np_version_under1p10,
17+
_np_version_under1p12)
1718

1819
use_bn = nanops._USE_BOTTLENECK
1920

@@ -995,10 +996,16 @@ def prng(self):
995996

996997

997998
@pytest.fixture(params=[
998-
pd.Series([1, 2, 3, 4, 5, 6]),
999-
pd.DataFrame([[1, 2, 3], [4, 5, 6]])
999+
pd.Series([1, 2, 3, 4]),
1000+
pd.DataFrame([[1, 2], [3, 4]]),
1001+
pd.Series([np.nan, 2, 3, 4]),
1002+
pd.DataFrame([[np.nan, 2], [3, 4]]),
1003+
pd.Series(),
1004+
pd.DataFrame(),
1005+
pd.Series([np.nan]),
1006+
pd.DataFrame([[np.nan]]),
10001007
])
1001-
def nan_test_object(request):
1008+
def series_or_frame(request):
10021009
return request.param
10031010

10041011

@@ -1010,30 +1017,27 @@ def nan_test_object(request):
10101017
(np.median, np.nanmedian),
10111018
(np.max, np.nanmax),
10121019
(np.min, np.nanmin),
1013-
])
1014-
def test_np_nan_functions(standard, nan_method, nan_test_object):
1015-
tm.assert_almost_equal(nan_test_object.agg(standard),
1016-
nan_test_object.agg(nan_method),
1020+
], ids=lambda x: x.__name__)
1021+
def test_np_nan_functions(standard, nan_method, series_or_frame):
1022+
tm.assert_almost_equal(series_or_frame.agg(standard),
1023+
series_or_frame.agg(nan_method),
10171024
check_exact=True)
10181025

10191026

1020-
@td.skip_if_no("numpy", min_version="1.10.0")
1021-
def test_np_nanprod(nan_test_object):
1022-
tm.assert_almost_equal(nan_test_object.agg(np.prod),
1023-
nan_test_object.agg(np.nanprod),
1027+
@pytest.mark.skipif(_np_version_under1p10, reason="requires numpy>=1.10")
1028+
def test_np_nanprod(series_or_frame):
1029+
tm.assert_almost_equal(series_or_frame.agg(np.prod),
1030+
series_or_frame.agg(np.nanprod),
10241031
check_exact=True)
10251032

10261033

1027-
@td.skip_if_no("numpy", min_version="1.12.0")
1028-
def test_np_nancumprod(nan_test_object):
1029-
# Not using pytest params for methods as will fail at build time
1030-
methods = [
1031-
(np.cumprod, np.nancumprod),
1032-
(np.cumsum, np.nancumsum)
1033-
]
1034-
for standard, nan_method in methods:
1035-
tm.assert_almost_equal(nan_test_object.agg(standard),
1036-
nan_test_object.agg(nan_method),
1034+
@pytest.mark.skipif(_np_version_under1p12, reason="requires numpy>=1.12")
1035+
def test_np_nancumprod(series_or_frame):
1036+
funcs = [(np.cumprod, np.nancumprod),
1037+
(np.cumsum, np.nancumsum)]
1038+
for standard, nan_method in funcs:
1039+
tm.assert_almost_equal(series_or_frame.agg(standard),
1040+
series_or_frame.agg(nan_method),
10371041
check_exact=True)
10381042

10391043

0 commit comments

Comments
 (0)