class_docstr: Test mol graphs.
class_docstr_tok: ["Test","mol","graphs","."]
docstr: Test AggrMol.agglomerate_mols.
docstr_tok: ["Test","AggrMol.agglomerate_mols","."]
code: def test_agglomerate_molecules(self):
      """Test AggrMol.agglomerate_mols."""
      molecules = []
  
      # First example molecule
      # Artificial feature array.
      atom_features = np.array(
          [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
      )
      adj_list = [[1], [0, 2], [1]]
      molecules.append(ConvMol(atom_features, adj_list))
  
      # Second example molecule
      atom_features = np.array(
          [
              [20, 21, 22, 23],
              [24, 25, 26, 27],
              [28, 29, 30, 31],
              [32, 33, 34, 35],
          ]
      )
      adj_list = [[1, 2], [0, 3], [0, 3], [1, 2]]
      molecules.append(ConvMol(atom_features, adj_list))
  
      # Third example molecule
      atom_features = np.array(
          [
              [40, 41, 42, 43],
              [44, 45, 46, 47],
              [48, 49, 50, 51],
              [52, 53, 54, 55],
              [56, 57, 58, 59],
          ]
      )
      adj_list = [[1, 2], [0, 3], [0, 3], [1, 2, 4], [3]]
      molecules.append(ConvMol(atom_features, adj_list))
  
      # Test agglomerate molecule method
      concat_mol = ConvMol.agglomerate_mols(molecules)
  
      assert concat_mol.get_num_atoms() == 12
      assert concat_mol.get_num_molecules() == 3
  
      atom_features = concat_mol.get_atom_features()
      assert np.array_equal(atom_features[0, :], [1, 2, 3, 4])
      assert np.array_equal(atom_features[2, :], [56, 57, 58, 59])
      assert np.array_equal(atom_features[11, :], [52, 53, 54, 55])
      assert np.array_equal(atom_features[4, :], [20, 21, 22, 23])
  
      deg_adj_lists = concat_mol.get_deg_adjacency_lists()
      # No atoms of degree 0
      assert np.array_equal(deg_adj_lists[0], np.zeros([0, 0]))
      # 3 atoms of degree 1
      assert np.array_equal(deg_adj_lists[1], [[3], [3], [11]])
      # 8 atoms of degree 2
      assert np.array_equal(
          deg_adj_lists[2],
          [
              [0, 1],
              [5, 6],
              [4, 7],
              [4, 7],
              [5, 6],
              [9, 10],
              [8, 11],
              [8, 11],
          ],
      )
      # 1 atom of degree 3
      assert np.array_equal(deg_adj_lists[3], [[9, 10, 2]])
      # 0 atoms of degree 4
      assert np.array_equal(deg_adj_lists[4], np.zeros([0, 4]))
      # 0 atoms of degree 5
      assert np.array_equal(deg_adj_lists[5], np.zeros([0, 5]))
  
file_path: deepchem/deepchem/feat/tests/test_mol_graphs.py
imports: import unittest
  import numpy
  from deepchem.feat.mol_graphs import ConvMol
label_desc: Use image node_id 5 for calling the TestMolGraphs obj's underlying member method code with example usage: obj.test_agglomerate_molecules() without return types