Skip to content

Commit

Permalink
MNT: test with numpy 2.0.0rc1 and fix API changes of np.array()'s cop…
Browse files Browse the repository at this point in the history
…y kwarg (#450)
  • Loading branch information
bnavigator authored May 23, 2024
1 parent 0aa41ca commit c5356da
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
numpy-version: [""]
architecture: [x86, x64]
os:
[
Expand All @@ -27,6 +28,12 @@ jobs:
architecture: x86
- os: macos-12
architecture: x86
include:
- python-version: "3.12"
numpy-version: ">=2.0.0rc1"
architecture: x64
os: ubuntu-latest

steps:
- uses: actions/checkout@v4

Expand All @@ -42,7 +49,7 @@ jobs:
- name: Test with pytest
run: |
pip install pytest
pip install pytest "numpy${{ matrix.numpy-version }}"
pytest --pyargs bottleneck
check:
Expand Down
8 changes: 4 additions & 4 deletions bottleneck/slow/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def move_argmin(a, window, min_count=None, axis=-1):
"Slow move_argmin for unaccelerated dtype"

def argmin(a, axis):
a = np.array(a, copy=False)
a = np.asarray(a)
flip = [slice(None)] * a.ndim
flip[axis] = slice(None, None, -1)
a = a[tuple(flip)] # if tie, pick index of rightmost tie
Expand All @@ -78,7 +78,7 @@ def move_argmax(a, window, min_count=None, axis=-1):
"Slow move_argmax for unaccelerated dtype"

def argmax(a, axis):
a = np.array(a, copy=False)
a = np.asarray(a)
flip = [slice(None)] * a.ndim
flip[axis] = slice(None, None, -1)
a = a[tuple(flip)] # if tie, pick index of rightmost tie
Expand Down Expand Up @@ -115,7 +115,7 @@ def move_rank(a, window, min_count=None, axis=-1):

def move_func(func, a, window, min_count=None, axis=-1, **kwargs):
"Generic moving window function implemented with a python loop."
a = np.array(a, copy=False)
a = np.asarray(a)
if min_count is None:
mc = window
else:
Expand Down Expand Up @@ -226,7 +226,7 @@ def lastrank(a, axis=-1):
-0.5
"""
a = np.array(a, copy=False)
a = np.asarray(a)
ndim = a.ndim
if a.size == 0:
# At least one dimension has length 0
Expand Down
2 changes: 1 addition & 1 deletion bottleneck/slow/nonreduce_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def nanrankdata(a, axis=None):


def _rank(func1d, a, axis):
a = np.array(a, copy=False)
a = np.asarray(a)
if axis is None:
a = a.ravel()
axis = 0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ requires = [
# and disabling build isolation.
# 3. The <2.3 upper bound is for matching the numpy deprecation policy,
# it should not be loosened
"numpy>=2.0.0rc1<2.3 ; python_version >= '3.9'",
"numpy>=2.0.0rc1,<2.3 ; python_version >= '3.9'",
]
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,6 @@ def get_long_description():
install_requires=["numpy"],
extras_require={"doc": ["numpydoc", "sphinx", "gitpython"]},
cmdclass=cmdclass,
setup_requires=[
"oldest-supported-numpy ; python_version < '3.9'",
"numpy>=2.0.0rc1 ; python_version >= '3.9'"
],
ext_modules=prepare_modules(),
zip_safe=False,
)
Expand Down

0 comments on commit c5356da

Please sign in to comment.