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