def test_promote_list_of_two_arrays_dtypes_set(self): arrays = [np.zeros((1,), dtype=np.int8), np.zeros((1,), dtype=np.int16)] observed = iadt.promote_array_dtypes_(arrays, dtypes=[np.float32, np.float64]) assert observed[0].dtype.name == "float64" assert observed[1].dtype.name == "float64"
def test_promote_list_of_two_arrays(self): arrays = [np.zeros((1,), dtype=np.int8), np.zeros((1,), dtype=np.int16)] observed = iadt.promote_array_dtypes_(arrays, increase_itemsize_factor=2) assert observed[0].dtype.name == "int32" assert observed[1].dtype.name == "int32"
def test_calls_subfunctions_dtypes_set(self, mock_cd, mock_gmd): mock_gmd.return_value = np.dtype("int16") mock_cd.return_value = "foo" arrays = [np.zeros((1, ), dtype=np.int8)] observed = iadt.promote_array_dtypes_(arrays, dtypes=["float32"]) assert mock_gmd.call_count == 1 assert mock_cd.call_count == 1 # call 0, args, arg 0, dtype 0 assert mock_gmd.call_args_list[0][0][0][0] == "float32" assert mock_gmd.call_args_list[0][1]["increase_itemsize_factor"] == 1 assert mock_cd.call_args_list[0][0][0] is arrays assert observed == "foo"
def test_promote_single_array_increase_itemsize_factor_set(self): arr = np.zeros((1, ), dtype=np.int8) observed = iadt.promote_array_dtypes_(arr, increase_itemsize_factor=2) assert observed.dtype.name == "int16"
def test_promote_single_array_dtypes_set(self): arr = np.zeros((1, ), dtype=np.int8) observed = iadt.promote_array_dtypes_(arr, [np.int16]) assert observed.dtype.name == "int16"