Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of python 3.11 for public CI #1501

Merged
merged 11 commits into from
Aug 6, 2023
8 changes: 4 additions & 4 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

strategy:
matrix:
python: ['3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, windows-latest]

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:

strategy:
matrix:
python: ['3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, ubuntu-latest]

experimental: [false]
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:

strategy:
matrix:
python: ['3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11']
experimental: [false]

continue-on-error: ${{ matrix.experimental }}
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:

strategy:
matrix:
python: ['3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, windows-latest]

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
shell: bash -l {0}

env:
python-ver: '3.10'
python-ver: '3.11'
CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: '3.10'
python-version: '3.11'
- uses: pre-commit/[email protected]
3 changes: 3 additions & 0 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# This is necessary to help DPC++ find Intel libraries such as SVML, IRNG, etc in build prefix
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${BUILD_PREFIX}/lib"

# Intel LLVM must cooperate with compiler and sysroot from conda
echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg
export ICPXCFG="$(pwd)/icpx_for_conda.cfg"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _get_cmdclass():
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development
Topic :: Scientific/Engineering
Expand Down
22 changes: 22 additions & 0 deletions tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
from sys import platform

import dpctl
import numpy
from numpy.testing import assert_allclose, assert_array_equal

import dpnp


def assert_dtype_allclose(dpnp_arr, numpy_arr):
"""
Assert DPNP and NumPy array based on maximum dtype resolution of input arrays
for floating and complex types.
For other dtypes the assertion is based on exact matching of the arrays.

"""

is_inexact = lambda x: dpnp.issubdtype(x.dtype, dpnp.inexact)
if is_inexact(dpnp_arr) or is_inexact(numpy_arr):
tol = 8 * max(
numpy.finfo(dpnp_arr.dtype).resolution,
numpy.finfo(numpy_arr.dtype).resolution,
)
assert_allclose(dpnp_arr.asnumpy(), numpy_arr, atol=tol, rtol=tol)
else:
assert_array_equal(dpnp_arr.asnumpy(), numpy_arr)
assert dpnp_arr.dtype == numpy_arr.dtype


def get_complex_dtypes(device=None):
"""
Build a list of complex types supported by DPNP based on device capabilities.
Expand Down
8 changes: 4 additions & 4 deletions tests/test_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ def test_dot_ones(type):
assert_array_equal(expected, result)


@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True))
def test_dot_arange(type):
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
def test_dot_arange(dtype):
n = 10**2
m = 10**3
a = numpy.hstack((numpy.arange(n, dtype=type),) * m)
m = 10**3 if dtype is not inp.float32 else 10**2
a = numpy.hstack((numpy.arange(n, dtype=dtype),) * m)
b = numpy.flipud(a)
ia = inp.array(a)
ib = inp.array(b)
Expand Down
16 changes: 6 additions & 10 deletions tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import dpnp

from .helper import has_support_aspect64
from .helper import assert_dtype_allclose, has_support_aspect64

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

np_res = numpy.fft.fft(data, norm=norm)
dpnp_res = dpnp.asnumpy(dpnp.fft.fft(dpnp_data, norm=norm))
dpnp_res = dpnp.fft.fft(dpnp_data, norm=norm)

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


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

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


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

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


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

numpy.testing.assert_allclose(dpnp_res, np_res, rtol=1e-4, atol=1e-7)
assert dpnp_res.dtype == np_res.dtype
assert_dtype_allclose(dpnp_res, np_res)
5 changes: 2 additions & 3 deletions tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import dpnp

from .helper import get_all_dtypes, is_win_platform
from .helper import assert_dtype_allclose, get_all_dtypes, is_win_platform

list_of_backend_str = [
"host",
Expand Down Expand Up @@ -670,8 +670,7 @@ def test_fft_rfft(type, shape, device):
np_res = numpy.fft.rfft(np_data)
dpnp_res = dpnp.fft.rfft(dpnp_data)

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

expected_queue = dpnp_data.get_array().sycl_queue
result_queue = dpnp_res.get_array().sycl_queue
Expand Down
2 changes: 1 addition & 1 deletion tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def test_tan(self):
np_array = numpy.array(array_data, dtype=numpy.float64)
expected = numpy.tan(np_array, out=out)

assert_array_equal(expected, result)
assert_allclose(expected, result)

@pytest.mark.parametrize(
"dtype",
Expand Down
16 changes: 13 additions & 3 deletions tests/third_party/cupy/fft_tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
class TestFft(unittest.TestCase):
@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(
rtol=1e-4, atol=1e-7, accept_error=ValueError, contiguous_check=False
rtol=1e-4,
atol=1e-7,
accept_error=ValueError,
contiguous_check=False,
type_check=False,
)
def test_fft(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
Expand All @@ -33,7 +37,11 @@ def test_fft(self, xp, dtype):

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(
rtol=1e-4, atol=1e-7, accept_error=ValueError, contiguous_check=False
rtol=1e-4,
atol=1e-7,
accept_error=ValueError,
contiguous_check=False,
type_check=False,
)
def test_ifft(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
Expand Down Expand Up @@ -154,7 +162,9 @@ def test_ifftn(self, xp, dtype):
@testing.gpu
class TestRfft(unittest.TestCase):
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose(rtol=1e-4, atol=1e-7, contiguous_check=False)
@testing.numpy_cupy_allclose(
rtol=1e-4, atol=1e-7, contiguous_check=False, type_check=False
)
def test_rfft(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
out = xp.fft.rfft(a, n=self.n, norm=self.norm)
Expand Down
3 changes: 2 additions & 1 deletion tests/third_party/cupy/sorting_tests/test_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def test_argsort_zero_dim(self, xp, dtype):
@testing.numpy_cupy_array_equal()
def test_argsort_one_dim(self, xp, dtype):
a = testing.shaped_random((10,), xp, dtype)
return self.argsort(a)
res = self.argsort(a)
return a[res]

@testing.for_all_dtypes()
@testing.numpy_cupy_array_equal()
Expand Down