Commit 5c336178 authored by theos's avatar theos
Browse files

d2o.set_full_data now also supports scalars.

parent 74a9b76c
Pipeline #2202 skipped
...@@ -656,6 +656,8 @@ class _slicing_distributor(distributor): ...@@ -656,6 +656,8 @@ class _slicing_distributor(distributor):
copy=copy) copy=copy)
return temp_d2o.get_local_data(copy=False).astype(self.dtype, return temp_d2o.get_local_data(copy=False).astype(self.dtype,
copy=False) copy=False)
elif np.isscalar(data):
return np.ones(self.local_shape, dtype=self.dtype)*data
else: else:
return data[self.local_start:self.local_end].astype( return data[self.local_start:self.local_end].astype(
self.dtype, self.dtype,
...@@ -1923,6 +1925,9 @@ class _not_distributor(distributor): ...@@ -1923,6 +1925,9 @@ class _not_distributor(distributor):
new_data = data.get_full_data() new_data = data.get_full_data()
elif isinstance(data, np.ndarray): elif isinstance(data, np.ndarray):
new_data = data new_data = data
elif np.isscalar(data):
new_data = np.ones(self.global_shape, dtype=self.dtype)*data
copy = False
else: else:
new_data = np.array(data) new_data = np.array(data)
return new_data.astype(self.dtype, return new_data.astype(self.dtype,
......
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