def test_unknown_dtype(self): with self.assertRaises(TypeError) as context: _ = iadt.increase_itemsize_of_dtype(np.uint64, 2) assert ( "Unable to create a numpy dtype matching" in str(context.exception))
def test_factor_is_1(self): dts = [ np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64, np.float16, np.float32, np.float64 ] for dt in dts: dt = np.dtype(dt) with self.subTest(dtype=dt.name): dt_increased = iadt.increase_itemsize_of_dtype(dt, 1) assert dt_increased.name == dt.name
def test_dtype_as_string(self): dt_names = [ "int8", "int16", "int32", "uint8", "uint16", "uint32", "float16", "float32" ] expecteds = [ np.int16, np.int32, np.int64, np.uint16, np.uint32, np.uint64, np.float32, np.float64 ] for dt_name, expected in zip(dt_names, expecteds): expected = np.dtype(expected) with self.subTest(dtype=dt_name): dt_increased = iadt.increase_itemsize_of_dtype(dt_name, 2) assert dt_increased.name == expected.name
def test_factor_is_2(self): dts = [ np.int8, np.int16, np.int32, np.uint8, np.uint16, np.uint32, np.float16, np.float32 ] expecteds = [ np.int16, np.int32, np.int64, np.uint16, np.uint32, np.uint64, np.float32, np.float64 ] for dt, expected in zip(dts, expecteds): dt = np.dtype(dt) expected = np.dtype(expected) with self.subTest(dtype=dt.name): dt_increased = iadt.increase_itemsize_of_dtype(dt, 2) assert dt_increased.name == expected.name