コード例 #1
0
 def test_atoms(self):
     """Asserts whether the atom space is correct or not."""
     test_molecule = Mol("C", "ClCC(Cl)(Cl)Cl")
     with self.subTest():
         self.assertEqual(test_molecule.get_atoms(), ["Cl", "C"])
     with self.subTest():
         self.assertEqual(test_molecule.get_atoms(), ["C", "Cl"])
コード例 #2
0
 def test_add_back(self):
     """Tests the functionality of adding an atom to the back of a molecule."""
     test_molecule = Mol()
     test_molecule.set_start_molecule("C")
     test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
     test_molecule.add_atom("", "C")
     self.assertEqual(test_molecule.start, "CC")
コード例 #3
0
 def test_atoms(self):
     """Asserts whether the atom space is correct or not."""
     test_molecule = Mol()
     test_molecule.set_start_molecule("C")
     test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
     atom_set = set(test_molecule.get_atoms())
     self.assertEqual(atom_set, {"Cl", "C"})
コード例 #4
0
def test_action_space():
    """Tests the format of the action space."""
    test_molecule = Mol()
    test_molecule.set_start_molecule("C")
    test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
    env = gym.make("gym_molecule:molecule-v0", mol=test_molecule, goal=100)
    assert env.action_space == spaces.Discrete(6)
コード例 #5
0
def test_init_goal():
    """Tests whether the env correctly sets the goal.
    """
    test_molecule = Mol()
    test_molecule.set_start_molecule("C")
    test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
    env = gym.make("gym_molecule:molecule-v0", mol=test_molecule, goal=100)
    assert env.target_molecule == "ClCC(Cl)(Cl)Cl"
コード例 #6
0
def test_main():
    """Tests that an iteration of the environment-agent interaction is correct."""
    test_molecule = Mol()
    test_molecule.set_start_molecule("C")
    test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
    env = gym.make("gym_molecule:molecule-v0", mol=test_molecule, goal=100)
    agent = MoleculeAgent(env.observation_space, env.action_space)
    state = env.reset()
    reward = 0
    done = False
    action = agent.act(state, reward, done)

    assert env.step(action) == (np.array(env.state), 10, False,
                                env.molecule.modifications)
コード例 #7
0
 def test_validity(self):
     test_molecule = Mol("C", "ClCC(Cl)(Cl)Cl")
     self.assertEqual()
コード例 #8
0
 def test_history(self):
     test_molecule = Mol("C", "ClCC(Cl)(Cl)Cl")
     self.assertEqual()
コード例 #9
0
 def test_remove(self):
     """Tests the functionality of removing an atom from the molecule."""
     test_molecule = Mol("C", "ClCC(Cl)(Cl)Cl")
     self.assertEqual()
コード例 #10
0
 def test_add_back(self):
     """Tests the functionality of adding an atom to the back of a molecule."""
     test_molecule = Mol("C", "ClCC(Cl)(Cl)Cl")
     self.assertEqual()
コード例 #11
0
 def test_bonds(self):
     """Asserts whether the bond space is correct or not."""
     test_molecule = Mol("C", "ClCC(Cl)(Cl)Cl")
     self.assertEqual()
コード例 #12
0
 def test_validity(self):
     test_molecule = Mol()
     test_molecule.set_start_molecule("CX")
     test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
     self.assertEqual(test_molecule.is_valid(test_molecule.start), False)
コード例 #13
0
 def test_bonds(self):
     """Asserts whether the bond space is correct or not."""
     test_molecule = Mol()
     test_molecule.set_start_molecule("C")
     test_molecule.set_target_molecule("ClCC(Cl)(Cl)Cl")
     self.assertEqual(test_molecule.get_bonds(), [1.0])