MAINT: Improve/test errors for insufficient data.

This commit is contained in:
Scott Sanderson
2016-08-17 16:52:09 -04:00
parent 4c59857e1f
commit 765f9b6d57
2 changed files with 27 additions and 4 deletions
+23
View File
@@ -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(
+4 -4
View File
@@ -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,
),
)