14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
- import numpy as np
18
-
19
-
20
17
# 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
38
36
39
37
cdef int type_bytesize(int typenum):
40
38
"""
@@ -74,7 +72,7 @@ cdef int type_bytesize(int typenum):
74
72
sizeof(float complex ),
75
73
sizeof(double complex ), - 1 ]
76
74
77
- if typenum < 0 :
75
+ if typenum < 0 : # pragma: no cover
78
76
return - 1
79
77
if typenum > 16 :
80
78
if typenum == 23 :
@@ -92,12 +90,12 @@ cdef str _make_typestr(int typenum):
92
90
" |i" , " |u" , " |i" , " |u" , " |i" , " |u" ,
93
91
" |f" , " |f" , " " , " |c" , " |c" , " " ]
94
92
95
- if (typenum < 0 ):
93
+ if (typenum < 0 ): # pragma: no cover
96
94
return " "
97
95
if (typenum > 16 ):
98
96
if (typenum == 23 ):
99
97
return " |f2"
100
- return " "
98
+ return " " # pragma: no cover
101
99
102
100
return type_to_str[typenum] + str (type_bytesize(typenum))
103
101
@@ -126,10 +124,10 @@ cdef int descr_to_typenum(object dtype):
126
124
if (not isinstance (obj, list ) or len (obj) != 1 ):
127
125
return - 1 # token for ValueError
128
126
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
130
128
return - 1
131
129
obj = obj[1 ]
132
- if not isinstance (obj, str ):
130
+ if not isinstance (obj, str ): # pragma: no cover
133
131
return - 1
134
132
return typenum_from_format(obj)
135
133
@@ -146,9 +144,9 @@ cdef int dtype_to_typenum(dtype):
146
144
dt = np.dtype(dtype)
147
145
except TypeError :
148
146
return - 3
149
- except Exception :
147
+ except Exception : # pragma: no cover
150
148
return - 1
151
149
if hasattr (dt, ' descr' ):
152
150
return descr_to_typenum(dt)
153
- else :
151
+ else : # pragma: no cover
154
152
return - 3 # token for TypeError
0 commit comments