mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-14 12:10:24 +08:00
MAINT: Make load_adjusted_array return a dict.
Rather than a list that's ordered the same as the received columns. Most nontrivial loaders were constructing dicts internally and then converting back to lists, only to have the engine convert **back again** into a dict. This cuts out the middleman, and prevents bugs due to incorrect ordering of the output arrays.
This commit is contained in:
@@ -80,7 +80,7 @@ class DataFrameLoaderTestCase(TestCase):
|
||||
self.dates[dates_slice],
|
||||
self.sids[sids_slice],
|
||||
self.mask[dates_slice, sids_slice],
|
||||
)
|
||||
).values()
|
||||
|
||||
for idx, window in enumerate(adj_array.traverse(window_length=3)):
|
||||
expected = baseline.values[dates_slice, sids_slice][idx:idx + 3]
|
||||
|
||||
@@ -35,6 +35,7 @@ from pandas import (
|
||||
Timestamp,
|
||||
)
|
||||
from testfixtures import TempDirectory
|
||||
from toolz.curried.operator import getitem
|
||||
|
||||
from zipline.lib.adjustment import Float64Multiply
|
||||
from zipline.pipeline.loaders.synthetic import (
|
||||
@@ -422,12 +423,13 @@ class USEquityPricingLoaderTestCase(TestCase):
|
||||
adjustment_reader,
|
||||
)
|
||||
|
||||
closes, volumes = pricing_loader.load_adjusted_array(
|
||||
results = pricing_loader.load_adjusted_array(
|
||||
columns,
|
||||
dates=query_days,
|
||||
assets=self.assets,
|
||||
mask=ones((len(query_days), len(self.assets)), dtype=bool),
|
||||
)
|
||||
closes, volumes = map(getitem(results), columns)
|
||||
|
||||
expected_baseline_closes = self.bcolz_writer.expected_values_2d(
|
||||
shifted_query_days,
|
||||
@@ -500,12 +502,13 @@ class USEquityPricingLoaderTestCase(TestCase):
|
||||
adjustment_reader,
|
||||
)
|
||||
|
||||
highs, volumes = pricing_loader.load_adjusted_array(
|
||||
results = pricing_loader.load_adjusted_array(
|
||||
columns,
|
||||
dates=query_days,
|
||||
assets=Int64Index(arange(1, 7)),
|
||||
mask=ones((len(query_days), 6), dtype=bool),
|
||||
)
|
||||
highs, volumes = map(getitem(results), columns)
|
||||
|
||||
expected_baseline_highs = self.bcolz_writer.expected_values_2d(
|
||||
shifted_query_days,
|
||||
|
||||
Reference in New Issue
Block a user