Skip to content

Commit

Permalink
Fixes for _unravel_index (#65)
Browse files Browse the repository at this point in the history
Handle cases where there are multiple labels selected with some
structure to them.
  • Loading branch information
jakirkham committed Sep 17, 2018
1 parent e3ca96e commit 3dcf9f3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dask_image/ndmeasure/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def _ravel_shape_indices(dimensions, dtype=int, chunks=None):


def _unravel_index_kernel(indices, func_kwargs):
return numpy.stack(numpy.unravel_index(indices, **func_kwargs), axis=1)
nd_indices = numpy.unravel_index(indices, **func_kwargs)
nd_indices = numpy.stack(nd_indices, axis=indices.ndim)
return nd_indices


def _unravel_index(indices, dims, order='C'):
Expand All @@ -85,7 +87,7 @@ def _unravel_index(indices, dims, order='C'):
_unravel_index_kernel,
dtype=numpy.intp,
chunks=indices.chunks + ((len(dims),),),
new_axis=1,
new_axis=indices.ndim,
func_kwargs={"dims": dims, "order": order}
)
else:
Expand Down

0 comments on commit 3dcf9f3

Please sign in to comment.