given bounds = (lo,hi) and an index value idx, _posn(bounds, idx)
           returns the position in a 0-based array corresponding to idx in 
           the (lo,hi)-based array.  It generates an error if idx < lo or 
           idx > hi.
434767
def _posn(self, bounds, idx):
        """"""
        lo,hi = bounds[0],bounds[1]
        assert idx >= lo and idx <= hi, \
               f"Array index {idx} out of bounds: {bounds}\n"
   
        return idx-lo
1121149
def PositionalEncoding(x, params, **unused_kwargs):
  """"""
  if not isinstance(x, (list, tuple)):  # non-chunked inputs
    symbol_size = np.shape(x)[1]
    return x + params[:, :symbol_size, :]
  # Chunked case: apply to all chunks selecting as much as needed.
  offset = 0
  results = []
  for chunk in x:
    symbol_size = np.shape(chunk)[1]
    results.append(chunk + params[:, offset:offset + symbol_size, :])
    offset += symbol_size
  return results
654518
function _offsetPos(pos, offset) {
        return {line: pos.line, ch: pos.ch + offset};
    }
624070
def set_x(idx, val)
      check_bounds(idx)
      FFIGeos.GEOSCoordSeq_setX_r(Geos.current_handle_pointer, ptr, idx, val.to_f)
    end
485845
public void putInt(int pos, int i) {
		adaptSize(pos + 4);
		ByteBuffer bb = getBuffer(pos);
		int index = pos % _bufferSize;
		if (bb.limit() - index >= 4) {
			bb.putInt(index, i);
		} else {
			byte b0 = (byte)i;
			byte b1 = (byte)(i >> 8);
			byte b2 = (byte)(i >> 16);
			byte b3 = (byte)(i >> 24);
			
			if (_order == ByteOrder.BIG_ENDIAN) {
				putBytes(pos, b3, b2, b1, b0);
			} else {
				putBytes(pos, b0, b1, b2, b3);
			}
		}
	}
682173
def index_bounds(x):
    """"""
    if isinstance(x, (pd.DataFrame, pd.Series)):
        return x.iloc[0], x.iloc[-1]
    else:
        return x[0], x[-1]
269601
function singleIndexOf(arr, v) {
  var pos = -1;
  var i, l;
  if (!arr) {
    return -1;
  }
  for (i = 0, l = arr.length; i < l; i++) {
    if (arr[i] === v) {
      if (pos >= 0) {
        return -2;
      }
      pos = i;
    }
  }
  return pos;
}
672085
def _compute_bounds(self, axis, view):
        
        is_vertical = self._is_vertical
        pos = self._pos
        if axis == 0 and is_vertical:
            return (pos[0, 0], pos[0, 0])
        elif axis == 1 and not is_vertical:
            return (self._pos[0, 1], self._pos[0, 1])

        return None
909706
def get_point(cls, idx, size):
        
        x, y = cls.POSITION[idx % 4]
        idx //= 4
        block_size = 2
        while block_size < size:
            block_idx = idx % 4
            x, y = cls.get_point_in_block(x, y, block_idx, block_size)
            idx //= 4
            block_size *= 2
        return x, y
325609
public void setPos(int pos) {

        position = pos;

        NodeAVL n = nPrimaryNode;

        while (n != null) {
            ((NodeAVLDisk) n).iData = position;
            n                       = n.nNext;
        }
    }
77661
function _toNaturalIndex (idx, len) {
    idx = _toInteger(idx);

    return idx >= -len && idx < len ? idx < 0 ? idx + len : idx : NaN;
}
924895
function fgetIndex(unit, pos) {
  return pos2index(pos, idlen(unit), unit.linelen) + Number(unit.start);
}
79677
public boolean get(int index) throws ArrayIndexOutOfBoundsException {
        if (index < 0 || index >= length) {
            throw new ArrayIndexOutOfBoundsException(Integer.toString(index));
        }

        return (repn[subscript(index)] & position(index)) != 0;
    }
694
def map_position(pos):
    """"""

    posiction_dict = dict(zip(range(1, 17), [i for i in range(30, 62) if i % 2]))
    return posiction_dict[pos]
350507
function positionAfter (arr, prevChild) {
    var idx
    if (prevChild === null) {
      return 0
    } else {
      idx = findIndex(arr, prevChild)
      return (idx === -1) ? arr.length : idx + 1
    }
  }
1307268
def min_pos(self):
        ''''''
        if self.__len__() == 0:
            return ArgumentError('empty set has no minimum positive value.')
        if self.contains(0):
            return None
        positive = [interval for interval in self.intervals
                    if interval.left > 0]
        if len(positive) == 0:
            return None
        return numpy.min(list(map(lambda i: i.left, positive)))
9068
def _find_bracket_position(self, text, bracket_left, bracket_right,
                               pos_quote):
        
        pos = {}
        pstack = []

        for idx, character in enumerate(text):
            if character == bracket_left and \
                    not self.is_char_in_pairs(idx, pos_quote):
                pstack.append(idx)
            elif character == bracket_right and \
                    not self.is_char_in_pairs(idx, pos_quote):
                if len(pstack) == 0:
                    raise IndexError(
                        "No matching closing parens at: " + str(idx))
                pos[pstack.pop()] = idx

        if len(pstack) > 0:
            raise IndexError(
                "No matching opening parens at: " + str(pstack.pop()))

        return pos