def test_episode_not_started(self): mol = molecules.Molecule({'C', 'O'}, 'c1ccccc1') with self.assertRaisesRegexp(ValueError, 'This episode is terminated.'): mol.step('Cc1ccccc1')
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')
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'})
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' })
def test_empty_init(self): mol = molecules.Molecule({'C', 'O'}) mol.initialize() self.assertSetEqual(mol.get_valid_actions(), {'C', 'O'})
def test_more_than_three_possible_bonds(self): mol = molecules.Molecule({'C', 'S'}) mol.initialize() mol.step('C')
def test_image_generation(self): mol = molecules.Molecule({'C', 'O'}, 'c1ccccc1', max_steps=3) mol.initialize() image = mol.visualize_state() del image