Commit d66fd65f authored by theos's avatar theos
Browse files

Fixed dtype handling in _slicing_distributor's bincount.

parent 0bba7a71
Pipeline #2067 skipped
......@@ -1424,8 +1424,9 @@ class distributed_data_object(object):
out : numpy.ndarray of ints
The result of binning `self`.
out : numpy.ndarray
The result of binning `self`. The returned dtype is `int` if
no weights were given, and `np.float` otherwise.
......@@ -1515,7 +1516,7 @@ class distributed_data_object(object):
hermitian=False, copy=True, **kwargs):
""" Takes the supplied `data` and distributes it to the nodes.
Essentially this method behaves like `d2o[to_key] = data[from_key]`.
Essentially this method behaves like `d2o[to_key] = data[from_key]`
In order to makes this process efficient, the built-in distributors
do not evaluate the object `d2o[from_key]` explicitly. Instead, the
individual nodes check for the self-affecting part of `to_key`, then
......@@ -1489,10 +1489,17 @@ class _slicing_distributor(distributor):
return global_unique_data
def bincount(self, local_data, local_weights, minlength):
if local_weights is None:
result_dtype =
result_dtype = np.float
local_counts = np.bincount(local_data,
# cast the local_counts to the right dtype while avoiding copying
local_counts = np.array(local_counts, copy=False, dtype=result_dtype)
global_counts = np.empty_like(local_counts)
Supports Markdown
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