Skip to content

Commit 6f688e9

Browse files
authored
fix: correct dtypes for numpy v2 (#3159)
* fix: import numpy for tests * fix: use the platform integer type * fix: use type * fix: np.intp type * fix: only for numpy 2+ * fix: remove duplicate workflows and test windows with numpy v1.xx * fix: add coverage * fix: remove duplicate test
1 parent 02858f8 commit 6f688e9

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ jobs:
5353
python-architecture: x86
5454
runs-on: windows-latest
5555
dependencies-kind: full
56+
- python-version: '3.9'
57+
python-architecture: x86
58+
runs-on: windows-latest
59+
dependencies-kind: numpy1
5660
- python-version: '3.8'
5761
python-architecture: x64
5862
runs-on: ubuntu-latest
@@ -61,18 +65,6 @@ jobs:
6165
python-architecture: x64
6266
runs-on: ubuntu-latest
6367
dependencies-kind: pypy
64-
- python-version: '3.11'
65-
python-architecture: x64
66-
runs-on: ubuntu-latest
67-
dependencies-kind: numpy2
68-
- python-version: '3.11'
69-
python-architecture: x64
70-
runs-on: macos-11
71-
dependencies-kind: numpy2
72-
- python-version: '3.11'
73-
python-architecture: x64
74-
runs-on: windows-latest
75-
dependencies-kind: numpy2
7668

7769
runs-on: ${{ matrix.runs-on }}
7870

dev/generate-tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ def genspectests(specdict):
425425
"""
426426
)
427427
f.write("import pytest\nimport kernels\n\n")
428+
f.write("import pytest\nimport numpy as np\nimport kernels\n\n")
428429
num = 1
429430
if spec.tests == []:
430431
f.write(

requirements-test-numpy1.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
numpy<2.0.0
2+
pytest>=6
3+
pytest-cov
4+
pytest-xdist

requirements-test-numpy2.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/awkward/_reducers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def _dtype_for_kernel(cls, dtype: DTypeLike) -> DTypeLike:
6262
else:
6363
return dtype
6464

65-
_use32 = (ak._util.win or ak._util.bits32) and not ak._util.numpy2
65+
_use32 = ((ak._util.win or ak._util.bits32) and not ak._util.numpy2) or (
66+
ak._util.numpy2 and np.intp is np.int32
67+
)
6668

6769
@classmethod
6870
def _promote_integer_rank(cls, given_dtype: DTypeLike) -> DTypeLike:

0 commit comments

Comments
 (0)