From 554bc015395605fafea98a3cad42f9fca86c1e6d Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Wed, 5 Oct 2016 13:15:11 -0400 Subject: [PATCH] MAINT: Alternate AdjustedArray boundary conditions. Avoids the need for a special sentinel value, and means that we only have to have one branch instead of two in the inner loop. --- zipline/lib/_windowtemplate.pxi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zipline/lib/_windowtemplate.pxi b/zipline/lib/_windowtemplate.pxi index 0dbd141c..40f900a5 100644 --- a/zipline/lib/_windowtemplate.pxi +++ b/zipline/lib/_windowtemplate.pxi @@ -67,7 +67,7 @@ cdef class AdjustedArrayWindow: if len(self.adjustment_indices) > 0: return self.adjustment_indices.pop() else: - return -1 + return self.max_anchor + self.perspective_offset def __iter__(self): return self @@ -86,9 +86,7 @@ cdef class AdjustedArrayWindow: # Apply any adjustments that occured before our current anchor. # Equivalently, apply any adjustments known **on or before** the date # for which we're calculating a window. - while (self.next_adj != -1 - and - self.next_adj - self.perspective_offset < anchor): + while self.next_adj < anchor + self.perspective_offset: for adjustment in self.adjustments[self.next_adj]: adjustment.mutate(self.data)