code: def test_find_clusters_1d_break_dist(seq, delta):
      with pytest.raises(TypeError):  # first param must be np.array
          find_clusters_1d_break_dist(seq, delta)
  
      arr = np.array(seq)
  
      if delta < 0:
          with pytest.raises(ValueError):  # delta must be >= 0
              find_clusters_1d_break_dist(arr, delta)
          return
  
      clusts = find_clusters_1d_break_dist(arr, delta)
  
      # types and return length must match
      assert type(clusts) is list
      assert sum(map(len, clusts)) == len(seq)
  
      idx_list = []
      for c in clusts:
          idx_list.extend(c)
  
      assert len(idx_list) == len(seq)
      recon = arr[idx_list]
      recon_sorted = np.sort(recon)
      seq_sorted = np.sort(seq)
  
      # values in clusters and in input must match
      assert np.array_equal(recon_sorted, seq_sorted)
  
      if len(seq) > 1:
          clust_borders = []
          for c in clusts:
              v = arr[c]
  
              # inside clusters, the gaps must be < delta
              if len(v) > 1:
                  max_dist_in_clust = max(np.diff(np.sort(v)))
                  assert max_dist_in_clust < delta
  
              v_min = np.min(v)
              v_max = np.max(v)
              clust_borders.append((v_min, v_max))
  
          clust_borders = sorted(clust_borders, key=lambda x: x[0])
  
          if len(clusts) > 1:
              # between the clusters, the gaps must be >= delta
              gaps = []
              prev_max = None
              for v_min, v_max in clust_borders:
                  if prev_max is not None:
                      gaps.append(v_min - prev_max)
                  prev_max = v_max
  
              assert min(gaps) >= delta
  
file_path: pdftabextract/tests/test_clustering.py
imports: import pytest
  from hypothesis import given
  import hypothesis.strategies
  import numpy
  from scipy.stats import chisquare
  from pdftabextract.clustering import find_clusters_1d_break_dist, zip_clusters_and_values, calc_cluster_centers_1d, array_match_difference_1d, find_best_matching_array, adjust_bad_positions
label_desc: Use image node_id 1 for calling a global function with example usage: test_find_clusters_1d_break_dist(seq, delta) without return types