BUG: Fix error from RequiredWindowLengthMixin.

WindowLengthNotSpecified expects an argument.
This commit is contained in:
Scott Sanderson
2015-08-04 01:41:03 -04:00
parent e91b1c56b2
commit b89fc0c028
2 changed files with 29 additions and 4 deletions
+28 -1
View File
@@ -15,7 +15,11 @@ from zipline.data.dataset import (
Column,
DataSet,
)
from zipline.errors import InputTermNotAtomic
from zipline.errors import (
InputTermNotAtomic,
TermInputsNotSpecified,
WindowLengthNotSpecified,
)
from zipline.modelling.engine import build_dependency_graph
from zipline.modelling.factor import Factor
from zipline.modelling.expression import NUMEXPR_MATH_FUNCS
@@ -244,3 +248,26 @@ class ObjectIdentityTestCase(TestCase):
for funcname in NUMEXPR_MATH_FUNCS:
method = getattr(f, funcname)
self.assertIs(method(), method())
def test_bad_input(self):
class SomeFactor(Factor):
pass
class SomeFactorDefaultInputs(Factor):
inputs = (SomeDataSet.foo, SomeDataSet.bar)
class SomeFactorDefaultLength(Factor):
window_length = 10
with self.assertRaises(TermInputsNotSpecified):
SomeFactor(window_length=1)
with self.assertRaises(TermInputsNotSpecified):
SomeFactorDefaultLength()
with self.assertRaises(WindowLengthNotSpecified):
SomeFactor(inputs=(SomeDataSet.foo,))
with self.assertRaises(WindowLengthNotSpecified):
SomeFactorDefaultInputs()
+1 -3
View File
@@ -214,10 +214,8 @@ class SingleInputMixin(object):
class RequiredWindowLengthMixin(object):
def _validate(self):
if self.windowed:
if self.windowed or self.window_length is NotSpecified:
return super(RequiredWindowLengthMixin, self)._validate()
if self.window_length is NotSpecified:
raise WindowLengthNotSpecified()
raise WindowLengthNotPositive(window_length=self.window_length)