Fixes bug that .run() could not be called twice on an algorithm. Added unittest to check.

This commit is contained in:
Thomas Wiecki
2012-10-19 11:47:59 -05:00
parent 943a56322e
commit 92f1dbef0c
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -15,6 +15,7 @@
from unittest2 import TestCase
from datetime import timedelta
import numpy as np
from zipline.utils.test_utils import setup_logger
import zipline.utils.factory as factory
@@ -62,6 +63,13 @@ class TestTransformAlgorithm(TestCase):
algo.run(self.df)
assert isinstance(algo.sources[0], DataFrameSource)
def test_run_twice(self):
algo = TestRegisterTransformAlgorithm(sids=[0, 1])
res1 = algo.run(self.df)
res2 = algo.run(self.df)
np.testing.assert_array_equal(res1, res2)
def test_transform_registered(self):
algo = TestRegisterTransformAlgorithm(sids=[133])
algo.run(self.source)
+1
View File
@@ -153,6 +153,7 @@ start and end date have to be specified."""
self.sources = source
# Create transforms by wrapping them into StatefulTransforms
self.transforms = []
for namestring, trans_descr in self.registered_transforms.iteritems():
sf = StatefulTransform(
trans_descr['class'],