Skip to content

Commit 6b55da7

Browse files
MAINT: Numpy 2.0 Compatbility (#51)
* version updates * skip sharpe test on pandas 14 due to macos CI error * gha wheels update * update python version * update test matrix
1 parent a013587 commit 6b55da7

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

.github/workflows/build_wheels.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
required: true
1010
default: 'PYPI'
1111
options: [ 'TESTPYPI', 'PYPI' ]
12+
version:
13+
type: string
14+
description: 'Version tag'
15+
required: true
16+
default: '0.9.9'
1217

1318
jobs:
1419
dist:
@@ -17,14 +22,14 @@ jobs:
1722
fail-fast: false
1823
matrix:
1924
os: [ ubuntu-latest ]
20-
python-version: [ "3.10" ]
25+
python-version: [ "3.12" ]
2126

2227
steps:
2328
- name: Checkout pyfolio
2429
uses: actions/checkout@v4
2530
with:
2631
fetch-depth: 0
27-
ref: 0.9.7
32+
ref: ${{ github.event.inputs.version }}
2833

2934
- name: Set up Python ${{ matrix.python-version }}
3035
uses: actions/setup-python@v5
@@ -57,7 +62,7 @@ jobs:
5762
with:
5863
user: __token__
5964
password: ${{ secrets.TESTPYPI_TOKEN }}
60-
repository_url: https://test.pypi.org/legacy/
65+
repository-url: https://test.pypi.org/legacy/
6166

6267
- name: publish to pypi
6368
if: ${{ github.event.inputs.target == 'PYPI' }}

.github/workflows/unit_tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Tests
22

33
on:
44
workflow_dispatch:
5+
schedule:
6+
- cron: "0 9 * * 6"
57
push:
68
branches:
79
- main
@@ -17,7 +19,7 @@ jobs:
1719
fail-fast: false
1820
matrix:
1921
os: [ ubuntu-latest , windows-latest, macos-latest ]
20-
python-version: [ '3.9', '3.10', '3.11', '3.12']
22+
python-version: [ '3.10', '3.11', '3.12', '3.13']
2123
steps:
2224
- name: Checkout pyfolio
2325
uses: actions/checkout@v4

pyproject.toml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ classifiers = [
2424
'Programming Language :: Python :: 3.10',
2525
'Programming Language :: Python :: 3.11',
2626
'Programming Language :: Python :: 3.12',
27+
'Programming Language :: Python :: 3.13',
2728
'Operating System :: OS Independent',
2829
'Intended Audience :: Science/Research',
2930
'Topic :: Office/Business :: Financial :: Investment',
3031
'Topic :: Scientific/Engineering :: Information Analysis',
3132
]
3233

3334
dependencies = [
35+
# following pandas
36+
"numpy>=1.23.5; python_version<'3.12'",
37+
"numpy>=1.26.0; python_version>='3.12'",
38+
"pandas >=1.5.0,<3.0",
3439
"ipython >=3.2.3",
3540
"matplotlib >=1.4.0",
36-
"numpy >=1.11.1",
37-
"pandas >=1.3",
3841
"pytz >=2014.10",
3942
"scipy >=0.14.0",
4043
"scikit-learn >=0.16.1",
@@ -99,7 +102,8 @@ version_scheme = 'guess-next-dev'
99102
local_scheme = 'dirty-tag'
100103

101104

102-
[tool.pytest]
105+
[tool.pytest.ini_options]
106+
pythonpath = ['src']
103107
minversion = "6.0"
104108
testpaths = 'tests'
105109
addopts = '-v'
@@ -134,17 +138,26 @@ extend-exclude = '''
134138
[tool.tox]
135139
legacy_tox_ini = """
136140
[tox]
137-
envlist = py{39,310}-pandas{13,14,15}, py{39,310, 311,312}-pandas{20,21,22}
141+
142+
envlist =
143+
py310-pandas{15,20,21,22}-numpy1
144+
py311-pandas{15,20,21,22}-numpy1
145+
py312-pandas{15,20,21,22}-numpy1
146+
py310-pandas222-numpy2{0,1,2}
147+
py311-pandas222-numpy2{0,1,2}
148+
py312-pandas222-numpy2{01,2}
149+
py313-pandas222-numpy2{1,2}
150+
138151
isolated_build = True
139152
skip_missing_interpreters = True
140153
minversion = 3.23.0
141154
142155
[gh-actions]
143156
python =
144-
3.9: py39
145157
3.10: py310
146158
3.11: py311
147159
3.12: py312
160+
3.13: py313
148161
149162
[testenv]
150163
usedevelop = True
@@ -154,12 +167,16 @@ setenv =
154167
changedir = tmp
155168
extras = test
156169
deps =
157-
pandas13: pandas>=1.3.0,<1.4
158-
pandas14: pandas>=1.4.0,<1.5
159170
pandas15: pandas>=1.5.0,<1.6
160171
pandas20: pandas>=2.0,<2.1
161172
pandas21: pandas>=2.1,<2.2
162173
pandas22: pandas>=2.2,<2.3
174+
pandas222: pandas>=2.2.2,<2.3
175+
numpy1: numpy>=1.23.5,<2.0
176+
numpy20: numpy>=2.0,<2.1
177+
numpy21: numpy>=2.1,<2.2
178+
numpy22: numpy>=2.2,<2.3
179+
163180
164181
commands =
165182
pytest -n 2 --cov={toxinidir}/src --cov-report term --cov-report=xml --cov-report=html:htmlcov {toxinidir}/tests

src/pyfolio/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
pandas_version = Version(pd.__version__)
7272

73-
pandas_one_point_three_or_less = pandas_version < Version("1.4")
73+
pandas_one_point_three_or_less = pandas_version <= Version("1.4")
7474

7575

7676
def one_dec_places(x, pos):

tests/test_timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class TestStats(TestCase):
297297
)
298298
]
299299
)
300-
@skipIf(pandas_one_point_three_or_less, "pandas<=1.3 returns np.inf not np.nan")
300+
@skipIf(pandas_one_point_three_or_less, "pandas<=1.4 returns np.inf not np.nan")
301301
def test_sharpe_2(self, returns, rolling_sharpe_window, expected):
302302
np.testing.assert_array_almost_equal(
303303
timeseries.rolling_sharpe(returns, rolling_sharpe_window).to_numpy(),

0 commit comments

Comments
 (0)