Skip to content

Commit

Permalink
Merge pull request #1508 from quantopian/forward-window-safety-in-demean
Browse files Browse the repository at this point in the history
BUG: F.window_safe implies f.demean().window_safe.
  • Loading branch information
Scott Sanderson committed Sep 22, 2016
2 parents ca5f98b + 49cd8e1 commit ac9d841
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/pipeline/test_factor.py
Expand Up @@ -1047,3 +1047,14 @@ def test_demean(self):
def test_zscore(self):
r = F().zscore().short_repr()
self.assertEqual(r, "GroupedRowTransform('zscore')")


class TestWindowSafety(TestCase):

def test_zscore_is_window_safe(self):
self.assertTrue(F().zscore().window_safe)

def test_demean_is_window_safe_if_input_is_window_safe(self):
self.assertFalse(F().demean().window_safe)
self.assertFalse(F(window_safe=False).demean().window_safe)
self.assertTrue(F(window_safe=True).demean().window_safe)
1 change: 1 addition & 0 deletions zipline/pipeline/factors/factor.py
Expand Up @@ -509,6 +509,7 @@ def demean(self, mask=NotSpecified, groupby=NotSpecified):
groupby=groupby,
dtype=self.dtype,
missing_value=self.missing_value,
window_safe=self.window_safe,
mask=mask,
)

Expand Down

0 comments on commit ac9d841

Please sign in to comment.