Skip to content

Commit

Permalink
Require NumPy 2.x and Python 3.9+
Browse files Browse the repository at this point in the history
Replace usages of float_ with float64.
  • Loading branch information
p00ya committed Sep 7, 2024
1 parent e7d5d5b commit 9965e15
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 20 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -55,12 +55,8 @@ jobs:
python3 -X dev -m pytest
- name: mypy
run: |
if dpkg --compare-versions "${{ matrix.python-version }}" ge "3.9" ; then
python3 -m mypy --strict -p climbing_ratings
python3 -m mypy --strict tests/test_climbing_ratings.py
else
echo "skipping type checking; needs Python 3.9"
fi
python3 -m mypy --strict -p climbing_ratings
python3 -m mypy --strict tests/test_climbing_ratings.py
lint:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Results of analyzing a database of Australian ascents with an earlier version of

The estimation algorithms are implemented in Python and Cython, in the `climbing_ratings` package. Some effort has been taken to optimize parts of the code for speed, namely by leveraging numpy for vectorized operations and using Cython to reduce Python overheads and allow C compilers to generate vectorized CPU instructions.

Python 3.7+ with pip is required; Python 3.9 is recommended. The additional dependencies can be installed with:
Python 3.9+ with pip is required. The additional dependencies can be installed with:

```sh
python3 -m pip install Cython numpy pytest
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
from typing import Any, Callable, List, Tuple, cast


_Array = NDArray[np.float_]
_Array = NDArray[np.float64]


class TableReader:
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/bradley_terry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from numpy.typing import NDArray
from typing import List, Tuple
from .slices import Slices

_Array = NDArray[np.float_]
_Array = NDArray[np.float64]

def expand_to_slices(
values: _Array,
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/derivatives.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ from numpy.typing import NDArray
from typing import List, Tuple
from .slices import Slices

_Array = NDArray[np.float_]
_Array = NDArray[np.float64]

class TriDiagonal:
def __init__(self, d: _Array, u: _Array, l: _Array) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions climbing_ratings/tests/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def assert_close(
test_case: unittest.TestCase,
expected: ArrayLike,
actual: NDArray[np.float_],
actual: NDArray[np.float64],
name: str,
) -> None:
"""Raise an exception if expected does not equal actual.
Expand All @@ -54,7 +54,7 @@ def assert_close(

def assert_close_get(
test_case: unittest.TestCase, owner: type
) -> Callable[[ArrayLike, NDArray[np.float_], str], None]:
) -> Callable[[ArrayLike, NDArray[np.float64], str], None]:
"""Returns assert_close bound to a particular test case.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/tests/test_bradley_terry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from .assertions import assert_close_get


_Array = NDArray[np.float_]
_Array = NDArray[np.float64]


class TestBradleyTerryFunctions(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/tests/test_csum.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ..csum import _csum


_Array = NDArray[np.float_]
_Array = NDArray[np.float64]


class TestCsumFunctions(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/tests/test_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .assertions import assert_close_get


_Array = NDArray[np.float_]
_Array = NDArray[np.float64]


class TestDerivativesFunctions(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion climbing_ratings/whole_history_rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from typing import List, NamedTuple, Optional, Tuple, Union, cast


_Array = NDArray[np.float_]
_Array = NDArray[np.float64]


class Hyperparameters(NamedTuple):
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
include_package_data=False,
package_data={"climbing_ratings": ["*.pyi", "*.pyx"]},
platforms=["POSIX"],
python_requires=">=3.7",
install_requires=["numpy>=1.21"],
setup_requires=["Cython>=3.0.0", "numpy>=1.21"],
python_requires=">=3.9",
install_requires=["numpy>=2.0.0"],
setup_requires=["Cython>=3.0.0", "numpy>=2.0.0"],
test_suite="climbing_ratings.tests.test_suite",
tests_require=["numpy", "pytest"],
ext_modules=cythonize(
Expand Down

0 comments on commit 9965e15

Please sign in to comment.