code: def endpts_to_intervals(endpts):
      """
      Returns a list of intervals for categorical colormaps
  
      Accepts a list or tuple of sequentially increasing numbers and returns
      a list representation of the mathematical intervals with these numbers
      as endpoints. For example, [1, 6] returns [[-inf, 1], [1, 6], [6, inf]]
  
      :raises: (PlotlyError) If input is not a list or tuple
      :raises: (PlotlyError) If the input contains a string
      :raises: (PlotlyError) If any number does not increase after the
          previous one in the sequence
      """
      length = len(endpts)
      # Check if endpts is a list or tuple
      if not (
          isinstance(endpts, (tuple)) or isinstance(endpts, (list))
      ):
          raise exceptions.PlotlyError(
              "The intervals_endpts argument must "
              "be a list or tuple of a sequence "
              "of increasing numbers."
          )
      # Check if endpts contains only numbers
      for item in endpts:
          if isinstance(item, str):
              raise exceptions.PlotlyError(
                  "The intervals_endpts argument "
                  "must be a list or tuple of a "
                  "sequence of increasing "
                  "numbers."
              )
      # Check if numbers in endpts are increasing
      for k in range(length - 1):
          if endpts[k] >= endpts[k + 1]:
              raise exceptions.PlotlyError(
                  "The intervals_endpts argument "
                  "must be a list or tuple of a "
                  "sequence of increasing "
                  "numbers."
              )
      else:
          intervals = []
          # add -inf to intervals
          intervals.append([float("-inf"), endpts[0]])
          for k in range(length - 1):
              interval = []
              interval.append(endpts[k])
              interval.append(endpts[k + 1])
              intervals.append(interval)
          # add +inf to intervals
          intervals.append([endpts[length - 1], float("inf")])
          return intervals
  
file_path: plotly.py/packages/python/plotly/plotly/figure_factory/utils.py
imports: from collections.abc import Sequence
  from plotly import exceptions
  from plotly.colors import DEFAULT_PLOTLY_COLORS, PLOTLY_SCALES, color_parser, colorscale_to_colors, colorscale_to_scale, convert_to_RGB_255, find_intermediate_color, hex_to_rgb, label_rgb, n_colors, unconvert_from_RGB_255, unlabel_rgb, validate_colors, validate_colors_dict, validate_colorscale, validate_scale_values
label_desc: Use image node_id 7 for calling a global function with example usage: endpts_to_intervals(endpts) and returns: intervals