nodes: 0, module; 1, function_definition; 2, function_name:locate_intersection_ranges; 3, parameters; 4, block; 5, identifier:self; 6, identifier:starts; 7, identifier:stops; 8, expression_statement; 9, comment:# check inputs; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, comment:# find indices of start and stop values in idx; 14, expression_statement; 15, expression_statement; 16, comment:# find intervals overlapping at least one value; 17, expression_statement; 18, comment:# find values within at least one interval; 19, expression_statement; 20, for_statement; 21, return_statement; 22, comment:"""Locate the intersection with a set of ranges.
  
          Parameters
          ----------
          starts : array_like, int
              Range start values.
          stops : array_like, int
              Range stop values.
  
          Returns
          -------
          loc : ndarray, bool
              Boolean array with location of entries found.
          loc_ranges : ndarray, bool
              Boolean array with location of ranges containing one or more
              entries.
  
          Examples
          --------
  
          >>> import allel
          >>> import numpy as np
          >>> idx = allel.SortedIndex([3, 6, 11, 20, 35])
          >>> ranges = np.array([[0, 2], [6, 17], [12, 15], [31, 35],
          ...                    [100, 120]])
          >>> starts = ranges[:, 0]
          >>> stops = ranges[:, 1]
          >>> loc, loc_ranges = idx.locate_intersection_ranges(starts, stops)
          >>> loc
          array([False,  True,  True, False,  True])
          >>> loc_ranges
          array([False,  True, False,  True, False])
          >>> idx[loc]
          <SortedIndex shape=(3,) dtype=int64>
          [6, 11, 35]
          >>> ranges[loc_ranges]
          array([[ 6, 17],
                 [31, 35]])
  
          """; 23, assignment; 24, assignment; 25, call; 26, assignment; 27, assignment; 28, assignment; 29, assignment; 30, pattern_list; 31, call; 32, block; 33, expression_list; 34, identifier:starts; 35, call; 36, identifier:stops; 37, call; 38, identifier:check_dim0_aligned; 39, argument_list; 40, identifier:start_indices; 41, call; 42, identifier:stop_indices; 43, call; 44, identifier:loc_ranges; 45, comparison_operator:start_indices < stop_indices; 46, identifier:loc; 47, call; 48, identifier:i; 49, identifier:j; 50, identifier:zip; 51, argument_list; 52, expression_statement; 53, identifier:loc; 54, identifier:loc_ranges; 55, identifier:asarray_ndim; 56, argument_list; 57, identifier:asarray_ndim; 58, argument_list; 59, identifier:starts; 60, identifier:stops; 61, attribute; 62, argument_list; 63, attribute; 64, argument_list; 65, identifier:start_indices; 66, identifier:stop_indices; 67, attribute; 68, argument_list; 69, subscript; 70, subscript; 71, assignment; 72, identifier:starts; 73, integer:1; 74, identifier:stops; 75, integer:1; 76, identifier:np; 77, identifier:searchsorted; 78, identifier:self; 79, identifier:starts; 80, identifier:np; 81, identifier:searchsorted; 82, identifier:self; 83, identifier:stops; 84, keyword_argument; 85, identifier:np; 86, identifier:zeros; 87, attribute; 88, keyword_argument; 89, identifier:start_indices; 90, identifier:loc_ranges; 91, identifier:stop_indices; 92, identifier:loc_ranges; 93, subscript; 94, True; 95, identifier:side; 96, string; 97, identifier:self; 98, identifier:shape; 99, identifier:dtype; 100, attribute; 101, identifier:loc; 102, slice; 103, string_content:right; 104, identifier:np; 105, identifier:bool; 106, identifier:i; 107, identifier:j
code: def locate_intersection_ranges(self, starts, stops):
          """Locate the intersection with a set of ranges.
  
          Parameters
          ----------
          starts : array_like, int
              Range start values.
          stops : array_like, int
              Range stop values.
  
          Returns
          -------
          loc : ndarray, bool
              Boolean array with location of entries found.
          loc_ranges : ndarray, bool
              Boolean array with location of ranges containing one or more
              entries.
  
          Examples
          --------
  
          >>> import allel
          >>> import numpy as np
          >>> idx = allel.SortedIndex([3, 6, 11, 20, 35])
          >>> ranges = np.array([[0, 2], [6, 17], [12, 15], [31, 35],
          ...                    [100, 120]])
          >>> starts = ranges[:, 0]
          >>> stops = ranges[:, 1]
          >>> loc, loc_ranges = idx.locate_intersection_ranges(starts, stops)
          >>> loc
          array([False,  True,  True, False,  True])
          >>> loc_ranges
          array([False,  True, False,  True, False])
          >>> idx[loc]
          <SortedIndex shape=(3,) dtype=int64>
          [6, 11, 35]
          >>> ranges[loc_ranges]
          array([[ 6, 17],
                 [31, 35]])
  
          """
  
          # check inputs
          starts = asarray_ndim(starts, 1)
          stops = asarray_ndim(stops, 1)
          check_dim0_aligned(starts, stops)
  
          # find indices of start and stop values in idx
          start_indices = np.searchsorted(self, starts)
          stop_indices = np.searchsorted(self, stops, side='right')
  
          # find intervals overlapping at least one value
          loc_ranges = start_indices < stop_indices
  
          # find values within at least one interval
          loc = np.zeros(self.shape, dtype=np.bool)
          for i, j in zip(start_indices[loc_ranges], stop_indices[loc_ranges]):
              loc[i:j] = True
  
          return loc, loc_ranges