def fancy_ind(inds, shape):
    """
    This simple function gives the index of the flattened array given the 
    indices in an unflattened array.
    
    Parameters
    ----------
    inds : list- or array-like
    List of indices in the unflattened array. 
    For sensical results, must all be less than value at corresponding index in 'shape'.
   
    shape : list- or array-like
    Dimension sizes in the unflattened array.
    """
    ind = 0
    for i in range(len(inds)):
        mult = 1
        for j in range(i+1, len(inds)):
            mult *= shape[j]
        ind += inds[i]*mult
    return ind