Commit a8223de5 authored by Theo Steininger's avatar Theo Steininger

Fixed dtype bug in distribute_data.

parent d5c7bb26
......@@ -317,15 +317,16 @@ class distributor(object):
h5py_dataset_Q = isinstance(data, h5py.Dataset)
if data is None:
return np.empty(self.local_shape, dtype=self.dtype)
result_data = np.empty(self.local_shape, dtype=self.dtype)
elif np.isscalar(data):
return np.ones(self.local_shape, dtype=self.dtype)*data
result_data = np.empty(self.local_shape, dtype=self.dtype)
result_data[:] = data
elif isinstance(data, np.ndarray) or \
isinstance(data, distributed_data_object) or \
h5py_dataset_Q:
data = self.extract_local_data(data)
if data.shape is not self.local_shape:
if data.shape != self.local_shape:
copy = True
if copy:
......@@ -334,12 +335,14 @@ class distributor(object):
else:
result_data = data
return result_data
# fix dtype
result_data = result_data.astype(self.dtype, copy=False)
else:
new_data = np.array(data)
return new_data.astype(self.dtype,
copy=copy).reshape(self.local_shape)
result_data = new_data.astype(self.dtype,
copy=copy).reshape(self.local_shape)
return result_data
def disperse_data(self, data, to_key, data_update, from_key=None,
local_keys=False, copy=True, **kwargs):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment