From 2e0254a411053468b8e53b46ec2a69743ce1c9eb Mon Sep 17 00:00:00 2001 From: Tim Paine <3105306+timkpaine@users.noreply.github.com> Date: Sat, 22 Jun 2024 16:24:32 -0500 Subject: [PATCH] WIP numpy 2 support --- .github/workflows/regression.yml | 14 ++++++++++---- ffn/core.py | 4 ++-- pyproject.toml | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 2bc541c..3da47f8 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -20,9 +20,15 @@ jobs: matrix: python-version: [3.9] os: [ubuntu-latest] - dependency: - - 'pandas>=2.2' - - 'pandas<2' + pandas_version: + - '>=2.2' + - '<2' + numpy_version: + - '<2' + - '>=2' + exclude: + - numpy_version: '>=2' + pandas_version: '<2' steps: - uses: actions/checkout@v4 @@ -36,7 +42,7 @@ jobs: - name: Install dependencies run: | make develop - python -m pip install -U wheel twine setuptools "${{ matrix.dependency }}" + python -m pip install -U wheel twine setuptools "numpy${{ matrix.numpy_version }}" "pandas${{ matrix.pandas_version}}" - name: Test run: make test diff --git a/ffn/core.py b/ffn/core.py index 13dd2d2..843b66b 100644 --- a/ffn/core.py +++ b/ffn/core.py @@ -1241,7 +1241,7 @@ def to_drawdown_series(prices): drawdown = drawdown.ffill() # Ignore problems with NaN's in the beginning - drawdown[np.isnan(drawdown)] = -np.Inf + drawdown[np.isnan(drawdown)] = -np.inf # Rolling maximum if isinstance(drawdown, pd.DataFrame): @@ -1547,7 +1547,7 @@ def calc_inv_vol_weights(returns): """ # calc vols vol = np.divide(1.0, np.std(returns, ddof=1)).astype(float) - vol[np.isinf(vol)] = np.NaN + vol[np.isinf(vol)] = np.nan volsum = vol.sum() return np.divide(vol, volsum) diff --git a/pyproject.toml b/pyproject.toml index e17afe0..4fdf4b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,9 @@ [build-system] -# Minimum requirements for the build system to execute. -requires = ["setuptools", "wheel"] +requires = [ + "oldest-supported-numpy", + "setuptools", + "wheel", +] build-backend = "setuptools.build_meta" [project] @@ -36,7 +39,7 @@ classifiers = [ dependencies = [ "decorator>=5.0.7", "matplotlib>=1", - "numpy>=1.5", + "numpy", "pandas>=0.19", "pandas-datareader>=0.2", "scikit-learn>=0.15",