From bdf66aaa3d3f79eeb123265ffa8b3d966eeb195f Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 23 Nov 2015 12:55:23 -0500 Subject: [PATCH] BUG: Fix typo in CustomFactor docstring. nan* functions should get passed the actual array. Also adds code-block directives to the docstring so that they get highlighted by Sphinx as Python code. --- zipline/pipeline/factors/factor.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/zipline/pipeline/factors/factor.py b/zipline/pipeline/factors/factor.py index 0fadb497..d2376332 100644 --- a/zipline/pipeline/factors/factor.py +++ b/zipline/pipeline/factors/factor.py @@ -496,7 +496,9 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor): Notes ----- Users implementing their own Factors should subclass CustomFactor and - implement a method named `compute` with the following signature:: + implement a method named `compute` with the following signature: + + .. code-block:: python def compute(self, today, assets, out, *inputs): ... @@ -529,7 +531,9 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor): Examples -------- - A CustomFactor with pre-declared defaults:: + A CustomFactor with pre-declared defaults: + + .. code-block:: python class TenDayRange(CustomFactor): """ @@ -546,8 +550,8 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor): def compute(self, today, assets, out, highs, lows): from numpy import nanmin, nanmax - highest_highs = nanmax(axis=0) - lowest_lows = nanmin(axis=0) + highest_highs = nanmax(highs, axis=0) + lowest_lows = nanmin(lows, axis=0) out[:] = highest_highs - lowest_lows @@ -555,7 +559,9 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor): # pre-declared as defaults for the TenDayRange class. ten_day_range = TenDayRange() - A CustomFactor without defaults:: + A CustomFactor without defaults: + + .. code-block:: python class MedianValue(CustomFactor): """ @@ -568,7 +574,7 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor): def compute(self, today, assets, out, data): from numpy import nanmedian - out[:] = data.nanmedian(axis=0) + out[:] = data.nanmedian(data, axis=0) # Values for `inputs` and `window_length` must be passed explicitly to # MedianValue.