Skip to content

Commit bfb5583

Browse files
authored
Merge pull request #628 from quantopian/empyrical-backwards-compat
Empyrical backwards compat
2 parents 13af662 + 521a153 commit bfb5583

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

pyfolio/pos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
except ImportError:
2525
ZIPLINE = False
2626
warnings.warn(
27-
'Module "zipline.assets" not found; mutltipliers will not be applied' +
27+
'Module "zipline.assets" not found; multipliers will not be applied'
2828
' to position notionals.'
2929
)
3030

pyfolio/tests/test_perf_attrib.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
)
1212

1313

14+
def _empyrical_compat_perf_attrib_result(index, columns, data):
15+
if ep.__version__ < '0.5.2':
16+
# Newer columns were added in empyrical v0.5.2. These exist in older
17+
# and newer empyrical:
18+
columns = ['risk_factor1', 'risk_factor2', 'common_returns',
19+
'specific_returns', 'total_returns']
20+
data = {k: v for k, v in data.items() if k in columns}
21+
22+
return pd.DataFrame(index=index, columns=columns, data=data)
23+
24+
1425
def generate_toy_risk_model_output(start_date='2017-01-01', periods=10,
1526
num_styles=2):
1627
"""
@@ -115,7 +126,7 @@ def test_perf_attrib_simple(self):
115126
'risk_factor2': [0.25, 0.25, 0.25, 0.25]}
116127
)
117128

118-
expected_perf_attrib_output = pd.DataFrame(
129+
expected_perf_attrib_output = _empyrical_compat_perf_attrib_result(
119130
index=dts,
120131
columns=['risk_factor1', 'risk_factor2', 'total_returns',
121132
'common_returns', 'specific_returns',
@@ -158,7 +169,7 @@ def test_perf_attrib_simple(self):
158169
factor_returns,
159170
factor_loadings)
160171

161-
expected_perf_attrib_output = pd.DataFrame(
172+
expected_perf_attrib_output = _empyrical_compat_perf_attrib_result(
162173
index=dts,
163174
columns=['risk_factor1', 'risk_factor2', 'total_returns',
164175
'common_returns', 'specific_returns',

setup.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@
3939
'Topic :: Scientific/Engineering :: Mathematics',
4040
'Operating System :: OS Independent']
4141

42-
if (sys.version_info.major, sys.version_info.minor) >= (3, 3):
43-
support_ipython_6 = True
44-
else:
45-
support_ipython_6 = False
42+
support_ipython_6 = (sys.version_info >= (3, 3))
4643

4744
install_reqs = [
4845
'ipython>=3.2.3' if support_ipython_6 else 'ipython>=3.2.3, <6',
@@ -53,7 +50,7 @@
5350
'scipy>=0.14.0',
5451
'scikit-learn>=0.16.1',
5552
'seaborn>=0.7.1',
56-
'empyrical>=0.5.2'
53+
'empyrical>=0.5.0',
5754
]
5855

5956
test_reqs = ['nose>=1.3.7', 'nose-parameterized>=0.5.0', 'runipy>=0.1.3']

0 commit comments

Comments
 (0)