Skip to content

Commit 6538397

Browse files
authored
Add support of python 3.11 for public CI (#1501)
* Added support of python 3.11 * Pinned python back to 3.9 in build sphinx * The change to help icpx to find the libraries in * Updated FFT tests to work with numpy from conda-forge * Update tan test to use assert_allclose * Updated remaing FFT tests * Updated test with dpnp.dot() * Updated argsort test * Reduced array size for single precision dtype in dot() test
1 parent 297810e commit 6538397

File tree

12 files changed

+60
-28
lines changed

12 files changed

+60
-28
lines changed

.github/workflows/conda-package.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
strategy:
3939
matrix:
40-
python: ['3.8', '3.9', '3.10']
40+
python: ['3.8', '3.9', '3.10', '3.11']
4141
os: [ubuntu-20.04, windows-latest]
4242

4343
runs-on: ${{ matrix.os }}
@@ -114,7 +114,7 @@ jobs:
114114

115115
strategy:
116116
matrix:
117-
python: ['3.8', '3.9', '3.10']
117+
python: ['3.8', '3.9', '3.10', '3.11']
118118
os: [ubuntu-20.04, ubuntu-latest]
119119

120120
experimental: [false]
@@ -217,7 +217,7 @@ jobs:
217217

218218
strategy:
219219
matrix:
220-
python: ['3.8', '3.9', '3.10']
220+
python: ['3.8', '3.9', '3.10', '3.11']
221221
experimental: [false]
222222

223223
continue-on-error: ${{ matrix.experimental }}
@@ -350,7 +350,7 @@ jobs:
350350

351351
strategy:
352352
matrix:
353-
python: ['3.8', '3.9', '3.10']
353+
python: ['3.8', '3.9', '3.10', '3.11']
354354
os: [ubuntu-20.04, windows-latest]
355355

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

.github/workflows/generate_coverage.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
shell: bash -l {0}
1515

1616
env:
17-
python-ver: '3.10'
17+
python-ver: '3.11'
1818
CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'
1919

2020
steps:

.github/workflows/pre-commit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ jobs:
1919
- uses: actions/[email protected]
2020
- uses: actions/[email protected]
2121
with:
22-
python-version: '3.10'
22+
python-version: '3.11'
2323
- uses: pre-commit/[email protected]

conda-recipe/build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
# This is necessary to help DPC++ find Intel libraries such as SVML, IRNG, etc in build prefix
4+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${BUILD_PREFIX}/lib"
5+
36
# Intel LLVM must cooperate with compiler and sysroot from conda
47
echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg
58
export ICPXCFG="$(pwd)/icpx_for_conda.cfg"

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def _get_cmdclass():
3737
Programming Language :: Python :: 3.8
3838
Programming Language :: Python :: 3.9
3939
Programming Language :: Python :: 3.10
40+
Programming Language :: Python :: 3.11
4041
Programming Language :: Python :: Implementation :: CPython
4142
Topic :: Software Development
4243
Topic :: Scientific/Engineering

tests/helper.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
from sys import platform
22

33
import dpctl
4+
import numpy
5+
from numpy.testing import assert_allclose, assert_array_equal
46

57
import dpnp
68

79

10+
def assert_dtype_allclose(dpnp_arr, numpy_arr):
11+
"""
12+
Assert DPNP and NumPy array based on maximum dtype resolution of input arrays
13+
for floating and complex types.
14+
For other dtypes the assertion is based on exact matching of the arrays.
15+
16+
"""
17+
18+
is_inexact = lambda x: dpnp.issubdtype(x.dtype, dpnp.inexact)
19+
if is_inexact(dpnp_arr) or is_inexact(numpy_arr):
20+
tol = 8 * max(
21+
numpy.finfo(dpnp_arr.dtype).resolution,
22+
numpy.finfo(numpy_arr.dtype).resolution,
23+
)
24+
assert_allclose(dpnp_arr.asnumpy(), numpy_arr, atol=tol, rtol=tol)
25+
else:
26+
assert_array_equal(dpnp_arr.asnumpy(), numpy_arr)
27+
assert dpnp_arr.dtype == numpy_arr.dtype
28+
29+
830
def get_complex_dtypes(device=None):
931
"""
1032
Build a list of complex types supported by DPNP based on device capabilities.

tests/test_dot.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ def test_dot_ones(type):
2020
assert_array_equal(expected, result)
2121

2222

23-
@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True))
24-
def test_dot_arange(type):
23+
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
24+
def test_dot_arange(dtype):
2525
n = 10**2
26-
m = 10**3
27-
a = numpy.hstack((numpy.arange(n, dtype=type),) * m)
26+
m = 10**3 if dtype is not inp.float32 else 10**2
27+
a = numpy.hstack((numpy.arange(n, dtype=dtype),) * m)
2828
b = numpy.flipud(a)
2929
ia = inp.array(a)
3030
ib = inp.array(b)

tests/test_fft.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import dpnp
55

6-
from .helper import has_support_aspect64
6+
from .helper import assert_dtype_allclose, has_support_aspect64
77

88
pytestmark = pytest.mark.skipif(
99
not has_support_aspect64(), reason="Aborted on Iris Xe: SAT-6028"
@@ -20,10 +20,9 @@ def test_fft(type, norm):
2020
dpnp_data = dpnp.array(data)
2121

2222
np_res = numpy.fft.fft(data, norm=norm)
23-
dpnp_res = dpnp.asnumpy(dpnp.fft.fft(dpnp_data, norm=norm))
23+
dpnp_res = dpnp.fft.fft(dpnp_data, norm=norm)
2424

25-
numpy.testing.assert_allclose(dpnp_res, np_res, rtol=1e-4, atol=1e-7)
26-
assert dpnp_res.dtype == np_res.dtype
25+
assert_dtype_allclose(dpnp_res, np_res)
2726

2827

2928
@pytest.mark.parametrize(
@@ -38,8 +37,7 @@ def test_fft_ndim(type, shape, norm):
3837
np_res = numpy.fft.fft(np_data, norm=norm)
3938
dpnp_res = dpnp.fft.fft(dpnp_data, norm=norm)
4039

41-
numpy.testing.assert_allclose(dpnp_res, np_res, rtol=1e-4, atol=1e-7)
42-
assert dpnp_res.dtype == np_res.dtype
40+
assert_dtype_allclose(dpnp_res, np_res)
4341

4442

4543
@pytest.mark.parametrize(
@@ -56,8 +54,7 @@ def test_fft_ifft(type, shape, norm):
5654
np_res = numpy.fft.ifft(np_data, norm=norm)
5755
dpnp_res = dpnp.fft.ifft(dpnp_data, norm=norm)
5856

59-
numpy.testing.assert_allclose(dpnp_res, np_res, rtol=1e-4, atol=1e-7)
60-
assert dpnp_res.dtype == np_res.dtype
57+
assert_dtype_allclose(dpnp_res, np_res)
6158

6259

6360
@pytest.mark.parametrize("type", ["float32", "float64", "int32", "int64"])
@@ -71,5 +68,4 @@ def test_fft_rfft(type, shape):
7168
np_res = numpy.fft.rfft(np_data)
7269
dpnp_res = dpnp.fft.rfft(dpnp_data)
7370

74-
numpy.testing.assert_allclose(dpnp_res, np_res, rtol=1e-4, atol=1e-7)
75-
assert dpnp_res.dtype == np_res.dtype
71+
assert_dtype_allclose(dpnp_res, np_res)

tests/test_sycl_queue.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import dpnp
88

9-
from .helper import get_all_dtypes, is_win_platform
9+
from .helper import assert_dtype_allclose, get_all_dtypes, is_win_platform
1010

1111
list_of_backend_str = [
1212
"host",
@@ -670,8 +670,7 @@ def test_fft_rfft(type, shape, device):
670670
np_res = numpy.fft.rfft(np_data)
671671
dpnp_res = dpnp.fft.rfft(dpnp_data)
672672

673-
numpy.testing.assert_allclose(dpnp_res, np_res, rtol=1e-4, atol=1e-7)
674-
assert dpnp_res.dtype == np_res.dtype
673+
assert_dtype_allclose(dpnp_res, np_res)
675674

676675
expected_queue = dpnp_data.get_array().sycl_queue
677676
result_queue = dpnp_res.get_array().sycl_queue

tests/test_umath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def test_tan(self):
480480
np_array = numpy.array(array_data, dtype=numpy.float64)
481481
expected = numpy.tan(np_array, out=out)
482482

483-
assert_array_equal(expected, result)
483+
assert_allclose(expected, result)
484484

485485
@pytest.mark.parametrize(
486486
"dtype",

tests/third_party/cupy/fft_tests/test_fft.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
class TestFft(unittest.TestCase):
2424
@testing.for_all_dtypes()
2525
@testing.numpy_cupy_allclose(
26-
rtol=1e-4, atol=1e-7, accept_error=ValueError, contiguous_check=False
26+
rtol=1e-4,
27+
atol=1e-7,
28+
accept_error=ValueError,
29+
contiguous_check=False,
30+
type_check=False,
2731
)
2832
def test_fft(self, xp, dtype):
2933
a = testing.shaped_random(self.shape, xp, dtype)
@@ -33,7 +37,11 @@ def test_fft(self, xp, dtype):
3337

3438
@testing.for_all_dtypes()
3539
@testing.numpy_cupy_allclose(
36-
rtol=1e-4, atol=1e-7, accept_error=ValueError, contiguous_check=False
40+
rtol=1e-4,
41+
atol=1e-7,
42+
accept_error=ValueError,
43+
contiguous_check=False,
44+
type_check=False,
3745
)
3846
def test_ifft(self, xp, dtype):
3947
a = testing.shaped_random(self.shape, xp, dtype)
@@ -154,7 +162,9 @@ def test_ifftn(self, xp, dtype):
154162
@testing.gpu
155163
class TestRfft(unittest.TestCase):
156164
@testing.for_all_dtypes(no_complex=True)
157-
@testing.numpy_cupy_allclose(rtol=1e-4, atol=1e-7, contiguous_check=False)
165+
@testing.numpy_cupy_allclose(
166+
rtol=1e-4, atol=1e-7, contiguous_check=False, type_check=False
167+
)
158168
def test_rfft(self, xp, dtype):
159169
a = testing.shaped_random(self.shape, xp, dtype)
160170
out = xp.fft.rfft(a, n=self.n, norm=self.norm)

tests/third_party/cupy/sorting_tests/test_sort.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ def test_argsort_zero_dim(self, xp, dtype):
317317
@testing.numpy_cupy_array_equal()
318318
def test_argsort_one_dim(self, xp, dtype):
319319
a = testing.shaped_random((10,), xp, dtype)
320-
return self.argsort(a)
320+
res = self.argsort(a)
321+
return a[res]
321322

322323
@testing.for_all_dtypes()
323324
@testing.numpy_cupy_array_equal()

0 commit comments

Comments
 (0)