@@ -200,30 +200,29 @@ def type_info(np_type):
200
200
return dict (min = np_type (info .min ), max = np_type (info .max ),
201
201
nmant = None , nexp = None , width = width )
202
202
info = np .finfo (dt )
203
- vals = info .nmant , info .nexp , width
204
- if vals == (10 , 5 , 2 ): # binary16
205
- assert np_type is _float16
206
- elif vals == (23 , 8 , 4 ): # binary32
207
- assert np_type is np .float32
208
- elif vals == (23 , 8 , 8 ): # binary32, complex
209
- assert np_type is np .complex64
210
- elif vals == (52 , 11 , 8 ): # binary64
211
- assert np_type in (np .float64 , np .longdouble )
212
- elif vals == (52 , 11 , 16 ): # binary64, complex
213
- assert np_type is np .complex128
214
- elif vals == (112 , 15 , 16 ): # binary128
215
- assert np_type is np .longdouble
216
- elif vals in ((63 , 15 , 12 ), (63 , 15 , 16 )): # Intel extended 80
203
+ # Trust the standard IEEE types
204
+ nmant , nexp = info .nmant , info .nexp
205
+ ret = dict (min = np_type (info .min ), max = np_type (info .max ), nmant = nmant ,
206
+ nexp = nexp , width = width )
207
+ if np_type in (_float16 , np .float32 , np .float64 ,
208
+ np .complex64 , np .complex128 ):
209
+ return ret
210
+ if dt .kind == 'c' :
211
+ assert np_type is np .longcomplex
212
+ vals = (nmant , nexp , width / 2 )
213
+ else :
217
214
assert np_type is np .longdouble
215
+ vals = (nmant , nexp , width )
216
+ if vals in ((112 , 15 , 16 ), # binary128
217
+ (63 , 15 , 12 ), (63 , 15 , 16 )): # Intel extended 80
218
+ pass # these are OK
218
219
elif vals == (1 , 1 , 16 ) and processor () == 'powerpc' : # broken PPC
219
- assert np_type is np .longdouble
220
220
dbl_info = np .finfo (np .float64 )
221
221
return dict (min = np_type (dbl_info .min ), max = np_type (dbl_info .max ),
222
222
nmant = 106 , nexp = 11 , width = width )
223
223
else : # don't recognize the type
224
224
raise FloatingError ('We had not expected this type' )
225
- return dict (min = np_type (info .min ), max = np_type (info .max ), nmant = info .nmant ,
226
- nexp = info .nexp , width = width )
225
+ return ret
227
226
228
227
229
228
def as_int (x , check = True ):
0 commit comments