mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-01 15:08:49 +08:00
BUG: Change str to string_types to avoid errors
When in python2.7, and unicode_literals is imported type check will raise error because 'type' is not str but unicode
This commit is contained in:
committed by
Richard Frank
parent
548e0675be
commit
eb6b6d046d
@@ -20,7 +20,7 @@ from pandas.tslib import normalize_date
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
from six import iteritems, PY2
|
||||
from six import iteritems, PY2, string_types
|
||||
from cpython cimport bool
|
||||
from collections import Iterable
|
||||
|
||||
@@ -29,7 +29,7 @@ from zipline.zipline_warnings import ZiplineDeprecationWarning
|
||||
|
||||
|
||||
cdef bool _is_iterable(obj):
|
||||
return isinstance(obj, Iterable) and not isinstance(obj, str)
|
||||
return isinstance(obj, Iterable) and not isinstance(obj, string_types)
|
||||
|
||||
|
||||
# Wraps doesn't work for method objects in python2. Docs should be generated
|
||||
@@ -247,7 +247,7 @@ cdef class BarData:
|
||||
|
||||
return dt
|
||||
|
||||
@check_parameters(('assets', 'fields'), ((Asset, str), str))
|
||||
@check_parameters(('assets', 'fields'), ((Asset, string_types), string_types))
|
||||
def current(self, assets, fields):
|
||||
"""
|
||||
Returns the current value of the given assets for the given fields
|
||||
@@ -569,7 +569,7 @@ cdef class BarData:
|
||||
return not (last_traded_dt is pd.NaT)
|
||||
|
||||
@check_parameters(('assets', 'fields', 'bar_count', 'frequency'),
|
||||
((Asset, str), str, int, str))
|
||||
((Asset, string_types), string_types, int, string_types))
|
||||
def history(self, assets, fields, bar_count, frequency):
|
||||
"""
|
||||
Returns a window of data for the given assets and fields.
|
||||
@@ -615,7 +615,7 @@ cdef class BarData:
|
||||
If the current simulation time is not a valid market time, we use the
|
||||
last market close instead.
|
||||
"""
|
||||
if isinstance(fields, str):
|
||||
if isinstance(fields, string_types):
|
||||
single_asset = isinstance(assets, Asset)
|
||||
|
||||
if single_asset:
|
||||
|
||||
Reference in New Issue
Block a user