Commit 07fc9bc8 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

cleanup

parent 857bb932
...@@ -65,7 +65,6 @@ def get_slice_list(shape, axes): ...@@ -65,7 +65,6 @@ def get_slice_list(shape, axes):
yield slice_list yield slice_list
else: else:
yield [slice(None, None)] yield [slice(None, None)]
return
def cast_axis_to_tuple(axis, length=None): def cast_axis_to_tuple(axis, length=None):
...@@ -152,20 +151,14 @@ def bincount_axis(obj, minlength=None, weights=None, axis=None): ...@@ -152,20 +151,14 @@ def bincount_axis(obj, minlength=None, weights=None, axis=None):
# compute the local bincount results # compute the local bincount results
# -> prepare the local result array # -> prepare the local result array
if weights is None: result_dtype = np.int if weights is None else np.float
result_dtype = np.int
else:
result_dtype = np.float
local_counts = np.empty(flat_shape[:-1] + (length, ), local_counts = np.empty(flat_shape[:-1] + (length, ),
dtype=result_dtype) dtype=result_dtype)
# iterate over all entries in the surviving axes and compute the local # iterate over all entries in the surviving axes and compute the local
# bincounts # bincounts
for slice_list in get_slice_list(flat_shape, for slice_list in get_slice_list(flat_shape,
axes=(len(flat_shape)-1, )): axes=(len(flat_shape)-1, )):
if weights is not None: current_weights = None if weights is None else weights[slice_list]
current_weights = weights[slice_list]
else:
current_weights = None
local_counts[slice_list] = np.bincount( local_counts[slice_list] = np.bincount(
data[slice_list], data[slice_list],
weights=current_weights, weights=current_weights,
......
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