From a7763673aa9bec089af387154bbebba1b87fac9c Mon Sep 17 00:00:00 2001 From: llllllllll Date: Mon, 12 Oct 2015 12:24:37 -0400 Subject: [PATCH] MAINT: remove from_function. We can revisit this later --- zipline/pipeline/factors/factor.py | 45 ------------------------------ 1 file changed, 45 deletions(-) diff --git a/zipline/pipeline/factors/factor.py b/zipline/pipeline/factors/factor.py index 125fdc5b..4c22d1ef 100644 --- a/zipline/pipeline/factors/factor.py +++ b/zipline/pipeline/factors/factor.py @@ -541,48 +541,3 @@ class CustomFactor(RequiredWindowLengthMixin, CustomTermMixin, Factor): if self.dtype != float64: raise UnsupportedDataType(dtype=self.dtype) return super(CustomFactor, self)._validate() - - @classmethod - def from_function(cls, f, window_length, *inputs): - """Construct a new factor type or factor from an arbitrary callable. - - Parameters - ---------- - f : callable - The callable to reduce the input data with. - This will be called with ``*input_data`` where each input data is - the lookback array for the input. - window_length : int - The size of the window of data. This is the length of each - input_data array. - *inputs : iterable of DataSet, optional - The inputs to the new factor. If this is not passed, then a new - factor type is created instead of a factor instance. - - Returns - ------- - factor : type or CustomFactor - A new custom factor class if not inputs are passed, otherwise - a new instance of a new custom factor class. - """ - try: - name = f.__name__ - except AttributeError: - name = '' - - def compute(self, today, assets, out, *data): - """Compute the values for the output by calling: - out[:] = {fn}(*data) - """ - out[:] = f(*data) - - compute.__doc__ = compute.__doc__.format(fn=name) - - factor = type(name, (cls,), { - 'compute': compute, - 'window_length': window_length, - }) - - if inputs: - factor = factor(inputs) - return factor