MAINT: Perspective offset for load adjustments.

Add a perspective offset to `AdjustedArrayWindow` and `AdjustedArray`,
so that `HistoryLoader` does not need to twiddle with offsets to support
viewing the data from the bar after end of the window, (Which is the
case when a '1d' history window is retrieved in minute mode, which is
explained in the docstring for `HistoryLoader.history`)

Presently, this simplifies the logic in
`HistoryLoader._get_adjustments_in_range`, and other incoming
AdjustmentReader's, (e.g. the roll based adjustment reader for continous
futures.) This patch should also make it easier for history and pipeline
to converge on a singular `load_adjustments` method.
This commit is contained in:
Eddie Hebert
2016-10-17 14:23:39 -04:00
parent 837d8824de
commit 34d4e4b974
4 changed files with 118 additions and 24 deletions
+10 -1
View File
@@ -152,16 +152,22 @@ class AdjustedArray(object):
missing_value : object
A value to use to fill missing data in yielded windows.
Should be a value coercible to `data.dtype`.
perspective_offset : int
The number of rows after the current end of the window, from which the
data is being viewed. This value is used so that adjustments that occur
between the end of the window and the vantage point are applied.
"""
__slots__ = (
'_data',
'_view_kwargs',
'adjustments',
'missing_value',
'perspective_offset',
'__weakref__',
)
def __init__(self, data, mask, adjustments, missing_value):
def __init__(self, data, mask, adjustments, missing_value,
perspective_offset=0):
self._data, self._view_kwargs = _normalize_array(data, missing_value)
self.adjustments = adjustments
@@ -177,6 +183,8 @@ class AdjustedArray(object):
)
self._data[~mask] = self.missing_value
self.perspective_offset = perspective_offset
@lazyval
def data(self):
"""
@@ -220,6 +228,7 @@ class AdjustedArray(object):
self.adjustments,
offset,
window_length,
self.perspective_offset
)
def inspect(self):