BUG: Fix randomly failing talib unittest that relied on dict order.

This commit is contained in:
Thomas Wiecki
2013-06-27 17:50:35 -04:00
parent 9931812745
commit 84e6050c65
+4 -6
View File
@@ -293,7 +293,6 @@ class TestTALIB(TestCase):
self.source, self.panel = \
factory.create_test_panel_ohlc_source(sim_params)
@unittest.skip
def test_talib_with_default_params(self):
BLACKLIST = ['make_transform', 'BatchTransform',
# TODO: Figure out why MAVP generates a KeyError
@@ -345,9 +344,6 @@ class TestTALIB(TestCase):
# self.source, self.panel = \
# factory.create_test_panel_ohlc_source(self.sim_params)
# TODO: Remove this skip, after debugging why sometimes the talib_results
# contain to many leading nans.
@unittest.skip
def test_multiple_talib_with_args(self):
zipline_transforms = [ta.MA(0, window_length=10),
ta.MA(0, window_length=25)]
@@ -355,10 +351,12 @@ class TestTALIB(TestCase):
algo = TALIBAlgorithm(talib=zipline_transforms)
algo.run(self.source)
# Test if computed values match those computed by pandas rolling mean.
np.testing.assert_array_equal(np.array(algo.talib_results.values()[0]),
talib_values = np.array(algo.talib_results[zipline_transforms[0]])
np.testing.assert_array_equal(talib_values,
pd.rolling_mean(self.panel[0]['price'],
10).values)
np.testing.assert_array_equal(np.array(algo.talib_results.values()[1]),
talib_values = np.array(algo.talib_results[zipline_transforms[1]])
np.testing.assert_array_equal(talib_values,
pd.rolling_mean(self.panel[0]['price'],
25).values)
for t in zipline_transforms: