@@ -183,7 +183,8 @@ def type_info(np_type):
183
183
with fields ``min`` (minimum value), ``max`` (maximum value), ``nexp``
184
184
(exponent width), ``nmant`` (significand precision not including
185
185
implicit first digit) ``width`` (width in bytes). ``nexp``, ``nmant``
186
- are None for integer types.
186
+ are None for integer types. Both ``min`` and ``max`` are of type
187
+ `np_type`.
187
188
188
189
Raises
189
190
------
@@ -197,39 +198,40 @@ def type_info(np_type):
197
198
that we know are likely to be correct.
198
199
"""
199
200
dt = np .dtype (np_type )
201
+ np_type = dt .type
200
202
width = dt .itemsize
201
203
try : # integer type
202
204
info = np .iinfo (dt )
203
205
except ValueError :
204
206
pass
205
207
else :
206
- return dict (min = info .min , max = info .max , nmant = None , nexp = None ,
207
- width = width )
208
+ return dict (min = np_type ( info .min ) , max = np_type ( info .max ) ,
209
+ nmant = None , nexp = None , width = width )
208
210
info = np .finfo (dt )
209
211
vals = info .nmant , info .nexp , width
210
212
if vals == (10 , 5 , 2 ): # binary16
211
- assert dt . type is _float16
213
+ assert np_type is _float16
212
214
elif vals == (23 , 8 , 4 ): # binary32
213
- assert dt . type is np .float32
215
+ assert np_type is np .float32
214
216
elif vals == (23 , 8 , 8 ): # binary32, complex
215
- assert dt . type is np .complex64
217
+ assert np_type is np .complex64
216
218
elif vals == (52 , 11 , 8 ): # binary64
217
- assert dt . type in (np .float64 , np .longdouble )
219
+ assert np_type in (np .float64 , np .longdouble )
218
220
elif vals == (52 , 11 , 16 ): # binary64, complex
219
- assert dt . type is np .complex128
221
+ assert np_type is np .complex128
220
222
elif vals == (112 , 15 , 16 ): # binary128
221
- assert dt . type is np .longdouble
223
+ assert np_type is np .longdouble
222
224
elif vals in ((63 , 15 , 12 ), (63 , 15 , 16 )): # Intel extended 80
223
- assert dt . type is np .longdouble
225
+ assert np_type is np .longdouble
224
226
elif vals == (1 , 1 , 16 ) and processor () == 'powerpc' : # broken PPC
225
- assert dt . type is np .longdouble
227
+ assert np_type is np .longdouble
226
228
dbl_info = np .finfo (np .float64 )
227
- return dict (min = dbl_info .min , max = dbl_info .max , nmant = 106 , nexp = 11 ,
228
- width = width )
229
+ return dict (min = np_type ( dbl_info .min ) , max = np_type ( dbl_info .max ) ,
230
+ nmant = 106 , nexp = 11 , width = width )
229
231
else : # don't recognize the type
230
232
raise FloatingError ('We had not expected this type' )
231
- return dict (min = info .min , max = info .max , nmant = info .nmant , nexp = info . nexp ,
232
- width = width )
233
+ return dict (min = np_type ( info .min ) , max = np_type ( info .max ) , nmant = info .nmant ,
234
+ nexp = info . nexp , width = width )
233
235
234
236
235
237
def flt2nmant (flt_type ):
0 commit comments