Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Numpy 2.0 Compatbility #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
required: true
default: 'PYPI'
options: [ 'TESTPYPI', 'PYPI' ]
version:
type: string
description: 'Version tag'
required: true
default: '0.9.8'

jobs:
dist:
Expand All @@ -24,7 +29,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: 0.9.7
ref: ${{ github.event.inputs.version }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand Down Expand Up @@ -57,7 +62,7 @@ jobs:
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/

- name: publish to pypi
if: ${{ github.event.inputs.target == 'PYPI' }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Tests

on:
workflow_dispatch:
schedule:
- cron: "0 9 * * 6"
push:
branches:
- main
Expand Down
25 changes: 21 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ classifiers = [
]

dependencies = [
# following pandas
"numpy>=1.23.5; python_version<'3.12'",
"numpy>=1.26.0; python_version>='3.12'",
"pandas >=1.3.0,<3.0",
"ipython >=3.2.3",
"matplotlib >=1.4.0",
"numpy >=1.11.1",
"pandas >=1.3",
"pytz >=2014.10",
"scipy >=0.14.0",
"scikit-learn >=0.16.1",
Expand Down Expand Up @@ -99,7 +101,8 @@ version_scheme = 'guess-next-dev'
local_scheme = 'dirty-tag'


[tool.pytest]
[tool.pytest.ini_options]
pythonpath = ['src']
minversion = "6.0"
testpaths = 'tests'
addopts = '-v'
Expand Down Expand Up @@ -134,7 +137,17 @@ extend-exclude = '''
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py{39,310}-pandas{13,14,15}, py{39,310, 311,312}-pandas{20,21,22}

envlist =
py39-pandas{13,14,15}-numpy1
py310-pandas{13,14,15,20,21,22}-numpy1
py311-pandas{13,14,15,20,21,22}-numpy1
py312-pandas{13,14,15,20,21,22}-numpy1
py39-pandas222-numpy2
py310-pandas222-numpy2
py311-pandas222-numpy2
py312-pandas222-numpy2

isolated_build = True
skip_missing_interpreters = True
minversion = 3.23.0
Expand All @@ -160,6 +173,10 @@ deps =
pandas20: pandas>=2.0,<2.1
pandas21: pandas>=2.1,<2.2
pandas22: pandas>=2.2,<2.3
pandas222: pandas>=2.2.2,<2.3
numpy1: numpy>=1.23.5,<2.0
numpy2: numpy>=2.0,<2.1


commands =
pytest -n 2 --cov={toxinidir}/src --cov-report term --cov-report=xml --cov-report=html:htmlcov {toxinidir}/tests
Expand Down
2 changes: 1 addition & 1 deletion src/pyfolio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

pandas_version = Version(pd.__version__)

pandas_one_point_three_or_less = pandas_version < Version("1.4")
pandas_one_point_three_or_less = pandas_version <= Version("1.4")


def one_dec_places(x, pos):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class TestStats(TestCase):
)
]
)
@skipIf(pandas_one_point_three_or_less, "pandas<=1.3 returns np.inf not np.nan")
@skipIf(pandas_one_point_three_or_less, "pandas<=1.4 returns np.inf not np.nan")
def test_sharpe_2(self, returns, rolling_sharpe_window, expected):
np.testing.assert_array_almost_equal(
timeseries.rolling_sharpe(returns, rolling_sharpe_window).to_numpy(),
Expand Down
Loading