Skip to content

Commit 412eb98

Browse files
committed
Add parametrized test
1 parent a02183a commit 412eb98

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

pandas/tests/test_window.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,22 +1173,21 @@ def test_rolling_quantile_series(self):
11731173
s = Series(arr)
11741174
q1 = s.quantile(0.1)
11751175
q2 = s.rolling(100).quantile(0.1).iloc[-1]
1176-
tm.assert_almost_equal(q1, q2)
1177-
1178-
q1 = s.quantile(0.1, interpolation='lower')
1179-
q2 = s.rolling(100).quantile(0.1, interpolation='lower').iloc[-1]
1180-
tm.assert_almost_equal(q1, q2)
11811176

1182-
q1 = s.quantile(0.1, interpolation='higher')
1183-
q2 = s.rolling(100).quantile(0.1, interpolation='higher').iloc[-1]
11841177
tm.assert_almost_equal(q1, q2)
11851178

1186-
q1 = s.quantile(0.1, interpolation='nearest')
1187-
q2 = s.rolling(100).quantile(0.1, interpolation='nearest').iloc[-1]
1188-
tm.assert_almost_equal(q1, q2)
1179+
@pytest.mark.parametrize('quantile', [0.0, 0.1, 0.45, 0.5, 1])
1180+
@pytest.mark.parametrize('interpolation', ['linear', 'lower', 'higher',
1181+
'nearest', 'midpoint'])
1182+
def test_rolling_quantile_interpolation_options(self, quantile,
1183+
interpolation):
1184+
# Tests that rolling window's quantile behavior is analogus to
1185+
# Series' quantile for each interpolation option
1186+
size = 100
1187+
s = Series(np.arange(size))
1188+
q1 = s.quantile(quantile, interpolation)
1189+
q2 = s.rolling(size).quantile(quantile, interpolation).iloc[-1]
11891190

1190-
q1 = s.quantile(0.1, interpolation='midpoint')
1191-
q2 = s.rolling(100).quantile(0.1, interpolation='midpoint').iloc[-1]
11921191
tm.assert_almost_equal(q1, q2)
11931192

11941193
def test_rolling_quantile_param(self):

0 commit comments

Comments
 (0)