Skip to content

Commit

Permalink
Fix for pandas 1.0 (#124)
Browse files Browse the repository at this point in the history
* as_matrix was depricated then removed. to_numpy() works in this situation

* updated travis to include pandas 1.0.x, python 3.7 numpy 1.18 and scipy 1.4.x - kept a python 2.7 with the last supported versions of pydata.

* versions compatible with conda for travis

* old scipy and numpy

* old scipy and numpy

* old scipy and numpy

* old scipy and numpy

* old scipy and numpy

* old scipy and numpy

* who uses 3.5 anyway

* Fix for pandas 1.0

* as_matrix was deprecated then removed. to_numpy() works in this situation

* updated travis to include pandas 1.0.x, python 3.7 numpy 1.18 and scipy 1.4.x 

* kept a python 2.7 build with the last supported versions of pydata.

* versions compatible with conda for travis

* try except branch to support old pandas as required by zipline

* as_matrix() not to_matrix() - thanks again Travis.

Co-authored-by: Rich Atkinson <[email protected]>
  • Loading branch information
atkinson and atkinson authored Jun 9, 2020
1 parent b561c5f commit b026b4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ sudo: false
matrix:
include:
- python: 2.7
env: PANDAS_VERSION=0.18.1 NUMPY_VERSION=1.11.1 SCIPY_VERSION=0.17.1 LIBGFORTRAN_VERSION=3.0
- python: 2.7
env: PANDAS_VERSION=0.19.2 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
env: PANDAS_VERSION=0.24.2 NUMPY_VERSION=1.12.1 SCIPY_VERSION=1.2.1 LIBGFORTRAN_VERSION=3.0
- python: 2.7
env: PANDAS_VERSION=0.20.1 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
- python: 3.5
env: PANDAS_VERSION=0.18.1 NUMPY_VERSION=1.11.1 SCIPY_VERSION=0.17.1 LIBGFORTRAN_VERSION=3.0
- python: 3.5
env: PANDAS_VERSION=0.19.2 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
- python: 3.6
env: PANDAS_VERSION=1.0.4 NUMPY_VERSION=1.18.4 SCIPY_VERSION=1.4.1 LIBGFORTRAN_VERSION=3.0
- python: 3.6
env: PANDAS_VERSION=0.20.1 NUMPY_VERSION=1.12.1 SCIPY_VERSION=0.19.0 LIBGFORTRAN_VERSION=3.0
- python: 3.6
env: PANDAS_VERSION=1.0.4 NUMPY_VERSION=1.18.4 SCIPY_VERSION=1.4.1 LIBGFORTRAN_VERSION=3.0
- python: 3.7
env: PANDAS_VERSION=1.0.4 NUMPY_VERSION=1.18.4 SCIPY_VERSION=1.4.1 LIBGFORTRAN_VERSION=3.0

before_install:
# We do this conditionally because it saves us some downloading if the
Expand Down
8 changes: 7 additions & 1 deletion empyrical/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,13 @@ def gpd_risk_estimates_aligned(returns, var_p=0.01):

DEFAULT_THRESHOLD = 0.2
MINIMUM_THRESHOLD = 0.000000001
returns_array = pd.Series(returns).as_matrix()

try:
returns_array = pd.Series(returns).to_numpy()
except AttributeError:
# while zipline requires support for pandas < 0.25
returns_array = pd.Series(returns).as_matrix()

flipped_returns = -1 * returns_array
losses = flipped_returns[flipped_returns > 0]
threshold = DEFAULT_THRESHOLD
Expand Down

0 comments on commit b026b4e

Please sign in to comment.