Given a set of values returns the indices of each of those values
    in the source array.
519835
def search_indices(values, source):
    
    orig_indices = source.argsort()
    return orig_indices[np.searchsorted(source[orig_indices], values)]
1317048
def even_values(array)
      array.values_at(* array.each_index.select {|i| i.even?})
      # array.select_with_index{|item, i| item if i % 2 == 1}
    end
908543
def get_lines(self, key):
        """"""
        if key in self._indices:
            return self._indices[key].values()
        else:
            return []
1353221
protected Object[] getSourceValues() {
		Object[] values = new Object[sourceValueModels.length];
		for (int i = 0; i < values.length; i++) {
			values[i] = sourceValueModels[i].getValue();
		}
		return values;
	}
1304227
public int[] getElementIndices() {
        if (indices != null)
            return indices;
        Integer[] objIndices = indexToValue.keySet().toArray(new Integer[0]);
        indices = new int[objIndices.length];
        for (int i = 0; i < objIndices.length; ++i)
            indices[i] = objIndices[i].intValue();
        // sort the indices
        Arrays.sort(indices);
        return indices;
    }
1128203
function (arr, val) {

            debug('Finding all indices...');
            debug('Array: %o', arr);

            let indexes = [];

            for (let i = 0; i < arr.length; i++) {

                const
                    camelCaseVal = camelCase(val),
                    camelCaseKey = camelCase(arr[i]);

                if (arr[i] === val || camelCaseKey === camelCaseVal) {

                    debug('Matched index: %s', i);

                    indexes.push(i);
                }
            }

            debug('Found indices: %o', indexes);

            return indexes;
        }
486272
def _get_index_list_of_values(d, k, def_value=None):
    """"""
    v = d.get(k, def_value)
    if v is None:
        return []
    if isinstance(v, list):
        return v
    return [v]
619633
def values(self, index):
        
        values = []
        for i in xrange(self.num_instances):
            inst = self.get_instance(i)
            values.append(inst.get_value(index))
        return numpy.array(values)
872903
public long[] toPrimitiveArray(long[] array) {
	for (int i = 0, j = 0; i < array.length; ++i) {
	    int index = -1;
	    if (j < indices.length && (index = indices[j]) == i) {
		array[i] = values[j];
		j++;
	    }
	    else
		array[i] = 0;
	}

	return array;
    }
105208
public static <T> T[] slice(T[] array, int... indexes) {
		int length = indexes.length;
		T[] slice = ObjectArrays.newArray(array, length);
		for (int i = 0; i < length; i++) {
			slice[i] = array[indexes[i]];
		}
		return slice;
	}
576750
def p_array_index(self, p):
        ''''''
        if len(p) == 3:
            p[0] = slice(0, -1, -1)
        elif len(p) == 1 or p[1] == ':':
            p[0] = slice(0, -1, 1)
        else:
            p[0] = slice(0, int(p[1]), 1)
1186492
@Override
    public int[] getIndices() {
        if (used == indices.length)
            return indices;

        int[] tmpIndices = new int[used];
        for (int i = 0; i < used; i++) {
        	tmpIndices[i] = indices[i];
        }
        return tmpIndices;
    }
848759
private void checkIndices(int... indices) {
        if (indices.length != dims.length) {
            throw new IllegalArgumentException(String.format(
                    "Indices array is not the correct length. expected=%d actual=%d", 
                    indices.length, dims.length));
        }
        for (int i=0; i<indices.length; i++) {
            if (indices[i] < 0 || dims[i] <= indices[i]) {
                throw new IllegalArgumentException(String.format(
                        "Indices array contains an index that is out of bounds: i=%d index=%d", 
                        i, indices[i]));
            }
        }
    }
437997
public int getMaxValueIndex(double[] array) {

        int index = 0;
        double max = Integer.MIN_VALUE;

        for (int i = 0; i < array.length; i++) {
            if (array[i] > max) {
                max = array[i];
                index = i;
            }
        }

        return index;
    }
291489
public static INDArrayIndex[] allFor(INDArray arr) {
        INDArrayIndex[] ret = new INDArrayIndex[arr.rank()];
        for (int i = 0; i < ret.length; i++)
            ret[i] = NDArrayIndex.all();

        return ret;
    }
940950
public static int selectIndex( float []data , int k , int maxIndex ,  int []indexes) {

		for( int i = 0; i < maxIndex; i++ ) {
			indexes[i] = i;
		}

		int i,j,mid;
		int n = maxIndex;
		int a;
		int l = 0;
		int ir = n-1;

		int temp;

		for(;;) {
			if( ir <= l+1 ) {
				if( ir == l+1 && data[indexes[ir]] < data[indexes[l]] ) {
					temp = indexes[l];
					indexes[l] = indexes[ir];
					indexes[ir] = temp;
				}
				return indexes[k];
			} else {
				mid = (l+ir) >> 1;

				int lp1 = l+1;
				temp = indexes[mid];
				indexes[mid] = indexes[lp1];
				indexes[lp1] = temp;

				if( data[indexes[l]] > data[indexes[ir]] ) {
					temp = indexes[l];
					indexes[l] = indexes[ir];
					indexes[ir] = temp;
				}

				if( data[indexes[lp1]] > data[indexes[ir]] ) {
					temp = indexes[lp1];
					indexes[lp1] = indexes[ir];
					indexes[ir] = temp;
				}

				if( data[indexes[l]] > data[indexes[lp1]] ) {
					temp = indexes[lp1];
					indexes[lp1] = indexes[l];
					indexes[l] = temp;
				}

				i=lp1;
				j=ir;
				a=indexes[lp1];

				for(;;) {
					do i++; while(data[indexes[i]]<data[a]);
					do j--; while (data[indexes[j]]>data[a]);
					if( j < i) break;
					temp = indexes[i];
					indexes[i] = indexes[j];
					indexes[j] = temp;
				}
				indexes[lp1] = indexes[j];
				indexes[j] = a;
				if( j >= k ) ir=j-1;
				if( j <= k ) l=i;
			}
		}
	}
451941
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.')