mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 19:12:36 +08:00
MAINT: Check dates before computing factor_matrix.
In SimpleFFCEngine.factor_matrix barf with a useful error if end_date <= start_date.
This commit is contained in:
@@ -85,6 +85,16 @@ class ConstantInputTestCase(TestCase):
|
||||
)
|
||||
self.asset_finder = AssetFinder(self.asset_info)
|
||||
|
||||
def test_bad_dates(self):
|
||||
loader = self.loader
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
|
||||
msg = "start_date must be before end_date .*"
|
||||
with self.assertRaisesRegexp(ValueError, msg):
|
||||
engine.factor_matrix({}, self.dates[2], self.dates[1])
|
||||
with self.assertRaisesRegexp(ValueError, msg):
|
||||
engine.factor_matrix({}, self.dates[2], self.dates[2])
|
||||
|
||||
def test_single_factor(self):
|
||||
loader = self.loader
|
||||
engine = SimpleFFCEngine(loader, self.dates, self.asset_finder)
|
||||
|
||||
@@ -226,6 +226,12 @@ class SimpleFFCEngine(object):
|
||||
--------
|
||||
FFCEngine.factor_matrix
|
||||
"""
|
||||
if end_date <= start_date:
|
||||
raise ValueError(
|
||||
"start_date must be before end_date \n"
|
||||
"start_date=%s, end_date=%s" % (start_date, end_date)
|
||||
)
|
||||
|
||||
graph = build_dependency_graph(terms.values())
|
||||
ordered_terms = topological_sort(graph)
|
||||
extra_row_counts = get_node_attributes(graph, 'extra_rows')
|
||||
|
||||
Reference in New Issue
Block a user