code: def find_clusters_1d_break_dist(vals, dist_thresh):
      """
      Very simple clusting in 1D: Sort <vals> and calculate distance between values. Form clusters when <dist_thresh> is
      exceeded.
  
      Returns a list of clusters, where each element in the list is a np.array with indices of <vals>.
      """
      if type(vals) is not np.ndarray:
          raise TypeError("vals must be a NumPy array")
  
      if dist_thresh < 0:
          raise ValueError("dist_thresh must be positive")
  
      clusters = []
  
      if len(vals) > 0:
          pos_indices_sorted = np.argsort(
              vals
          )  # indices of sorted values
          gaps = np.diff(
              vals[pos_indices_sorted]
          )  # calculate distance between sorted values
  
          cur_clust = [
              pos_indices_sorted[0]
          ]  # initialize with first index
  
          if len(vals) > 1:
              for idx, gap in zip(pos_indices_sorted[1:], gaps):
                  if gap >= dist_thresh:  # create new cluster
                      clusters.append(np.array(cur_clust))
                      cur_clust = []
                  cur_clust.append(idx)
  
          clusters.append(np.array(cur_clust))
  
      assert len(vals) == sum(map(len, clusters))
  
      return clusters
  
file_path: pdftabextract/pdftabextract/clustering.py
imports: import itertools
  import numpy
  from scipy.stats import chisquare
  from pdftabextract import logger
  from pdftabextract.common import fill_array_a_with_values_from_b, sorted_by_attr, flatten_list, update_text_dict_dim, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL
label_desc: Use image node_id 1 for calling a global function with example usage: find_clusters_1d_break_dist(vals, dist_thresh) and returns: clusters