Skip to content

Commit 5ad8a37

Browse files
Merge pull request #42 from IntelPython/support-numpy-2.0
Support numpy 2.0
2 parents 50a443a + aac1e22 commit 5ad8a37

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

.github/workflows/build-with-clang.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
name: Build project with IntelLLVM clang compiler
1212
runs-on: ubuntu-latest
1313

14+
strategy:
15+
matrix:
16+
python: ["3.9", "3.10", "3.11", "3.12"]
17+
use_pre: ["", "--pre"]
1418
env:
1519
ONEAPI_ROOT: /opt/intel/oneapi
1620

@@ -37,7 +41,7 @@ jobs:
3741
- name: Setup Python
3842
uses: actions/setup-python@v5
3943
with:
40-
python-version: '3.12'
44+
python-version: ${{ matrix.python }}
4145
architecture: x64
4246

4347
- name: Checkout repo
@@ -48,7 +52,8 @@ jobs:
4852
- name: Install mkl_random dependencies
4953
shell: bash -l {0}
5054
run: |
51-
pip install numpy cython setuptools pytest pytest-cov
55+
pip install cython setuptools pytest pytest-cov
56+
pip install numpy ${{ matrix.use_pre }}
5257
5358
- name: List oneAPI folder content
5459
shell: bash -l {0}

.github/workflows/conda-package.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python: ["3.9", "3.10", "3.11", "3.12"]
19+
python: ["3.9", "3.10"]
2020
steps:
2121
- uses: actions/checkout@v4
2222
with:
@@ -59,11 +59,11 @@ jobs:
5959
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
6060

6161
build_windows:
62-
runs-on: windows-latest
62+
runs-on: windows-2019
6363

6464
strategy:
6565
matrix:
66-
python: ['3.9', '3.10', '3.11', '3.12']
66+
python: ['3.9', '3.10']
6767
env:
6868
conda-bld: C:\Miniconda\conda-bld\win-64\
6969
steps:
@@ -102,7 +102,7 @@ jobs:
102102

103103
strategy:
104104
matrix:
105-
python: ['3.9', '3.10', '3.11', '3.12']
105+
python: ['3.9', '3.10']
106106
experimental: [false]
107107
runner: [ubuntu-latest]
108108
continue-on-error: ${{ matrix.experimental }}
@@ -169,9 +169,9 @@ jobs:
169169

170170
strategy:
171171
matrix:
172-
python: ['3.9', '3.10', '3.11', '3.12']
172+
python: ['3.9', '3.10']
173173
experimental: [false]
174-
runner: [windows-latest]
174+
runner: [windows-2019]
175175
continue-on-error: ${{ matrix.experimental }}
176176
env:
177177
CHANNELS: -c conda-forge -c intel --override-channels

mkl_random/mklrand.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ cdef class RandomState:
16871687
ret = randfunc(low, high - 1, size)
16881688

16891689
if size is None:
1690-
if dtype in (bool, int, np.compat.long):
1690+
if dtype in (bool, int):
16911691
return dtype(ret)
16921692

16931693
return ret
@@ -1893,7 +1893,7 @@ cdef class RandomState:
18931893
"""
18941894

18951895
# Format and Verify input
1896-
a = np.array(a, copy=False)
1896+
a = np.asarray(a)
18971897
if a.ndim == 0:
18981898
try:
18991899
# __index__ must return an integer by python rules.
@@ -1942,7 +1942,7 @@ cdef class RandomState:
19421942
cdf /= cdf[-1]
19431943
uniform_samples = self.random_sample(shape)
19441944
idx = cdf.searchsorted(uniform_samples, side='right')
1945-
idx = np.array(idx, copy=False) # searchsorted returns a scalar
1945+
idx = np.asarray(idx) # searchsorted returns a scalar
19461946
else:
19471947
idx = self.randint(0, pop_size, size=shape)
19481948
else:

mkl_random/tests/test_random.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from numpy.testing import (
3232
assert_, assert_raises, assert_equal,
3333
assert_warns, suppress_warnings)
34-
from numpy.compat import asbytes
3534
import sys
3635
import warnings
3736

@@ -500,7 +499,7 @@ def test_choice_return_shape():
500499
def test_randomdist_bytes(randomdist):
501500
rnd.seed(randomdist.seed, brng=randomdist.brng)
502501
actual = rnd.bytes(10)
503-
desired = asbytes('\xa4\xde\xde{\xb4\x88\xe6\x84*2')
502+
desired = b'\xa4\xde\xde{\xb4\x88\xe6\x84*2'
504503
np.testing.assert_equal(actual, desired)
505504

506505

mkl_random/tests/test_regression.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from numpy.testing import (TestCase, assert_,
2929
assert_array_equal, assert_raises)
3030
import mkl_random as rnd
31-
from numpy.compat import long
3231
import numpy as np
3332

3433
import pytest
@@ -78,7 +77,9 @@ def test_permutation_longs():
7877
rnd.seed(1234, brng='MT19937')
7978
a = rnd.permutation(12)
8079
rnd.seed(1234, brng='MT19937')
81-
b = rnd.permutation(long(12))
80+
dt_long = np.dtype("long")
81+
twelve_long = dt_long.type(12)
82+
b = rnd.permutation(twelve_long)
8283
assert_array_equal(a, b)
8384

8485

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
Programming Language :: C
5151
Programming Language :: Python
5252
Programming Language :: Python :: 3
53-
Programming Language :: Python :: 3.7
54-
Programming Language :: Python :: 3.8
5553
Programming Language :: Python :: 3.9
5654
Programming Language :: Python :: 3.10
55+
Programming Language :: Python :: 3.11
56+
Programming Language :: Python :: 3.12
5757
Programming Language :: Python :: Implementation :: CPython
5858
Topic :: Software Development
5959
Topic :: Scientific/Engineering
@@ -95,7 +95,8 @@ def extensions():
9595

9696
defs = [('_FILE_OFFSET_BITS', '64'),
9797
('_LARGEFILE_SOURCE', '1'),
98-
('_LARGEFILE64_SOURCE', '1')]
98+
('_LARGEFILE64_SOURCE', '1'),
99+
("PY_ARRAY_UNIQUE_SYMBOL", "mkl_random_ext")]
99100

100101
exts = [
101102
Extension(

0 commit comments

Comments
 (0)