예제 #1
0
 def test_transform_depth3(self):
     # This is to test loop backs in the breadth-first search
     a = Shell(depth=3)
     a.fit(ALL_DATA)
     expected_results = numpy.array([
         [[0, 0, 0, 0], [0, 3, 0, 0], [0, 3, 0, 0], [0, 3, 0, 0],
          [0, 3, 0, 0]],
         [[0, 0, 0, 1], [0, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0],
          [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0],
          [0, 0, 0, 0]],
         [[2, 2, 0, 0], [1, 1, 1, 1], [2, 2, 0, 0], [2, 1, 1, 0],
          [4, 1, 0, 0], [3, 0, 0, 1], [2, 0, 0, 0], [2, 0, 0, 0],
          [1, 0, 1, 0], [1, 0, 0, 0], [2, 0, 0, 0], [3, 1, 0, 0],
          [2, 1, 2, 1], [3, 0, 0, 1], [3, 1, 1, 0], [3, 0, 0, 2],
          [3, 0, 0, 1], [2, 0, 0, 0], [1, 0, 1, 0], [1, 0, 0, 0],
          [2, 3, 0, 0], [1, 0, 0, 0], [0, 2, 0, 1], [0, 2, 0, 1],
          [0, 2, 0, 1], [4, 0, 1, 0], [4, 0, 0, 1], [3, 0, 1, 1],
          [5, 0, 0, 0], [4, 0, 0, 0], [2, 1, 0, 0], [1, 0, 0, 0],
          [1, 0, 0, 0], [1, 0, 0, 0], [2, 0, 0, 0], [3, 2, 0, 0],
          [2, 1, 2, 1], [4, 0, 0, 0], [2, 2, 1, 0], [3, 0, 0, 0],
          [2, 1, 1, 0], [2, 0, 0, 0], [1, 0, 1, 0], [1, 0, 1, 0],
          [1, 1, 0, 0], [1, 1, 0, 0], [2, 1, 0, 0], [1, 0, 0, 0],
          [1, 0, 0, 0]]
     ])
     self.assertTrue((a.transform(ALL_DATA) == expected_results).all())
예제 #2
0
 def test_transform_depth3(self):
     # This is to test loop backs in the breadth-first search
     a = Shell(depth=3)
     a.fit(ALL_DATA)
     expected_results = numpy.array([
         [[0, 0, 0, 0], [0, 3, 0, 0], [0, 3, 0, 0], [0, 3, 0, 0],
          [0, 3, 0, 0]],
         [[0, 0, 0, 1], [0, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0],
          [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0],
          [0, 0, 0, 0]],
         [[2, 2, 0, 0], [1, 1, 1, 1], [2, 2, 0, 0], [2, 1, 1, 0],
          [4, 1, 0, 0], [3, 0, 0, 1], [2, 0, 0, 0], [2, 0, 0, 0],
          [1, 0, 1, 0], [1, 0, 0, 0], [2, 0, 0, 0], [3, 1, 0, 0],
          [2, 1, 2, 1], [3, 0, 0, 1], [3, 1, 1, 0], [3, 0, 0, 2],
          [3, 0, 0, 1], [2, 0, 0, 0], [1, 0, 1, 0], [1, 0, 0, 0],
          [2, 3, 0, 0], [1, 0, 0, 0], [0, 2, 0, 1], [0, 2, 0, 1],
          [0, 2, 0, 1], [4, 0, 1, 0], [4, 0, 0, 1], [3, 0, 1, 1],
          [5, 0, 0, 0], [4, 0, 0, 0], [2, 1, 0, 0], [1, 0, 0, 0],
          [1, 0, 0, 0], [1, 0, 0, 0], [2, 0, 0, 0], [3, 2, 0, 0],
          [2, 1, 2, 1], [4, 0, 0, 0], [2, 2, 1, 0], [3, 0, 0, 0],
          [2, 1, 1, 0], [2, 0, 0, 0], [1, 0, 1, 0], [1, 0, 1, 0],
          [1, 1, 0, 0], [1, 1, 0, 0], [2, 1, 0, 0], [1, 0, 0, 0],
          [1, 0, 0, 0]]
     ])
     self.assertTrue((a.transform(ALL_DATA) == expected_results).all())
예제 #3
0
 def test_fit_use_coordination(self):
     a = Shell(depth=1, use_coordination=True)
     a.fit(ALL_DATA)
     self.assertEqual(
         a._elements,
         set([
             'H0', 'H1', 'O2', 'C4', 'N1', 'C3', 'C2', 'N2', 'N3', 'C1',
             'O1', 'O0'
         ]))
