mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-01 11:08:00 +08:00
Fixes bug that .run() could not be called twice on an algorithm. Added unittest to check.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user