Raise TypeError or IndexError if index is not an integer or out of
        range for the number of elements in this array, respectively.
973729
def _assertIndex(self, index):
        
        if type(index) is not int:
            raise TypeError('list indices must be integers')
        if index < 0 or index >= self.nelems:
            raise IndexError('list index out of range')
36699
def level_at_index(self, index):
        
        if not isinstance(index, int):
            self.log_exc(u"Index is not an integer", None, True, TypeError)
        levels = self.levels
        if (index < 0) or (index >= len(levels)):
            self.log_exc(u"The given level index '%d' is not valid" % (index), None, True, ValueError)
        return self.levels[index]
20328
def _check_not_tuple_of_2_elements(obj, obj_name='obj'):
    """"""
    if not isinstance(obj, tuple) or len(obj) != 2:
        raise TypeError('%s must be a tuple of 2 elements.' % obj_name)
201616
def out_of_bounds(self, index):
        
        if type(index) is int:
            return self.int_out_of_bounds(index)

        elif type(index) is slice:
            return self.slice_out_of_bounds(index)

        elif type(index) is tuple:

            local_index = []

            for k, item in enumerate(index):

                if type(item) is slice:
                    temp_index = self.slice_out_of_bounds(item, k)

                elif type(item) is int:
                    temp_index = self.int_out_of_bounds(item, k)
                # FIXME: will fail if item is no int or slice!
                if temp_index is None:
                    return temp_index

                local_index.append(temp_index)

            return tuple(local_index)
838816
def to_python_index(self, length, check_bounds=True, circular=False):
        
        if not self.is_unitless:
            raise ValueError("Index cannot have units: {0!r}".format(self))

        ret = int(self.value)
        if ret != self.value:
            raise ValueError("Index must be an integer: {0!r}".format(ret))

        if ret == 0:
            raise ValueError("Index cannot be zero")

        if check_bounds and not circular and abs(ret) > length:
            raise ValueError("Index {0!r} out of bounds for length {1}".format(ret, length))

        if ret > 0:
            ret -= 1

        if circular:
            ret = ret % length

        return ret
732468
def _check_array_parms(is_array, array_size, value, element_kind,
                       element_name):
    # pylint: disable=unused-argument
    # The array_size argument is unused.
    

    # The following case has been disabled because it cannot happen given
    # how this check function is used:
    # if array_size and is_array is False:
    #     raise ValueError(
    #         _format("The array_size parameter of {0} {1!A} is {2!A} but the "
    #                 "is_array parameter is False.",
    #                 element_kind, element_name, array_size))

    if value is not None:
        value_is_array = isinstance(value, (list, tuple))
        if not is_array and value_is_array:
            raise ValueError(
                _format("The is_array parameter of {0} {1!A} is False but "
                        "value {2!A} is an array.",
                        element_kind, element_name, value))
        if is_array and not value_is_array:
            raise ValueError(
                _format("The is_array parameter of {0} {1!A} is True but "
                        "value {2!A} is not an array.",
                        element_kind, element_name, value))
933329
def ele_index(class_name, index)
      raise 'Index must be >= 1' unless index == 'last()' || (index.is_a?(Integer) && index >= 1)

      elements = tags(class_name)

      if index == 'last()'
        result = elements.last
      else
        # elements array is 0 indexed
        index -= 1
        result = elements[index]
      end

      raise _no_such_element if result.nil?

      result
    end
979010
protected static int containsIndex(int[] is, int i) {
    for(int j = 0; j < is.length; j++) {
      if(i == is[j]) {
        return j;
      }
    }
    return -1;
  }
907647
def _validate_index(self, index):
        """"""
        if isinstance(index, slice):
            if index.step and index.step != 1:
                raise IndexError('Step is not allowed.')
            indexes = (index.start, index.stop)
        else:
            indexes = (index,)
        for index in indexes:
            if index is not None and index < 0:
                raise IndexError('Negative indexes are not allowed.')
381081
function ArrayindexOf(thing) {
  var index = 0;
  var count = this.length;
  while (index < count) {
    if (this[index] === thing) return index
    index = index + 1
  }
  return -1
}
1042522
def index(idx)
      unless (0...length).cover? idx
        raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
      end

      ptr = GirFFI::InOutPointer.new element_type, data_ptr + idx * element_size
      ptr.to_ruby_value
    end
841228
def _validate_indexers(self, key):
        
        for dim, k in zip(self.dims, key):
            if isinstance(k, BASIC_INDEXING_TYPES):
                pass
            else:
                if not isinstance(k, Variable):
                    k = np.asarray(k)
                    if k.ndim > 1:
                        raise IndexError(
                            "Unlabeled multi-dimensional array cannot be "
                            "used for indexing: {}".format(k))
                if k.dtype.kind == 'b':
                    if self.shape[self.get_axis_num(dim)] != len(k):
                        raise IndexError(
                            "Boolean array size {0:d} is used to index array "
                            "with shape {1:s}.".format(len(k),
                                                       str(self.shape)))
                    if k.ndim > 1:
                        raise IndexError("{}-dimensional boolean indexing is "
                                         "not supported. ".format(k.ndim))
                    if getattr(k, 'dims', (dim, )) != (dim, ):
                        raise IndexError(
                            "Boolean indexer should be unlabeled or on the "
                            "same dimension to the indexed array. Indexer is "
                            "on {0:s} but the target dimension is "
                            "{1:s}.".format(str(k.dims), dim))
2622
function (index) {
        assertType(index, Number);

        if (index < 0 || index >= this.slot.size) {
            error(ERROR_ARGUMENT_OUT_OF_RANGE);
        }

        this.slot.size--;
        this.slot.keys.splice(index, 1);
        this.slot.values.splice(index, 1);
        this.slot.keys.length++;
        this.slot.values.length++;
    }
479323
def item(self, index: int) -> Optional[Node]:
        
        if not isinstance(index, int):
            raise TypeError(
                'Indeces must be integer, not {}'.format(type(index)))
        return self.__nodes[index] if 0 <= index < self.length else None
41685
def _check_row_size(self, array):
        

        if not self._row_size:
            self._row_size = len(array)
        elif self._row_size != len(array):
            raise ArraySizeError, "array should contain %d elements" \
                % self._row_size
404949
function isIndex(value, length) {
  var type = typeof value;
  length = length == null ? MAX_SAFE_INTEGER$1 : length;

  return !!length &&
    (type == 'number' ||
      (type != 'symbol' && reIsUint.test(value))) &&
        (value > -1 && value % 1 == 0 && value < length);
}
1080956
def _sumindex(self, index=None):
        """"""
        try:
            ndim = len(index)
        except TypeError:
            # turn index into a 1-tuple
            index = (index,)
            ndim = 1
        if len(self.shape) != ndim:
            raise ValueError("Index to %d-dimensional array %s has too %s dimensions" %
                (len(self.shape), self.name, ["many","few"][len(self.shape) > ndim]))
        sumindex = 0
        for i in range(ndim-1,-1,-1):
            index1 = index[i]
            if index1 < 0 or index1 >= self.shape[i]:
                raise ValueError("Dimension %d index for array %s is out of bounds (value=%d)" %
                    (i+1, self.name, index1))
            sumindex = index1 + sumindex*self.shape[i]
        return sumindex