From 52687e1f49e784365cf65d080e3e2e3e8d01491f Mon Sep 17 00:00:00 2001 From: Joe Jevnik Date: Thu, 22 Feb 2018 16:20:42 -0500 Subject: [PATCH] BUG: truncate windows --- empyrical/stats.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/empyrical/stats.py b/empyrical/stats.py index 96aab89..b30c960 100644 --- a/empyrical/stats.py +++ b/empyrical/stats.py @@ -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') @@ -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 )