BUG: Fail fast on invalid pipeline columns

This commit is contained in:
dmichalowicz
2016-06-15 17:38:17 -04:00
parent 4c2f0e86eb
commit 6b9b9fb8e7
2 changed files with 14 additions and 2 deletions
+6
View File
@@ -63,6 +63,9 @@ class PipelineTestCase(TestCase):
with self.assertRaises(TypeError):
Pipeline({}, SomeFactor())
with self.assertRaises(TypeError):
Pipeline({'open': USEquityPricing.open})
Pipeline({}, SomeFactor() > 5)
def test_add(self):
@@ -78,6 +81,9 @@ class PipelineTestCase(TestCase):
with self.assertRaises(TypeError):
p.add(f, 1)
with self.assertRaises(TypeError):
p.add(USEquityPricing.open, 'open')
def test_overwrite(self):
p = Pipeline()
f = SomeFactor()
+8 -2
View File
@@ -1,6 +1,6 @@
from zipline.utils.input_validation import expect_types, optional
from .term import Term, AssetExists
from .term import AssetExists, ComputableTerm
from .filters import Filter
from .graph import TermGraph
@@ -37,6 +37,12 @@ class Pipeline(object):
if columns is None:
columns = {}
for term in columns.values():
if not isinstance(term, ComputableTerm):
raise TypeError(
'"{term}" is not a valid pipeline column. Did you mean '
'to add ".latest"?'.format(term=term)
)
self._columns = columns
self._screen = screen
@@ -54,7 +60,7 @@ class Pipeline(object):
"""
return self._screen
@expect_types(term=Term, name=str)
@expect_types(term=ComputableTerm, name=str)
def add(self, term, name, overwrite=False):
"""
Add a column.