code: def poisson_disc_sample(
      array_radius, pad_radius, candidates=100, d=2, seed=None
  ):
      """Find positions using poisson-disc sampling."""
      # See http://bost.ocks.org/mike/algorithms/
      rng = np.random.default_rng(seed)
      uniform = rng.uniform
      randint = rng.integers
  
      # Cache the results
      key = array_radius, pad_radius, seed
      if key in XY_CACHE:
          return XY_CACHE[key]
  
      # Start at a fixed point we know will work
      start = np.zeros(d)
      samples = [start]
      queue = [start]
  
      while queue:
          # Pick a sample to expand from
          s_idx = randint(len(queue))
          s = queue[s_idx]
  
          for i in range(candidates):
              # Generate a candidate from this sample
              coords = uniform(
                  s - 2 * pad_radius, s + 2 * pad_radius, d
              )
  
              # Check the three conditions to accept the candidate
              in_array = np.sqrt(np.sum(coords**2)) < array_radius
              in_ring = np.all(
                  distance.cdist(samples, [coords]) > pad_radius
              )
  
              if in_array and in_ring:
                  # Accept the candidate
                  samples.append(coords)
                  queue.append(coords)
                  break
  
          if (i + 1) == candidates:
              # We've exhausted the particular sample
              queue.pop(s_idx)
  
      samples = np.array(samples)
      XY_CACHE[key] = samples
      return samples
  
file_path: seaborn/doc/tools/generate_logos.py
imports: import numpy
  import seaborn
  from matplotlib import patches
  import matplotlib.pyplot
  from scipy.signal import gaussian
  from scipy.spatial import distance
label_desc: Use image node_id 1 for calling a global function with example usage: poisson_disc_sample(array_radius, pad_radius, candidates, d, seed) and returns: samples, XY_CACHE