docs: def format_array_flat(array, max_width):
      """Return a formatted string for as many items in the flattened version of
      array that will fit within max_width characters.
      """
      # every item will take up at least two characters, but we always want to
      # print at least first and last items
      max_possibly_relevant = min(max(array.size, 1),
                                  max(int(np.ceil(max_width / 2.)), 2))
      relevant_front_items = format_items(
          first_n_items(array, (max_possibly_relevant + 1) // 2))
      relevant_back_items = format_items(
          last_n_items(array, max_possibly_relevant // 2))
      # interleave relevant front and back items:
      #     [a, b, c] and [y, z] -> [a, z, b, y, c]
      relevant_items = sum(zip_longest(relevant_front_items,
                                       reversed(relevant_back_items)),
                           ())[:max_possibly_relevant]
  
      cum_len = np.cumsum([len(s) + 1 for s in relevant_items]) - 1
      if (array.size > 2) and ((max_possibly_relevant < array.size) or
                               (cum_len > max_width).any()):
          padding = ' ... '
          count = min(array.size,
                      max(np.argmax(cum_len + len(padding) - 1 > max_width), 2))
      else:
          count = array.size
          padding = '' if (count <= 1) else ' '
  
      num_front = (count + 1) // 2
      num_back = count - num_front
      # note that num_back is 0 <--> array.size is 0 or 1
      #                         <--> relevant_back_items is []
      pprint_str = (' '.join(relevant_front_items[:num_front]) +
                    padding +
                    ' '.join(relevant_back_items[-num_back:]))
      return pprint_str