Skip to content

Commit 6702a00

Browse files
carlosdanielcsantoscarlosdanielcsantos
carlosdanielcsantos
authored and
carlosdanielcsantos
committed
Fixing test of assertion of closed parameter in fixed windows
Style corrections
1 parent 2abfbb6 commit 6702a00

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
@@ -1057,7 +1057,7 @@ def validate(self):
10571057

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

10621062
def _validate_monotonic(self):
10631063
""" 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

@@ -3367,10 +3373,6 @@ def test_closed(self):
33673373
pd.Timestamp('20130101 09:00:04'),
33683374
pd.Timestamp('20130101 09:00:06')])
33693375

3370-
# closed only allowed for datetimelike
3371-
with self.assertRaises(ValueError):
3372-
self.regular.rolling(window=3, closed='both')
3373-
33743376
# closed must be 'right', 'left', 'both', 'neither'
33753377
with self.assertRaises(ValueError):
33763378
self.regular.rolling(window='2s', closed="blabla")

0 commit comments

Comments
 (0)