Skip to content

Commit c18a31b

Browse files
carlosdanielcsantosjreback
carlosdanielcsantos
authored andcommitted
Fixing test of assertion of closed parameter in fixed windows
Style corrections
1 parent 90dfb0c commit c18a31b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

doc/source/computation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ from present information back to past information. This allows the rolling windo
490490
df["right"] = df.rolling('2s', closed='right').x.sum() # default
491491
df["both"] = df.rolling('2s', closed='both').x.sum()
492492
df["left"] = df.rolling('2s', closed='left').x.sum()
493-
df["open"] = df.rolling('2s', closed='neither').x.sum()
493+
df["neither"] = df.rolling('2s', closed='neither').x.sum()
494494
495495
df
496496

pandas/core/window.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ def validate(self):
10601060

10611061
if not self.is_datetimelike and self.closed is not None:
10621062
raise ValueError("closed only implemented for datetimelike "
1063-
"and offset based windows")
1063+
"and offset based windows")
10641064

10651065
def _validate_monotonic(self):
10661066
""" validate on is monotonic """

pandas/tests/test_window.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ def test_numpy_compat(self):
431431
tm.assertRaisesRegexp(UnsupportedFunctionCall, msg,
432432
getattr(r, func), dtype=np.float64)
433433

434+
def test_closed(self):
435+
df = DataFrame({'A': [0, 1, 2, 3, 4]})
436+
# closed only allowed for datetimelike
437+
with self.assertRaises(ValueError):
438+
df.rolling(window=3, closed='both')
439+
434440

435441
class TestExpanding(Base):
436442

@@ -3396,10 +3402,6 @@ def test_closed(self):
33963402
pd.Timestamp('20130101 09:00:04'),
33973403
pd.Timestamp('20130101 09:00:06')])
33983404

3399-
# closed only allowed for datetimelike
3400-
with self.assertRaises(ValueError):
3401-
self.regular.rolling(window=3, closed='both')
3402-
34033405
# closed must be 'right', 'left', 'both', 'neither'
34043406
with self.assertRaises(ValueError):
34053407
self.regular.rolling(window='2s', closed="blabla")

0 commit comments

Comments
 (0)