Skip to content

Commit

Permalink
Merge pull request #229 from pmorissette/tkp/np2
Browse files Browse the repository at this point in the history
WIP numpy 2 support
  • Loading branch information
timkpaine authored Jun 23, 2024
2 parents 062c993 + 2e0254a commit 2c5cda2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions ffn/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 2c5cda2

Please sign in to comment.