-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: invalid rolling window on empty input #21291
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
Changes from 6 commits
efd03f9
6a5a26c
70e76df
2cd9b5c
87b2417
0349bf0
5aacfbb
4131f30
956a7f2
a69e0e0
c9c769e
da21015
5ecc436
9f5745c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,8 @@ def is_freq_type(self): | |
return self.win_type == 'freq' | ||
|
||
def validate(self): | ||
if self.window == 0: | ||
raise ValueError("Please Enter a window other than 0") | ||
if self.center is not None and not is_bool(self.center): | ||
raise ValueError("center must be a boolean") | ||
if self.min_periods is not None and not \ | ||
|
@@ -602,8 +604,8 @@ def validate(self): | |
if isinstance(window, (list, tuple, np.ndarray)): | ||
pass | ||
elif is_integer(window): | ||
if window < 0: | ||
raise ValueError("window must be non-negative") | ||
if window <= 0: | ||
raise ValueError("window must be positive") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd Combined them as pointed out by @mroeschke There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake in looking at the git diff I didn't realize they were two different methods. That said, are both required? Doesn't the call to super here raise already in the case where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd To be really honest, I don't think that it's required either. Let me remove this |
||
try: | ||
import scipy.signal as sig | ||
except ImportError: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -389,8 +389,8 @@ def test_constructor(self, which): | |
c(window=2, min_periods=1, center=False) | ||
|
||
# GH 13383 | ||
c(0) | ||
with pytest.raises(ValueError): | ||
c(0) | ||
c(-1) | ||
|
||
# not valid | ||
|
@@ -402,16 +402,17 @@ def test_constructor(self, which): | |
with pytest.raises(ValueError): | ||
c(window=2, min_periods=1, center=w) | ||
|
||
# these tests seems unnecessary here 21291 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need this comment |
||
@td.skip_if_no_scipy | ||
@pytest.mark.parametrize( | ||
'which', ['series', 'frame']) | ||
def test_constructor_with_win_type(self, which): | ||
# GH 13383 | ||
o = getattr(self, which) | ||
c = o.rolling | ||
c(0, win_type='boxcar') | ||
with pytest.raises(ValueError): | ||
c(-1, win_type='boxcar') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Errant extra line here will fail LINTing |
||
|
||
@pytest.mark.parametrize( | ||
'window', [timedelta(days=3), pd.Timedelta(days=3)]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @mroeschke pointed out can't you combine this with the check below? Don't think we need this