mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-21 12:30:16 +08:00
MAINT: Improve/test errors for insufficient data.
This commit is contained in:
@@ -206,6 +206,29 @@ class ConstantInputTestCase(WithTradingEnvironment, ZiplineTestCase):
|
||||
with self.assertRaisesRegexp(ValueError, msg):
|
||||
engine.run_pipeline(p, self.dates[2], self.dates[1])
|
||||
|
||||
def test_fail_usefully_on_insufficient_data(self):
|
||||
loader = self.loader
|
||||
engine = SimplePipelineEngine(
|
||||
lambda column: loader, self.dates, self.asset_finder,
|
||||
)
|
||||
|
||||
class SomeFactor(CustomFactor):
|
||||
inputs = [USEquityPricing.close]
|
||||
window_length = 10
|
||||
|
||||
def compute(self, today, assets, out, closes):
|
||||
pass
|
||||
|
||||
p = Pipeline(columns={'t': SomeFactor()})
|
||||
|
||||
# self.dates[9] is the earliest date we should be able to compute.
|
||||
engine.run_pipeline(p, self.dates[9], self.dates[9])
|
||||
|
||||
# We shouldn't be able to compute dates[8], since we only know about 8
|
||||
# prior dates, and we need a window length of 10.
|
||||
with self.assertRaises(NoFurtherDataError) as e:
|
||||
engine.run_pipeline(p, self.dates[8], self.dates[8])
|
||||
|
||||
def test_same_day_pipeline(self):
|
||||
loader = self.loader
|
||||
engine = SimplePipelineEngine(
|
||||
|
||||
@@ -211,10 +211,10 @@ class SimplePipelineEngine(object):
|
||||
start_idx, end_idx = self._calendar.slice_locs(start_date, end_date)
|
||||
if start_idx < extra_rows:
|
||||
raise NoFurtherDataError(
|
||||
msg="Insufficient data to compute Pipeline mask: "
|
||||
"start date was %s, "
|
||||
"earliest known date was %s, "
|
||||
"and %d extra rows were requested." % (
|
||||
msg="Insufficient data to compute Pipeline.\n\n"
|
||||
"start date was %s\n"
|
||||
"earliest known date was %s\n"
|
||||
"%d extra rows were required" % (
|
||||
start_date, calendar[0], extra_rows,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user