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:
Eddie Hebert
2014-01-07 11:33:50 -05:00
parent 40c8c38257
commit b4959e46cf
21 changed files with 95 additions and 47 deletions
+5 -3
View File
@@ -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'],