Calculate index values to properly broadcast index array within data array.

    See usage in interp.
761827
def broadcast_indices(x, minv, ndim, axis):
    
    ret = []
    for dim in range(ndim):
        if dim == axis:
            ret.append(minv)
        else:
            broadcast_slice = [np.newaxis] * ndim
            broadcast_slice[dim] = slice(None)
            dim_inds = np.arange(x.shape[dim])
            ret.append(dim_inds[tuple(broadcast_slice)])
    return tuple(ret)
2461
private function internalDataListUpdateValueIfNeeded(&$data, $index)
    {
        $value = $data[$index];
        if (is_callable($value)) {
            $value = call_user_func($value);
            $data[$index] = $value;
        }
        if (is_object($value)) {
            return $value;
        }
        $value = (object) $value;
        $data[$index] = $value;
        return $value;
    }
853002
public static double[] applyIndices (double[] vector, int[] indices) {
        // Initialize the return array:
        final double[] retval = new double[indices.length];

        // Iterate over indices and populate:
        for (int i = 0; i < retval.length; i++) {
            retval[i] = vector[indices[i]];
        }

        // Done, return the return value:
        return retval;
    }
58238
public static <T> int indexOf(T[] array, Object value) {
		if (null != array) {
			for (int i = 0; i < array.length; i++) {
				if (ObjectUtil.equal(value, array[i])) {
					return i;
				}
			}
		}
		return INDEX_NOT_FOUND;
	}
947173
def _cellValue(self, index):
        
        row = index.row()
        col = index.column()
        if (row < 0 or row >= self.rowCount() or col < 0 or col >= self.columnCount()):
            return None

        # The check above should have returned None if the sliced array is None
        assert self._slicedArray is not None, "Sanity check failed."

        nFields = len(self._fieldNames)

        data = self._slicedArray.data
        if self._separateFieldOrientation == Qt.Horizontal:
            dataValue = data[row, col // nFields][self._fieldNames[col % nFields]]
        elif self._separateFieldOrientation == Qt.Vertical:
            dataValue = data[row // nFields, col][self._fieldNames[row % nFields]]
        else:
            dataValue = data[row, col]

        return dataValue
1228047
def _get_indexers_coords_and_indexes(self, indexers):
        
        from .dataarray import DataArray

        coord_list = []
        indexes = OrderedDict()
        for k, v in indexers.items():
            if isinstance(v, DataArray):
                v_coords = v.coords
                if v.dtype.kind == 'b':
                    if v.ndim != 1:  # we only support 1-d boolean array
                        raise ValueError(
                            '{:d}d-boolean array is used for indexing along '
                            'dimension {!r}, but only 1d boolean arrays are '
                            'supported.'.format(v.ndim, k))
                    # Make sure in case of boolean DataArray, its
                    # coordinate also should be indexed.
                    v_coords = v[v.values.nonzero()[0]].coords

                coord_list.append({d: v_coords[d].variable for d in v.coords})
                indexes.update(v.indexes)

        # we don't need to call align() explicitly or check indexes for
        # alignment, because merge_variables already checks for exact alignment
        # between dimension coordinates
        coords = merge_variables(coord_list)
        assert_coordinate_consistent(self, coords)

        # silently drop the conflicted variables.
        attached_coords = OrderedDict(
            (k, v) for k, v in coords.items() if k not in self._variables
        )
        attached_indexes = OrderedDict(
            (k, v) for k, v in indexes.items() if k not in self._variables
        )
        return attached_coords, attached_indexes
1001203
def _getdata_by_idx(data, idx):
    """"""
    shuffle_data = []

    for k, v in data:
        if (isinstance(v, h5py.Dataset) if h5py else False):
            shuffle_data.append((k, v))
        elif isinstance(v, CSRNDArray):
            shuffle_data.append((k, sparse_array(v.asscipy()[idx], v.context)))
        else:
            shuffle_data.append((k, array(v.asnumpy()[idx], v.context)))

    return shuffle_data
1160849
public double getValueAt( int index ) {

        int row = index / data[0].length;
        int col = index % data[0].length;

        return data[row][col];
    }
1184568
def recursive_index_decode(int_array, max=32767, min=-32768):
    """"""
    out_arr = []
    encoded_ind = 0
    while encoded_ind < len(int_array):
        decoded_val = 0
        while int_array[encoded_ind]==max or int_array[encoded_ind]==min:
            decoded_val += int_array[encoded_ind]
            encoded_ind+=1
            if int_array[encoded_ind]==0:
                break
        decoded_val += int_array[encoded_ind]
        encoded_ind+=1
        out_arr.append(decoded_val)
    return out_arr
933620
function arrayPush$1(array, values) {
  var index = -1,
      length = values.length,
      offset = array.length;

  while (++index < length) {
    array[offset + index] = values[index];
  }
  return array;
}
764525
public void insert( int index , int value ) {
		if( size == data.length ) {
			int temp[] = new int[ size * 2];
			System.arraycopy(data,0,temp,0,index);
			temp[index] = value;
			System.arraycopy(data,index,temp,index+1,size-index);
			this.data = temp;
			size++;
		} else {
			size++;
			for( int i = size-1; i > index; i-- ) {
				data[i] = data[i-1];
			}
			data[index] = value;
		}
	}
397086
public void set(int index, float value)
    {
        if (index < offset + array.length && index >= offset)
        {
            array[index - offset] += value;
        }
        else if (index < offset)
        {  //expand from left
            int gap = offset - index;
            int newSize = gap + array.length;
            float[] newArray = new float[newSize];
            newArray[0] = value;
            for (int i = 0; i < array.length; i++)
            {
                newArray[gap + i] = array[i];
            }
            this.offset = index;
            this.array = newArray;
        }
        else
        {
            int gap = index - (array.length + offset - 1);
            int newSize = array.length + gap;
            float[] newArray = new float[newSize];
            newArray[newSize - 1] = value;
            for (int i = 0; i < array.length; i++)
            {
                newArray[i] = array[i];
            }
            this.array = newArray;
        }
    }
1370768
def index(value, array):
    
    i = array.searchsorted(value)
    if i == len(array): return -1
    else:               return i
1004944
def []= index, data
      if index > @size - 1
        # fill in the gaps
        ((index - @size) + 1).times do
          self.push nil
        end
        @last.data = data
      else
        # replace existing value
        current = @first
        index.times do
          current = current.next
        end
        current.data = data
      end
      self
    end
345899
public static void intIndexesToBooleanArray(int[] arra, boolean[] arrb) {

        for (int i = 0; i < arra.length; i++) {
            if (arra[i] < arrb.length) {
                arrb[arra[i]] = true;
            }
        }
    }
450320
private function _rindex($index, array $values) : int
    {
        if (is_int($index) && $index < 0){
            return count($values) + $index;
        }
        return $index;
    }
533511
def value(self, index):
        ""
        offset = units.offset(self._units[index])
        value_index = (index ^ offset) & units.PRECISION_MASK
        return units.value(self._units[value_index])