From 6287987c0bc776b9077f13cf97587f7601f2d494 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Tue, 16 Feb 2016 13:43:56 -0500 Subject: [PATCH] BUG: Work around scipy >= 0.17 changing dtype of rankdata. --- zipline/lib/rank.pyx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zipline/lib/rank.pyx b/zipline/lib/rank.pyx index 52b36ed0..84a57d07 100644 --- a/zipline/lib/rank.pyx +++ b/zipline/lib/rank.pyx @@ -58,6 +58,11 @@ def masked_rankdata_2d(ndarray data, # the extra work that apply_along_axis does. result = apply_along_axis(rankdata, 1, data, method=method) + # On SciPy >= 0.17, rankdata returns integers for any method except + # average. + if result.dtype.name != 'float64': + result = result.astype('float64') + # rankdata will sort missing values into last place, but we want our nans # to propagate, so explicitly re-apply. result[missing_locations] = nan