diff --git a/dpctl/_init_helper.py b/dpctl/_init_helper.py index db3ca3f7c8..e3903c7156 100644 --- a/dpctl/_init_helper.py +++ b/dpctl/_init_helper.py @@ -24,7 +24,7 @@ and os.path.isfile(os.path.join(sys.exec_prefix, "pyvenv.cfg")) ) -if is_venv_win32: +if is_venv_win32: # pragma: no cover # For virtual environments on Windows, add folder # with DPC++ libraries to the DLL search path gh-1745 dll_dir = os.path.join(sys.exec_prefix, "Library", "bin") diff --git a/dpctl/tensor/_numpy_helper.py b/dpctl/tensor/_numpy_helper.py index 5f369b5d0d..1325faa3bf 100644 --- a/dpctl/tensor/_numpy_helper.py +++ b/dpctl/tensor/_numpy_helper.py @@ -18,14 +18,14 @@ _npver = np.lib.NumpyVersion(np.__version__) -if _npver < "1.25.0": +if _npver < "1.25.0": # pragma: no cover from numpy import AxisError else: from numpy.exceptions import AxisError if _npver >= "2.0.0": from numpy._core.numeric import normalize_axis_index, normalize_axis_tuple -else: +else: # pragma: no cover from numpy.core.numeric import normalize_axis_index, normalize_axis_tuple diff --git a/dpctl/tensor/_types.pxi b/dpctl/tensor/_types.pxi index f2d26cb16c..df47fa28dc 100644 --- a/dpctl/tensor/_types.pxi +++ b/dpctl/tensor/_types.pxi @@ -14,27 +14,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np - - # these typenum values are aligned to values in NumPy -cdef int UAR_BOOL = 0 -cdef int UAR_BYTE = 1 -cdef int UAR_UBYTE = 2 -cdef int UAR_SHORT = 3 -cdef int UAR_USHORT = 4 -cdef int UAR_INT = 5 -cdef int UAR_UINT = 6 -cdef int UAR_LONG = 7 -cdef int UAR_ULONG = 8 -cdef int UAR_LONGLONG = 9 -cdef int UAR_ULONGLONG = 10 -cdef int UAR_FLOAT = 11 -cdef int UAR_DOUBLE = 12 -cdef int UAR_CFLOAT = 14 -cdef int UAR_CDOUBLE = 15 -cdef int UAR_TYPE_SENTINEL = 17 -cdef int UAR_HALF = 23 +cdef: + int UAR_BOOL = 0 # pragma: no cover + int UAR_BYTE = 1 # pragma: no cover + int UAR_UBYTE = 2 # pragma: no cover + int UAR_SHORT = 3 # pragma: no cover + int UAR_USHORT = 4 # pragma: no cover + int UAR_INT = 5 # pragma: no cover + int UAR_UINT = 6 # pragma: no cover + int UAR_LONG = 7 # pragma: no cover + int UAR_ULONG = 8 # pragma: no cover + int UAR_LONGLONG = 9 # pragma: no cover + int UAR_ULONGLONG = 10 # pragma: no cover + int UAR_FLOAT = 11 # pragma: no cover + int UAR_DOUBLE = 12 # pragma: no cover + int UAR_CFLOAT = 14 # pragma: no cover + int UAR_CDOUBLE = 15 # pragma: no cover + int UAR_TYPE_SENTINEL = 17 # pragma: no cover + int UAR_HALF = 23 # pragma: no cover cdef int type_bytesize(int typenum): """ @@ -74,7 +72,7 @@ cdef int type_bytesize(int typenum): sizeof(float complex), sizeof(double complex), -1] - if typenum < 0: + if typenum < 0: # pragma: no cover return -1 if typenum > 16: if typenum == 23: @@ -92,12 +90,12 @@ cdef str _make_typestr(int typenum): "|i", "|u", "|i", "|u", "|i", "|u", "|f", "|f", "", "|c", "|c", ""] - if (typenum < 0): + if (typenum < 0): # pragma: no cover return "" if (typenum > 16): if (typenum == 23): return "|f2" - return "" + return "" # pragma: no cover return type_to_str[typenum] + str(type_bytesize(typenum)) @@ -126,10 +124,10 @@ cdef int descr_to_typenum(object dtype): if (not isinstance(obj, list) or len(obj) != 1): return -1 # token for ValueError obj = obj[0] - if (not isinstance(obj, tuple) or len(obj) != 2 or obj[0]): + if (not isinstance(obj, tuple) or len(obj) != 2 or obj[0]): # pragma: no cover return -1 obj = obj[1] - if not isinstance(obj, str): + if not isinstance(obj, str): # pragma: no cover return -1 return typenum_from_format(obj) @@ -146,9 +144,9 @@ cdef int dtype_to_typenum(dtype): dt = np.dtype(dtype) except TypeError: return -3 - except Exception: + except Exception: # pragma: no cover return -1 if hasattr(dt, 'descr'): return descr_to_typenum(dt) - else: + else: # pragma: no cover return -3 # token for TypeError diff --git a/dpctl/tests/test_utils.py b/dpctl/tests/test_utils.py index 633438b9e0..fac9f41a7b 100644 --- a/dpctl/tests/test_utils.py +++ b/dpctl/tests/test_utils.py @@ -151,6 +151,12 @@ def test_intel_device_info(): assert test, err_msg +def test_intel_device_info_validation(): + invalid_device = dict() + with pytest.raises(TypeError): + dpctl.utils.intel_device_info(invalid_device) + + def test_order_manager(): try: q = dpctl.SyclQueue() diff --git a/dpctl/utils/_intel_device_info.py b/dpctl/utils/_intel_device_info.py index fd59623dd9..f4de00a8f4 100644 --- a/dpctl/utils/_intel_device_info.py +++ b/dpctl/utils/_intel_device_info.py @@ -69,11 +69,11 @@ def intel_device_info(dev, /): if not isinstance(dev, SyclDevice): raise TypeError(f"Expected dpctl.SyclDevice, got {type(dev)}") dev_id = intel_device_info_device_id(dev) - if dev_id: + if dev_id: # pragma: no cover res = { "device_id": dev_id, } - if dev.has_aspect_gpu: + if dev.has_aspect_gpu: # pragma: no cover eu_count = intel_device_info_gpu_eu_count(dev) if eu_count: res["gpu_eu_count"] = eu_count