Skip to content

dask.array.argmin errors when no axis is supplied #985

@shoyer

Description

@shoyer
In [30]: da.from_array(np.random.randn(2, 3), chunks=(2, 3)).argmin().compute()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-43e4bf57492f> in <module>()
----> 1 da.from_array(np.random.randn(2, 3), chunks=(2, 3)).argmin().compute()

/Users/shoyer/conda/envs/xarray-dev/lib/python3.5/site-packages/dask/array/core.py in argmin(self, axis, split_every)
   1146     def argmin(self, axis=None, split_every=None):
   1147         from .reductions import argmin
-> 1148         return argmin(self, axis=axis, split_every=split_every)
   1149
   1150     @wraps(np.argmax)

/Users/shoyer/conda/envs/xarray-dev/lib/python3.5/site-packages/dask/array/reductions.py in _(a, axis, split_every)
    457     @wraps(argfunc)
    458     def _(a, axis=None, split_every=None):
--> 459         if axis < 0:
    460             axis = a.ndim + axis
    461         return reduction(a, chunk, agg, axis=axis, dtype='i8',

This should probably give a more informative error -- or copy the numpy behavior of flattening the array first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions