Skip to content

The roll_quantile function now throws an exception instead of causing a segfault #15476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pandas/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,14 +1084,15 @@ def alt(x):

self._check_moment_func(f, alt, name='quantile', quantile=q)

self.assertRaises(ValueError, mom.rolling_quantile,
np.array([1, 2, 3]), window=3, quantile=-0.1)
def test_rolling_quantile_param(self):
ser = Series([0.0, .1, .5, .9, 1.0])

self.assertRaises(ValueError, mom.rolling_quantile,
np.array([1, 2, 3]), window=3, quantile=10)
with self.assertRaises(ValueError):
ser.rolling(3).quantile(-0.1)
ser.rolling(3).quantile(10.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

The second call needs it's own with block, otherwise the first call's risen ValueError might (in theory) mask the second one's, or vice versa.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed :D


self.assertRaises(TypeError, mom.rolling_quantile,
np.array([1, 2, 3]), window=3, quantile='foo')
with self.assertRaises(TypeError):
ser.rolling(3).quantile('foo')

def test_rolling_apply(self):
# suppress warnings about empty slices, as we are deliberately testing
Expand Down