code: def locate_key(self, key):
          
  
          left = bisect.bisect_left(self, key)
          right = bisect.bisect_right(self, key)
          diff = right - left
          if diff == 0:
              raise KeyError(key)
          elif diff == 1:
              return left
          else:
              return slice(left, right)
docs: Get index location for the requested key.
  
          Parameters
          ----------
          key : object
              Value to locate.
  
          Returns
          -------
          loc : int or slice
              Location of `key` (will be slice if there are duplicate entries).
  
          Examples
          --------
  
          >>> import allel
          >>> idx = allel.SortedIndex([3, 6, 6, 11])
          >>> idx.locate_key(3)
          0
          >>> idx.locate_key(11)
          3
          >>> idx.locate_key(6)
          slice(1, 3, None)
          >>> try:
          ...     idx.locate_key(2)
          ... except KeyError as e:
          ...     print(e)
          ...
          2