# Path: disentanglement_lib/visualize/dendrogram.py
# def dendrogram_plot(matrix, output_dir, factor_names):
# def report_merges(z, num_factors):
# def _find(nodes, i):
# def _union(nodes, idx, idy, val, z, cluster_id, size, matrix, n_clusters,
#            idx_found):


from absl.testing import absltest
from absl.testing import parameterized
from disentanglement_lib.visualize import dendrogram
import numpy as np
          {0: 2, 1: 2},  # Both factors are now mapped to the new cluster 2.
          {0: 1, 1: 1, 2: 2},  # Size of the new cluster is added.
          2,  # Our new max cluster id is 2.
          1  # We have had our first cluster merge.
      ),
      (
          # We're now considering the last step. The last code gets merged into
          # the now only cluster. Since cluster 0 and 1 were merged, 0 is the
          # root of cluster 2.
          np.array([0, 0, 1, 1]),  # Nodes in the graph. Smallest node is root.
          0,  # Merge node 0 ...
          2,  # With node 2
          3,  # Threshold value of the considered edge: this is the first edge.
          np.array([[0., 1., 2., 2.]]),  # Current dendrogram matrix.
          {0: 2, 1: 2},  # Dictionary factors of variation to cluster IDs.
          {0: 1, 1: 1, 2: 2},  # Size of each cluster.
          np.array([[1, 2], [3, 4]]),  # Original edge-weight matrix.
          2,  # Max cluster ID we have so far.
          1,  # How many events have been found.
          np.array([[0., 1., 2., 2.]]),  # A code is merged into a cluster.
          {0: 2, 1: 2},  # Both factors are now mapped to the new cluster 2.
          {0: 1, 1: 1, 2: 2},  # Size of the new cluster is added.
          2,  # Our new max cluster id is 2.
          1  # We have had one cluster merge.
      ))
  def test_union(
      self, nodes, idx, idy, val, z, cluster_id, size, matrix, n_clusters,
      idx_found, z_target, cluster_id_target, size_target, n_clusters_target,
      idx_found_target):


# Path: disentanglement_lib/visualize/dendrogram.py
# def dendrogram_plot(matrix, output_dir, factor_names):
# def report_merges(z, num_factors):
# def _find(nodes, i):
# def _union(nodes, idx, idy, val, z, cluster_id, size, matrix, n_clusters,
#            idx_found):


# Path: disentanglement_lib/visualize/dendrogram_test.py
from absl.testing import absltest
from absl.testing import parameterized
from disentanglement_lib.visualize import dendrogram
import numpy as np

          {0: 2, 1: 2},  # Both factors are now mapped to the new cluster 2.
          {0: 1, 1: 1, 2: 2},  # Size of the new cluster is added.
          2,  # Our new max cluster id is 2.
          1  # We have had our first cluster merge.
      ),
      (
          # We're now considering the last step. The last code gets merged into
          # the now only cluster. Since cluster 0 and 1 were merged, 0 is the
          # root of cluster 2.
          np.array([0, 0, 1, 1]),  # Nodes in the graph. Smallest node is root.
          0,  # Merge node 0 ...
          2,  # With node 2
          3,  # Threshold value of the considered edge: this is the first edge.
          np.array([[0., 1., 2., 2.]]),  # Current dendrogram matrix.
          {0: 2, 1: 2},  # Dictionary factors of variation to cluster IDs.
          {0: 1, 1: 1, 2: 2},  # Size of each cluster.
          np.array([[1, 2], [3, 4]]),  # Original edge-weight matrix.
          2,  # Max cluster ID we have so far.
          1,  # How many events have been found.
          np.array([[0., 1., 2., 2.]]),  # A code is merged into a cluster.
          {0: 2, 1: 2},  # Both factors are now mapped to the new cluster 2.
          {0: 1, 1: 1, 2: 2},  # Size of the new cluster is added.
          2,  # Our new max cluster id is 2.
          1  # We have had one cluster merge.
      ))
  def test_union(
      self, nodes, idx, idy, val, z, cluster_id, size, matrix, n_clusters,
      idx_found, z_target, cluster_id_target, size_target, n_clusters_target,
      idx_found_target):


    z, cluster_id, size, n_clusters, idx_found = dendrogram._union(