From 3cc1cf078a5d4a11368b2ebe66fc8d12f344f5c6 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Sun, 24 Jul 2016 21:21:40 -0400 Subject: [PATCH] TEST: Parameterize over window_length. --- tests/pipeline/test_filter.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/pipeline/test_filter.py b/tests/pipeline/test_filter.py index 6a33c251..c403e909 100644 --- a/tests/pipeline/test_filter.py +++ b/tests/pipeline/test_filter.py @@ -26,7 +26,7 @@ from numpy.random import randn, seed as random_seed from zipline.errors import BadPercentileBounds from zipline.pipeline import Filter, Factor, TermGraph from zipline.pipeline.factors import CustomFactor -from zipline.testing import check_arrays +from zipline.testing import check_arrays, parameter_space from zipline.utils.numpy_utils import float64_dtype from .base import BasePipelineTestCase, with_default_shape @@ -383,13 +383,11 @@ class FilterTestCase(BasePipelineTestCase): ) check_arrays(results['isfinite'], isfinite(data)) - def test_window_safe(self): + @parameter_space(factor_len=[2, 3, 4]) + def test_window_safe(self, factor_len): # all true data set of (days, securities) data = full(self.default_shape, True, dtype=bool) - # rolling window length for TestFactor - k = 8 - class InputFilter(Filter): inputs = () window_length = 0 @@ -397,7 +395,7 @@ class FilterTestCase(BasePipelineTestCase): class TestFactor(CustomFactor): dtype = float64_dtype inputs = (InputFilter(), ) - window_length = k + window_length = factor_len def compute(self, today, assets, out, filter_): # sum for each column @@ -412,5 +410,8 @@ class FilterTestCase(BasePipelineTestCase): n = self.default_shape[0] # shape of output array - output_shape = ((n - k + 1), self.default_shape[1]) - check_arrays(results['windowsafe'], full(output_shape, k)) + output_shape = ((n - factor_len + 1), self.default_shape[1]) + check_arrays( + results['windowsafe'], + full(output_shape, factor_len, dtype=float64) + )