mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-29 11:18:20 +08:00
MAINT: Use six for Python 3 compatible names and behavior.
Use the six module to import functions and types that are consistent between Python 2 and 3, so that one code base can support both versions. - Use integer types instead of int and long. - Use string_types instead of basestring. - Account for iteritems, itervalues, iterkeys. - Use six.moves for filter and zip, reduce - Use compatible bytes for md5 hasher. - xrange and range
This commit is contained in:
@@ -20,7 +20,9 @@ import numpy as np
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from itertools import groupby, ifilter
|
||||
from itertools import groupby
|
||||
from six.moves import filter
|
||||
from six import iteritems
|
||||
from operator import attrgetter
|
||||
|
||||
from zipline.errors import (
|
||||
@@ -194,7 +196,7 @@ class TradingAlgorithm(object):
|
||||
date_sorted = date_sorted_sources(*self.sources)
|
||||
|
||||
if source_filter:
|
||||
date_sorted = ifilter(source_filter, date_sorted)
|
||||
date_sorted = filter(source_filter, date_sorted)
|
||||
|
||||
with_tnfms = sequential_transforms(date_sorted,
|
||||
*self.transforms)
|
||||
@@ -305,7 +307,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
# Create transforms by wrapping them into StatefulTransforms
|
||||
self.transforms = []
|
||||
for namestring, trans_descr in self.registered_transforms.iteritems():
|
||||
for namestring, trans_descr in iteritems(self.registered_transforms):
|
||||
sf = StatefulTransform(
|
||||
trans_descr['class'],
|
||||
*trans_descr['args'],
|
||||
|
||||
Reference in New Issue
Block a user