code: def test_generate_candidates():
      X = np.stack(
          [
              ["entity_{}".format(np.mod(x, 15)) for x in range(50)],
              ["rel_{}".format(np.mod(x, 5)) for x in range(50)],
              ["entity_{}".format(np.mod(x, 20)) for x in range(50)],
          ],
          axis=1,
      )
  
      # Test
      X_candidates = generate_candidates(
          X,
          strategy="random_uniform",
          target_rel="rel_0",
          max_candidates=15,
          consolidate_sides=False,
          seed=1916,
      )
  
      assert X_candidates.shape == (15, 3)
  
      # Test
      X_candidates = generate_candidates(
          X,
          strategy="random_uniform",
          target_rel="rel_1",
          max_candidates=20,
          consolidate_sides=True,
          seed=1916,
      )
  
      assert X_candidates.shape == (20, 3)
      assert X_candidates[0, 0] == "entity_16"
      assert np.all(X_candidates[:, 1] == "rel_1")
  
      # Test that consolidate_sides LHS and RHS is respected
      X_candidates = generate_candidates(
          X,
          strategy="random_uniform",
          target_rel="rel_0",
          max_candidates=20,
          consolidate_sides=False,
          seed=0,
      )
  
      assert np.all(np.isin(X_candidates[:, 0], np.unique(X[:, 0])))
      assert np.all(np.isin(X_candidates[:, 2], np.unique(X[:, 2])))
  
      # Test that consolidate_sides=True LHS and RHS entities are mixed
      X_candidates = generate_candidates(
          X,
          strategy="random_uniform",
          target_rel="rel_0",
          max_candidates=100,
          consolidate_sides=True,
          seed=1,
      )
  
      # Check that any of the head or tail entities from X has been found
      # on the OTHER side of the candidates
      assert np.logical_or(
          np.any(np.isin(X_candidates[:, 2], np.unique(X[:, 0]))),
          np.all(np.isin(X_candidates[:, 0], np.unique(X[:, 2]))),
      )
  
      # Test entity frequency generation
      X_candidates = generate_candidates(
          X,
          strategy="entity_frequency",
          target_rel="rel_0",
          max_candidates=20,
          consolidate_sides=False,
          seed=1,
      )
      assert X_candidates.shape == (20, 3)
  
      X_candidates = generate_candidates(
          X,
          strategy="graph_degree",
          target_rel="rel_0",
          max_candidates=30,
          consolidate_sides=False,
          seed=1,
      )
      assert X_candidates.shape == (30, 3)
  
      X_candidates = generate_candidates(
          X,
          strategy="cluster_coefficient",
          target_rel="rel_0",
          max_candidates=30,
          consolidate_sides=False,
          seed=2,
      )
      assert X_candidates.shape == (30, 3)
  
      X_candidates = generate_candidates(
          X,
          strategy="cluster_triangles",
          target_rel="rel_0",
          max_candidates=50,
          consolidate_sides=False,
          seed=1,
      )
      assert X_candidates.shape == (50, 3)
  
      X_candidates = generate_candidates(
          X,
          strategy="cluster_squares",
          target_rel="rel_0",
          max_candidates=60,
          consolidate_sides=False,
          seed=1,
      )
      assert X_candidates.shape == (60, 3)
  
file_path: AmpliGraph/tests/ampligraph/discovery/test_discovery.py
imports: import numpy
  import pytest
  from sklearn.cluster import DBSCAN
  from ampligraph.discovery.discovery import discover_facts, generate_candidates, _setdiff2d, find_clusters, find_duplicates, query_topn
  from ampligraph.latent_features import ScoringBasedEmbeddingModel
label_desc: Use image node_id 2 for calling a global function with example usage: test_generate_candidates() without return types