Series.rolling(3).quantile(10) segmentation fault #15463

Closed
kernc opened this Issue Feb 20, 2017 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

kernc commented Feb 20, 2017 edited

Code Sample, a copy-pastable example if possible

>>> pd.Series(np.arange(10)).rolling(3).quantile(10)
[1]    20214 segmentation fault

Problem description

The value 10 is over the fraction of 1 which .quantile() works with, but I guess it still shouldn't crash my interpreter.

Expected Output

ValueError: quantile value 10 not in [0, 1]

Output of pd.show_versions()

pandas 0.19.0+479.g4842bc7

Contributor

jreback commented Feb 21, 2017

yep, not very friendly...PR's appreciated!

jreback added this to the Next Major Release milestone Feb 21, 2017

Contributor

csizsek commented Feb 22, 2017 edited

Hi @kernc and @jreback , I'm thinking about fixing this issue. Any idea where to start? (I have read the contribution documentation, set up the environment and was able to reproduce.)

Contributor

jreback commented Feb 22, 2017

you can add a validation right here 0 <= quantile <= 1: https://github.com/pandas-dev/pandas/blob/master/pandas/window.pyx#L1288, and raise a ValueError if not in range. please add some tests as well.

thanks!

@jreback jreback modified the milestone: 0.20.0, Next Major Release Feb 22, 2017

jreback closed this in b94186d Feb 23, 2017

@AnkurDedania AnkurDedania added a commit to AnkurDedania/pandas that referenced this issue Mar 21, 2017

@csizsek @AnkurDedania csizsek + AnkurDedania BUG: The roll_quantile function now throws an exception instead of ca…
…using a segfault when quantile is out of range


closes #15463

Author: Peter Csizsek <peter.csizsek@gmail.com>

Closes #15476 from csizsek/fix-rolling-quantile-segfault and squashes the following commits:

e31e5be [Peter Csizsek] Correctly catching exception in the test for Rolling.quantile.
4eea34a [Peter Csizsek] Refactored and moved exception throwing test to a new function for Rolling.quantile().
8b1e020 [Peter Csizsek] Added a note about the Rolling.quantile bug fix to the changelog.
f39b122 [Peter Csizsek] Added a new test case to roll_quantile_test to trigger a TypeError when called with a string.
f736ca2 [Peter Csizsek] The roll_quantile function in window.pyx now raises a ValueError when the quantile value is not in [0.0, 1.0]
4c015e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment