Skip to content

Fix tests for py3.11 #1172

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

Merged
merged 3 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/generate-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

env:
ONEAPI_ROOT: /opt/intel/oneapi
GTEST_ROOT: /home/runner/work/googletest-release-1.11.0/install
GTEST_ROOT: /home/runner/work/googletest-1.13.0/install

steps:
- name: Cancel Previous Runs
Expand Down Expand Up @@ -39,16 +39,16 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
architecture: x64

- name: Cache Gtest
id: cache-gtest
uses: actions/cache@v3
with:
path: |
/home/runner/work/googletest-release-1.11.0/install
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('/home/runner/work/googletest-release-1.11.0/install/include/gtest/*') }}
/home/runner/work/googletest-1.13.0/install
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('/home/runner/work/googletest-1.13.0/install/include/gtest/*') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
Expand All @@ -59,12 +59,12 @@ jobs:
shell: bash -l {0}
run: |
cd /home/runner/work
wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
tar xf release-1.11.0.tar.gz
cd googletest-release-1.11.0
wget https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz
tar xf v1.13.0.tar.gz
cd googletest-1.13.0
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/home/runner/work/googletest-release-1.11.0/install
cmake .. -DCMAKE_INSTALL_PREFIX=/home/runner/work/googletest-1.13.0/install
make && make install

- name: Checkout repo
Expand Down
10 changes: 8 additions & 2 deletions dpctl/tensor/_ctors.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,12 @@ def _get_arange_length(start, stop, step):
return _round_for_arange(tmp)


def _to_scalar(obj, sc_ty):
"A way to convert object to NumPy scalar type"
zd_arr = np.asarray(obj).astype(sc_ty, casting="unsafe")
return zd_arr[tuple()]


def arange(
start,
/,
Expand Down Expand Up @@ -861,9 +867,9 @@ def arange(
buffer_ctor_kwargs={"queue": sycl_queue},
)
sc_ty = dt.type
_first = sc_ty(start)
_first = _to_scalar(start, sc_ty)
if sh > 1:
_second = sc_ty(start + step)
_second = _to_scalar(start + step, sc_ty)
if dt in [dpt.uint8, dpt.uint16, dpt.uint32, dpt.uint64]:
int64_ty = dpt.int64.type
_step = int64_ty(_second) - int64_ty(_first)
Expand Down
9 changes: 8 additions & 1 deletion dpctl/tests/test_sycl_queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

import contextlib
import sys

import pytest
from helper import has_cpu, has_gpu, has_sycl_platforms
Expand Down Expand Up @@ -216,7 +217,13 @@ def factory(_):
"factory, exception, match",
[
(True, TypeError, "object is not callable"),
(lambda x: None, AttributeError, "no attribute '__exit__'"),
(lambda x: None, AttributeError, "no attribute '__exit__'")
if sys.version_info < (3, 11)
else (
lambda x: None,
TypeError,
r".* object does not support the context manager protocol",
),
],
)
def test_nested_context_factory_exception_if_wrong_factory(
Expand Down