예제 #4
0
 def test_add_unknown(self):
     a = Shell(add_unknown=True)
     a.fit([METHANE])
     temp = []
     for mol in BASE_SHELL:
         inner = []
         for atom in mol:
             inner.append(atom[:2] + [atom[2] + atom[3]])
         temp.append(inner)
     expected = numpy.array(temp)
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
예제 #5
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_add_unknown(self):
     a = Shell(add_unknown=True)
     a.fit([METHANE])
     temp = []
     for mol in BASE_SHELL:
         inner = []
         for atom in mol:
             inner.append(atom[:2] + [atom[2] + atom[3]])
         temp.append(inner)
     expected = numpy.array(temp)
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
예제 #6
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform_use_coordination(self):
     a = Shell(depth=1, use_coordination=True)
     a.fit([MID])
     expected_results = numpy.array([[[1, 0, 0, 0, 0,
                                       0], [0, 1, 0, 0, 0, 0],
                                      [0, 0, 0, 0, 0,
                                       1], [0, 0, 0, 0, 1, 0],
                                      [0, 0, 0, 0, 0,
                                       1], [0, 0, 0, 0, 0, 1],
                                      [0, 0, 1, 0, 0,
                                       0], [0, 0, 0, 1, 0, 0],
                                      [0, 0, 0, 1, 0, 0]]])
     self.assertTrue((a.transform([MID]) == expected_results).all())
예제 #7
0
 def test_transform_use_coordination(self):
     a = Shell(depth=1, use_coordination=True)
     a.fit([MID])
     expected_results = numpy.array([
         [[1, 0, 0, 0, 0, 0],
          [0, 1, 0, 0, 0, 0],
          [0, 0, 0, 0, 0, 1],
          [0, 0, 0, 0, 1, 0],
          [0, 0, 0, 0, 0, 1],
          [0, 0, 0, 0, 0, 1],
          [0, 0, 1, 0, 0, 0],
          [0, 0, 0, 1, 0, 0],
          [0, 0, 0, 1, 0, 0]]
     ])
     self.assertTrue((a.transform([MID]) == expected_results).all())
예제 #8
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform_depth2(self):
     a = Shell(depth=2)
     a.fit(ALL_DATA)
     expected_results = numpy.array([[[0, 4, 0, 0], [1, 0, 0, 0],
                                      [1, 0, 0, 0], [1, 0, 0, 0],
                                      [1, 0, 0, 0]],
                                     [[1, 0, 0, 0], [1, 0, 0, 1],
                                      [1, 0, 0, 0], [0, 0, 0, 0],
                                      [0, 0, 0, 1], [0, 0, 0, 1],
                                      [0, 0, 0, 0], [0, 1, 0, 0],
                                      [0, 1, 0, 0]],
                                     [[1, 0, 1, 1], [2, 1, 0, 0],
                                      [2, 1, 0, 0], [2, 1, 0, 0],
                                      [2, 0, 1, 0], [2, 0, 0, 0],
                                      [1, 0, 0, 0], [1, 0, 0, 0],
                                      [1, 1, 0, 0], [0, 0, 0, 1],
                                      [1, 0, 0, 0], [1, 0, 1, 1],
                                      [3, 0, 0, 0], [2, 1, 0, 0],
                                      [2, 0, 0, 1], [2, 0, 1, 0],
                                      [2, 0, 0, 0], [1, 0, 0, 0],
                                      [1, 1, 0, 0], [0, 0, 0, 1],
                                      [2, 0, 0, 0], [0, 3, 0, 1],
                                      [1, 0, 0, 0], [1, 0, 0, 0],
                                      [1, 0, 0, 0], [2, 0, 0, 1],
                                      [3, 0, 0, 0], [3, 0, 0, 0],
                                      [2, 0, 0, 1], [2, 0, 0, 0],
                                      [2, 0, 0, 0], [1, 1, 0, 0],
                                      [1, 0, 0, 0], [1, 0, 0, 0],
                                      [1, 0, 1, 0], [1, 0, 2, 0],
                                      [3, 0, 0, 0], [2, 1, 0, 0],
                                      [3, 0, 0, 0], [1, 1, 1, 0],
                                      [2, 0, 0, 0], [1, 0, 0, 0],
                                      [1, 0, 0, 0], [1, 2, 0, 0],
                                      [0, 0, 1, 0], [0, 0, 1, 0],
                                      [2, 0, 0, 0], [1, 1, 0, 0],
                                      [1, 0, 0, 0]]])
     self.assertTrue((a.transform(ALL_DATA) == expected_results).all())
