Skip to content

Commit 5f638ec

Browse files
committed
test(nanops): parametrize and utilize little and a lot of data
1 parent fdf1cac commit 5f638ec

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

pandas/tests/test_nanops.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,12 +1051,22 @@ def test_nans_skipna(self, samples, actual_skew):
10511051
skew = nanops.nanskew(samples, skipna=True)
10521052
tm.assert_almost_equal(skew, actual_skew)
10531053

1054-
def test_low_variance(self):
1055-
data_list = [-2.05191341e-06, -4.10391103e-07] + ([0.0] * 27)
1056-
data = np.array(data_list)
1057-
kurt = nanops.nanskew(data)
1058-
expected = -5.092092799675377 # scipy.stats.skew(data, bias=False)
1059-
tm.assert_almost_equal(kurt, expected)
1054+
@pytest.mark.parametrize(
1055+
"initial_data, nobs",
1056+
[
1057+
([-2.05191341e-05, -4.10391103e-05], 27),
1058+
([-2.05191341e-10, -4.10391103e-10], 27),
1059+
([-2.05191341e-05, -4.10391103e-05], 10_000),
1060+
([-2.05191341e-10, -4.10391103e-10], 10_000),
1061+
],
1062+
)
1063+
def test_low_variance(self, initial_data, nobs):
1064+
st = pytest.importorskip("scipy.stats")
1065+
data = np.zeros((nobs,), dtype=np.float64)
1066+
data[: len(initial_data)] = initial_data
1067+
skew = nanops.nanskew(data)
1068+
expected = st.skew(data, bias=False)
1069+
tm.assert_almost_equal(skew, expected)
10601070

10611071
@property
10621072
def prng(self):
@@ -1109,12 +1119,22 @@ def test_nans_skipna(self, samples, actual_kurt):
11091119
kurt = nanops.nankurt(samples, skipna=True)
11101120
tm.assert_almost_equal(kurt, actual_kurt)
11111121

1112-
def test_low_variance(self):
1122+
@pytest.mark.parametrize(
1123+
"initial_data, nobs",
1124+
[
1125+
([-2.05191341e-05, -4.10391103e-05], 27),
1126+
([-2.05191341e-10, -4.10391103e-10], 27),
1127+
([-2.05191341e-05, -4.10391103e-05], 10_000),
1128+
([-2.05191341e-10, -4.10391103e-10], 10_000),
1129+
],
1130+
)
1131+
def test_low_variance(self, initial_data, nobs):
11131132
# GH#57972
1114-
data_list = [-2.05191341e-05, -4.10391103e-05] + ([0.0] * 27)
1115-
data = np.array(data_list)
1133+
st = pytest.importorskip("scipy.stats")
1134+
data = np.zeros((nobs,), dtype=np.float64)
1135+
data[: len(initial_data)] = initial_data
11161136
kurt = nanops.nankurt(data)
1117-
expected = 18.087646853025614 # scipy.stats.kurtosis(data, bias=False)
1137+
expected = st.kurtosis(data, bias=False)
11181138
tm.assert_almost_equal(kurt, expected)
11191139

11201140
@property

0 commit comments

Comments
 (0)