def test_episode_not_started(self):
     mol = molecules.Molecule({'C', 'O'}, 'c1ccccc1')
     with self.assertRaisesRegexp(ValueError,
                                  'This episode is terminated.'):
         mol.step('Cc1ccccc1')
Example #2
0
 def test_do_not_allow_removal(self):
     mol = molecules.Molecule({'C', 'O'}, 'CC', allow_removal=False)
     mol.initialize()
     self.assertSetEqual(
         mol.get_valid_actions(),
         {'CC', 'CCC', 'C#CC', 'CCO', 'CC=O', 'C=CC', 'C=C', 'C#C'})
 def test_invalid_actions(self):
     mol = molecules.Molecule({'C', 'O'}, 'c1ccccc1')
     mol.initialize()
     with self.assertRaisesRegexp(ValueError, 'Invalid action.'):
         mol.step('C')
Example #4
0
 def test_ethane_init(self):
     mol = molecules.Molecule({'C', 'O'}, 'CC')
     mol.initialize()
     self.assertSetEqual(
         mol.get_valid_actions(),
         {'CC', 'C=C', 'CCC', 'C#CC', 'CCO', 'CC=O', 'C', 'C=CC', 'C#C'})
Example #5
0
 def test_benzene_init(self):
     mol = molecules.Molecule({'C', 'O'}, 'c1ccccc1')
     mol.initialize()
     self.assertSetEqual(mol.get_valid_actions(), {
         'Oc1ccccc1', 'c1ccccc1', 'Cc1ccccc1', 'c1cc2cc-2c1', 'c1cc2ccc1-2'
     })
Example #6
0
 def test_empty_init(self):
     mol = molecules.Molecule({'C', 'O'})
     mol.initialize()
     self.assertSetEqual(mol.get_valid_actions(), {'C', 'O'})
Example #7
0
 def test_more_than_three_possible_bonds(self):
     mol = molecules.Molecule({'C', 'S'})
     mol.initialize()
     mol.step('C')
Example #8
0
 def test_image_generation(self):
     mol = molecules.Molecule({'C', 'O'}, 'c1ccccc1', max_steps=3)
     mol.initialize()
     image = mol.visualize_state()
     del image