예제 #9
0
 def test_transform_depth2(self):
     a = Shell(depth=2)
     a.fit(ALL_DATA)
     expected_results = numpy.array([
         [[0, 4, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0],
          [1, 0, 0, 0]],
         [[1, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 0],
          [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 0], [0, 1, 0, 0],
          [0, 1, 0, 0]],
         [[1, 0, 1, 1], [2, 1, 0, 0], [2, 1, 0, 0], [2, 1, 0, 0],
          [2, 0, 1, 0], [2, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0],
          [1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [1, 0, 1, 1],
          [3, 0, 0, 0], [2, 1, 0, 0], [2, 0, 0, 1], [2, 0, 1, 0],
          [2, 0, 0, 0], [1, 0, 0, 0], [1, 1, 0, 0], [0, 0, 0, 1],
          [2, 0, 0, 0], [0, 3, 0, 1], [1, 0, 0, 0], [1, 0, 0, 0],
          [1, 0, 0, 0], [2, 0, 0, 1], [3, 0, 0, 0], [3, 0, 0, 0],
          [2, 0, 0, 1], [2, 0, 0, 0], [2, 0, 0, 0], [1, 1, 0, 0],
          [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 1, 0], [1, 0, 2, 0],
          [3, 0, 0, 0], [2, 1, 0, 0], [3, 0, 0, 0], [1, 1, 1, 0],
          [2, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 2, 0, 0],
          [0, 0, 1, 0], [0, 0, 1, 0], [2, 0, 0, 0], [1, 1, 0, 0],
          [1, 0, 0, 0]]
     ])
     self.assertTrue((a.transform(ALL_DATA) == expected_results).all())
예제 #10
0
 def test_small_to_large_transform(self):
     a = Shell()
     a.fit([METHANE])
     expected = numpy.array([numpy.array(x)[:, :2].tolist()
                             for x in BASE_SHELL])
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
예제 #11
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_transform(self):
     a = Shell()
     a.fit(ALL_DATA)
     self.assertTrue((a.transform(ALL_DATA) == BASE_SHELL).all())
예제 #12
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_fit(self):
     a = Shell(depth=1)
     a.fit(ALL_DATA)
     self.assertEqual(a._elements, ('C', 'H', 'N', 'O'))
예제 #13
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_get_labels_unknown(self):
     a = Shell(add_unknown=True)
     a.fit(ALL_DATA)
     expected = ('C', 'H', 'N', 'O', UNKNOWN)
     self.assertEqual(a.get_labels(), expected)
예제 #14
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_get_labels(self):
     a = Shell()
     a.fit(ALL_DATA)
     expected = ('C', 'H', 'N', 'O')
     self.assertEqual(a.get_labels(), expected)
예제 #15
0
 def test_large_to_small_transform(self):
     a = Shell()
     a.fit([BIG])
     self.assertTrue((a.transform(ALL_DATA) == BASE_SHELL).all())
예제 #16
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_large_to_small_transform(self):
     a = Shell()
     a.fit([BIG])
     self.assertTrue((a.transform(ALL_DATA) == BASE_SHELL).all())
예제 #17
0
파일: test_atom.py 프로젝트: zizai/molml
 def test_small_to_large_transform(self):
     a = Shell()
     a.fit([METHANE])
     expected = numpy.array(
         [numpy.array(x)[:, :2].tolist() for x in BASE_SHELL])
     self.assertTrue((a.transform(ALL_DATA) == expected).all())
예제 #18
0
 def test_get_labels(self):
     a = Shell()
     a.fit(ALL_DATA)
     expected = ('C', 'H', 'N', 'O')
     self.assertEqual(a.get_labels(), expected)
예제 #19
0
 def test_transform(self):
     a = Shell()
     a.fit(ALL_DATA)
     self.assertTrue((a.transform(ALL_DATA) == BASE_SHELL).all())
예제 #20
0
 def test_fit_use_coordination(self):
     a = Shell(depth=1, use_coordination=True)
     a.fit(ALL_DATA)
     self.assertEqual(a._elements, ('C1', 'C2', 'C3', 'C4', 'H0', 'H1',
                                    'N1', 'N2', 'N3', 'O0', 'O1', 'O2'))
예제 #21
0
 def test_fit(self):
     a = Shell(depth=1)
     a.fit(ALL_DATA)
     self.assertEqual(a._elements, ('C', 'H', 'N', 'O'))
예제 #22
0
 def test_get_labels_unknown(self):
     a = Shell(add_unknown=True)
     a.fit(ALL_DATA)
     expected = ('C', 'H', 'N', 'O', 'UNKNOWN')
     self.assertEqual(a.get_labels(), expected)