Skip to content

Commit 653f579

Browse files
Merge pull request #1970 from IntelPython/improve-coverage-stats
Improve coverage stats
2 parents a7e85a2 + b51a19f commit 653f579

File tree

5 files changed

+36
-32
lines changed

5 files changed

+36
-32
lines changed

dpctl/_init_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
and os.path.isfile(os.path.join(sys.exec_prefix, "pyvenv.cfg"))
2525
)
2626

27-
if is_venv_win32:
27+
if is_venv_win32: # pragma: no cover
2828
# For virtual environments on Windows, add folder
2929
# with DPC++ libraries to the DLL search path gh-1745
3030
dll_dir = os.path.join(sys.exec_prefix, "Library", "bin")

dpctl/tensor/_numpy_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
_npver = np.lib.NumpyVersion(np.__version__)
2020

21-
if _npver < "1.25.0":
21+
if _npver < "1.25.0": # pragma: no cover
2222
from numpy import AxisError
2323
else:
2424
from numpy.exceptions import AxisError
2525

2626
if _npver >= "2.0.0":
2727
from numpy._core.numeric import normalize_axis_index, normalize_axis_tuple
28-
else:
28+
else: # pragma: no cover
2929
from numpy.core.numeric import normalize_axis_index, normalize_axis_tuple
3030

3131

dpctl/tensor/_types.pxi

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,25 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import numpy as np
18-
19-
2017
# these typenum values are aligned to values in NumPy
21-
cdef int UAR_BOOL = 0
22-
cdef int UAR_BYTE = 1
23-
cdef int UAR_UBYTE = 2
24-
cdef int UAR_SHORT = 3
25-
cdef int UAR_USHORT = 4
26-
cdef int UAR_INT = 5
27-
cdef int UAR_UINT = 6
28-
cdef int UAR_LONG = 7
29-
cdef int UAR_ULONG = 8
30-
cdef int UAR_LONGLONG = 9
31-
cdef int UAR_ULONGLONG = 10
32-
cdef int UAR_FLOAT = 11
33-
cdef int UAR_DOUBLE = 12
34-
cdef int UAR_CFLOAT = 14
35-
cdef int UAR_CDOUBLE = 15
36-
cdef int UAR_TYPE_SENTINEL = 17
37-
cdef int UAR_HALF = 23
18+
cdef:
19+
int UAR_BOOL = 0 # pragma: no cover
20+
int UAR_BYTE = 1 # pragma: no cover
21+
int UAR_UBYTE = 2 # pragma: no cover
22+
int UAR_SHORT = 3 # pragma: no cover
23+
int UAR_USHORT = 4 # pragma: no cover
24+
int UAR_INT = 5 # pragma: no cover
25+
int UAR_UINT = 6 # pragma: no cover
26+
int UAR_LONG = 7 # pragma: no cover
27+
int UAR_ULONG = 8 # pragma: no cover
28+
int UAR_LONGLONG = 9 # pragma: no cover
29+
int UAR_ULONGLONG = 10 # pragma: no cover
30+
int UAR_FLOAT = 11 # pragma: no cover
31+
int UAR_DOUBLE = 12 # pragma: no cover
32+
int UAR_CFLOAT = 14 # pragma: no cover
33+
int UAR_CDOUBLE = 15 # pragma: no cover
34+
int UAR_TYPE_SENTINEL = 17 # pragma: no cover
35+
int UAR_HALF = 23 # pragma: no cover
3836

3937
cdef int type_bytesize(int typenum):
4038
"""
@@ -74,7 +72,7 @@ cdef int type_bytesize(int typenum):
7472
sizeof(float complex),
7573
sizeof(double complex), -1]
7674

77-
if typenum < 0:
75+
if typenum < 0: # pragma: no cover
7876
return -1
7977
if typenum > 16:
8078
if typenum == 23:
@@ -92,12 +90,12 @@ cdef str _make_typestr(int typenum):
9290
"|i", "|u", "|i", "|u", "|i", "|u",
9391
"|f", "|f", "", "|c", "|c", ""]
9492

95-
if (typenum < 0):
93+
if (typenum < 0): # pragma: no cover
9694
return ""
9795
if (typenum > 16):
9896
if (typenum == 23):
9997
return "|f2"
100-
return ""
98+
return "" # pragma: no cover
10199

102100
return type_to_str[typenum] + str(type_bytesize(typenum))
103101

@@ -126,10 +124,10 @@ cdef int descr_to_typenum(object dtype):
126124
if (not isinstance(obj, list) or len(obj) != 1):
127125
return -1 # token for ValueError
128126
obj = obj[0]
129-
if (not isinstance(obj, tuple) or len(obj) != 2 or obj[0]):
127+
if (not isinstance(obj, tuple) or len(obj) != 2 or obj[0]): # pragma: no cover
130128
return -1
131129
obj = obj[1]
132-
if not isinstance(obj, str):
130+
if not isinstance(obj, str): # pragma: no cover
133131
return -1
134132
return typenum_from_format(obj)
135133

@@ -146,9 +144,9 @@ cdef int dtype_to_typenum(dtype):
146144
dt = np.dtype(dtype)
147145
except TypeError:
148146
return -3
149-
except Exception:
147+
except Exception: # pragma: no cover
150148
return -1
151149
if hasattr(dt, 'descr'):
152150
return descr_to_typenum(dt)
153-
else:
151+
else: # pragma: no cover
154152
return -3 # token for TypeError

dpctl/tests/test_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ def test_intel_device_info():
151151
assert test, err_msg
152152

153153

154+
def test_intel_device_info_validation():
155+
invalid_device = dict()
156+
with pytest.raises(TypeError):
157+
dpctl.utils.intel_device_info(invalid_device)
158+
159+
154160
def test_order_manager():
155161
try:
156162
q = dpctl.SyclQueue()

dpctl/utils/_intel_device_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def intel_device_info(dev, /):
6969
if not isinstance(dev, SyclDevice):
7070
raise TypeError(f"Expected dpctl.SyclDevice, got {type(dev)}")
7171
dev_id = intel_device_info_device_id(dev)
72-
if dev_id:
72+
if dev_id: # pragma: no cover
7373
res = {
7474
"device_id": dev_id,
7575
}
76-
if dev.has_aspect_gpu:
76+
if dev.has_aspect_gpu: # pragma: no cover
7777
eu_count = intel_device_info_gpu_eu_count(dev)
7878
if eu_count:
7979
res["gpu_eu_count"] = eu_count

0 commit comments

Comments
 (0)