Skip to content

Commit

Permalink
BUG: truncate windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Jevnik authored and llllllllll committed Feb 23, 2018
1 parent a39a323 commit 52687e1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions empyrical/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def unary_vectorized_roll(arr, window, out=None, **kwargs):
allocated_output = out is None

if len(arr):
out = function(rolling_window(arr, window).T, out=out, **kwargs)
out = function(
rolling_window(arr, min(len(arr), window)).T,
out=out,
**kwargs
)
else:
out = np.empty(0, dtype='float64')

Expand Down Expand Up @@ -93,8 +97,8 @@ def binary_vectorized_roll(lhs, rhs, window, out=None, **kwargs):

if window >= 1 and len(lhs) and len(rhs):
out = function(
rolling_window(lhs, window).T,
rolling_window(rhs, window).T,
rolling_window(lhs, min(len(lhs), window)).T,
rolling_window(rhs, min(len(rhs), window)).T,
out=out,
**kwargs
)
Expand Down

0 comments on commit 52687e1

Please sign in to comment.