def test_known_types(): # Test we are correctly compiling parameters for known types for ftype, ma_like in ((np.float16, _float_ma[16]), (np.float32, _float_ma[32]), (np.float64, _float_ma[64])): assert_ma_equal(_discovered_machar(ftype), ma_like) # Suppress warning for broken discovery of double double on PPC with np.errstate(all='ignore'): ld_ma = _discovered_machar(np.longdouble) bytes = np.dtype(np.longdouble).itemsize if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16): # 80-bit extended precision assert_ma_equal(ld_ma, _float_ma[80]) elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16: # IEE 754 128-bit assert_ma_equal(ld_ma, _float_ma[128])
def test_known_types(): # Test we are correctly compiling parameters for known types for ftype, ma_like in ((np.float16, _float16_ma), (np.float32, _float32_ma), (np.float64, _float64_ma)): assert_ma_equal(_discovered_machar(ftype), ma_like) # Suppress warning for broken discovery of double double on PPC with np.errstate(all='ignore'): ld_ma = _discovered_machar(np.longdouble) bytes = np.dtype(np.longdouble).itemsize if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16): # 80-bit extended precision assert_ma_equal(ld_ma, _float80_ma) elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16: # IEE 754 128-bit assert_ma_equal(ld_ma, _float128_ma)
def test_subnormal_warning(): """Test that the subnormal is zero warning is not being raised.""" with np.errstate(all='ignore'): ld_ma = _discovered_machar(np.longdouble) bytes = np.dtype(np.longdouble).itemsize with warnings.catch_warnings(record=True) as w: warnings.simplefilter('always') if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16): # 80-bit extended precision ld_ma.smallest_subnormal assert len(w) == 0 elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16: # IEE 754 128-bit ld_ma.smallest_subnormal assert len(w) == 0 else: # Double double ld_ma.smallest_subnormal # This test may fail on some platforms assert len(w) == 0