def _indexes ( arr ) : myarr = np . array ( arr ) if myarr . ndim == 1 : return list ( range ( len ( myarr ) ) ) elif myarr . ndim == 2 : return tuple ( itertools . product ( list ( range ( arr . shape [ 0 ] ) ) , list ( range ( arr . shape [ 1 ] ) ) ) ) else : raise NotImplementedError ( 'Only supporting arrays of dimension 1 and 2 as yet.' )
python selecting from different dimensions of an array
Returns the list of all indexes of the given array .
def _indexes(arr):
    """ Returns the list of all indexes of the given array.

    Currently works for one and two-dimensional arrays

    """
    myarr = np.array(arr)
    if myarr.ndim == 1:
        return list(range(len(myarr)))
    elif myarr.ndim == 2:
        return tuple(itertools.product(list(range(arr.shape[0])),
                                       list(range(arr.shape[1]))))
    else:
        raise NotImplementedError('Only supporting arrays of dimension 1 and 2 as yet.')