def test_int16_dtype_is_converted_to_mode_1(self): mode = utils.mode_from_dtype(np.dtype(np.int16)) assert mode == 1
def test_int64_dtype_raises_exception(self): with self.assertRaises(ValueError): utils.mode_from_dtype(np.dtype(np.int64))
def test_float128_dtype_raises_exception(self): # float128 only exists on some platforms if hasattr(np, 'float128'): with self.assertRaises(ValueError): utils.mode_from_dtype(np.dtype(np.float128))
def test_int8_dtype_is_converted_to_mode_0(self): mode = utils.mode_from_dtype(np.dtype(np.int8)) assert mode == 0
def test_structured_dtype_raises_exception(self): with self.assertRaises(ValueError): utils.mode_from_dtype(np.dtype([('f1', np.int32)]))
def test_float32_dtype_is_converted_to_mode_2(self): mode = utils.mode_from_dtype(np.dtype(np.float32)) assert mode == 2
def test_object_dtype_raises_exception(self): with self.assertRaises(ValueError): utils.mode_from_dtype(np.dtype(object))
def test_unicode_dtype_raises_exception(self): with self.assertRaises(ValueError): utils.mode_from_dtype(np.dtype('U1'))
def test_complex128_dtype_raises_exception(self): with self.assertRaises(ValueError): utils.mode_from_dtype(np.dtype(np.complex128))
def test_complex64_dtype_is_converted_to_mode_4(self): mode = utils.mode_from_dtype(np.dtype(np.complex64)) assert mode == 4
def test_float16_dtype_is_converted_to_mode_12(self): mode = utils.mode_from_dtype(np.dtype(np.float16)) assert mode == 12