nodes: 0, module; 1, function_definition; 2, function_name:nearest_unequal_elements; 3, parameters; 4, block; 5, identifier:dts; 6, identifier:dt; 7, expression_statement; 8, if_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, try_statement; 13, if_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, comment:"""
      Find values in ``dts`` closest but not equal to ``dt``.
  
      Returns a pair of (last_before, first_after).
  
      When ``dt`` is less than any element in ``dts``, ``last_before`` is None.
      When ``dt`` is greater any element in ``dts``, ``first_after`` is None.
  
      ``dts`` must be unique and sorted in increasing order.
  
      Parameters
      ----------
      dts : pd.DatetimeIndex
          Dates in which to search.
      dt : pd.Timestamp
          Date for which to find bounds.
      """; 18, not_operator; 19, block; 20, not_operator; 21, block; 22, not_operator; 23, block; 24, assignment; 25, block; 26, except_clause; 27, comparison_operator:dt < sortval; 28, block; 29, elif_clause; 30, else_clause; 31, assignment; 32, assignment; 33, expression_list; 34, attribute; 35, raise_statement; 36, attribute; 37, raise_statement; 38, call; 39, return_statement; 40, identifier:sortpos; 41, call; 42, expression_statement; 43, identifier:IndexError; 44, comment:# dt is greater than any value in the array.; 45, block; 46, identifier:dt; 47, identifier:sortval; 48, expression_statement; 49, expression_statement; 50, comparison_operator:dt == sortval; 51, block; 52, block; 53, identifier:lower_value; 54, conditional_expression:dts[lower_ix] if lower_ix >= 0 else None; 55, identifier:upper_value; 56, conditional_expression:dts[upper_ix] if upper_ix < len(dts) else None; 57, identifier:lower_value; 58, identifier:upper_value; 59, identifier:dts; 60, identifier:is_unique; 61, call; 62, identifier:dts; 63, identifier:is_monotonic_increasing; 64, call; 65, identifier:len; 66, argument_list; 67, expression_list; 68, attribute; 69, argument_list; 70, assignment; 71, return_statement; 72, assignment; 73, assignment; 74, identifier:dt; 75, identifier:sortval; 76, expression_statement; 77, expression_statement; 78, expression_statement; 79, expression_statement; 80, subscript; 81, comparison_operator:lower_ix >= 0; 82, None; 83, subscript; 84, comparison_operator:upper_ix < len(dts); 85, None; 86, identifier:ValueError; 87, argument_list; 88, identifier:ValueError; 89, argument_list; 90, identifier:dts; 91, None; 92, None; 93, identifier:dts; 94, identifier:searchsorted; 95, identifier:dt; 96, keyword_argument; 97, identifier:sortval; 98, subscript; 99, expression_list; 100, identifier:lower_ix; 101, binary_operator:sortpos - 1; 102, identifier:upper_ix; 103, identifier:sortpos; 104, assignment; 105, assignment; 106, assignment; 107, assignment; 108, identifier:dts; 109, identifier:lower_ix; 110, identifier:lower_ix; 111, integer:0; 112, identifier:dts; 113, identifier:upper_ix; 114, identifier:upper_ix; 115, call; 116, string:"dts must be unique"; 117, string:"dts must be sorted in increasing order"; 118, identifier:side; 119, string; 120, identifier:dts; 121, identifier:sortpos; 122, subscript; 123, None; 124, identifier:sortpos; 125, integer:1; 126, identifier:lower_ix; 127, binary_operator:sortpos - 1; 128, identifier:upper_ix; 129, binary_operator:sortpos + 1; 130, identifier:lower_ix; 131, identifier:sortpos; 132, identifier:upper_ix; 133, binary_operator:sortpos + 1; 134, identifier:len; 135, argument_list; 136, string_content:left; 137, identifier:dts; 138, unary_operator; 139, identifier:sortpos; 140, integer:1; 141, identifier:sortpos; 142, integer:1; 143, identifier:sortpos; 144, integer:1; 145, identifier:dts; 146, integer:1
code: def nearest_unequal_elements(dts, dt):
      """
      Find values in ``dts`` closest but not equal to ``dt``.
  
      Returns a pair of (last_before, first_after).
  
      When ``dt`` is less than any element in ``dts``, ``last_before`` is None.
      When ``dt`` is greater any element in ``dts``, ``first_after`` is None.
  
      ``dts`` must be unique and sorted in increasing order.
  
      Parameters
      ----------
      dts : pd.DatetimeIndex
          Dates in which to search.
      dt : pd.Timestamp
          Date for which to find bounds.
      """
      if not dts.is_unique:
          raise ValueError("dts must be unique")
  
      if not dts.is_monotonic_increasing:
          raise ValueError("dts must be sorted in increasing order")
  
      if not len(dts):
          return None, None
  
      sortpos = dts.searchsorted(dt, side='left')
      try:
          sortval = dts[sortpos]
      except IndexError:
          # dt is greater than any value in the array.
          return dts[-1], None
  
      if dt < sortval:
          lower_ix = sortpos - 1
          upper_ix = sortpos
      elif dt == sortval:
          lower_ix = sortpos - 1
          upper_ix = sortpos + 1
      else:
          lower_ix = sortpos
          upper_ix = sortpos + 1
  
      lower_value = dts[lower_ix] if lower_ix >= 0 else None
      upper_value = dts[upper_ix] if upper_ix < len(dts) else None
  
      return lower_value, upper_value