Skip to content

Commit

Permalink
fix: correct dtypes for numpy v2 (#3159)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ianna authored Jun 21, 2024
1 parent 02858f8 commit 6f688e9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jobs:
python-architecture: x86
runs-on: windows-latest
dependencies-kind: full
- python-version: '3.9'
python-architecture: x86
runs-on: windows-latest
dependencies-kind: numpy1
- python-version: '3.8'
python-architecture: x64
runs-on: ubuntu-latest
Expand All @@ -61,18 +65,6 @@ jobs:
python-architecture: x64
runs-on: ubuntu-latest
dependencies-kind: pypy
- python-version: '3.11'
python-architecture: x64
runs-on: ubuntu-latest
dependencies-kind: numpy2
- python-version: '3.11'
python-architecture: x64
runs-on: macos-11
dependencies-kind: numpy2
- python-version: '3.11'
python-architecture: x64
runs-on: windows-latest
dependencies-kind: numpy2

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

Expand Down
1 change: 1 addition & 0 deletions dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def genspectests(specdict):
"""
)
f.write("import pytest\nimport kernels\n\n")
f.write("import pytest\nimport numpy as np\nimport kernels\n\n")
num = 1
if spec.tests == []:
f.write(
Expand Down
4 changes: 4 additions & 0 deletions requirements-test-numpy1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
numpy<2.0.0
pytest>=6
pytest-cov
pytest-xdist
5 changes: 0 additions & 5 deletions requirements-test-numpy2.txt

This file was deleted.

4 changes: 3 additions & 1 deletion src/awkward/_reducers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def _dtype_for_kernel(cls, dtype: DTypeLike) -> DTypeLike:
else:
return dtype

_use32 = (ak._util.win or ak._util.bits32) and not ak._util.numpy2
_use32 = ((ak._util.win or ak._util.bits32) and not ak._util.numpy2) or (
ak._util.numpy2 and np.intp is np.int32
)

@classmethod
def _promote_integer_rank(cls, given_dtype: DTypeLike) -> DTypeLike:
Expand Down

0 comments on commit 6f688e9

Please sign in to comment.