Exemplo n.º 1
0
 def test_to_from_dict(self):
     mc = ModelConfig(gym_env_name=_stepcount_name, fc_layers=10, seed=123)
     mc_dict = mc._to_dict()
     mc2 = ModelConfig._from_dict(mc_dict)
     assert mc2.fc_layers == mc.fc_layers
     assert mc2.original_env_name == mc.original_env_name
     assert mc2.seed == mc.seed
Exemplo n.º 2
0
 def test_agentcontext_train(self):
     b = easyagents.backends.debug.DebugAgentFactory()
     a = b.create_agent(PpoAgent, ModelConfig(_env_name))
     c = AgentContextTest.TrainCallback()
     a.train(callbacks=[Fast(), c], train_context=PpoTrainContext())
     assert c.train_called
     assert c.play_called
Exemplo n.º 3
0
 def test_agentcontext_play(self):
     b = easyagents.backends.debug.DebugAgentFactory()
     a = b.create_agent(PpoAgent, ModelConfig(_env_name))
     c = AgentContextTest.PlayCallback()
     pc = PlayContext()
     pc.num_episodes = 10
     pc.max_steps_per_episode = 10
     a.play(callbacks=[Fast(), c], play_context=pc)
     assert not c.train_called
     assert c.play_called
Exemplo n.º 4
0
 def test_create_fclayersNegativeValue(self):
     with pytest.raises(AssertionError):
         ModelConfig(gym_env_name=_env_name, fc_layers=-10)
Exemplo n.º 5
0
 def test_create_fclayersSimpleInt(self):
     assert ModelConfig(gym_env_name=_env_name, fc_layers=10) is not None
Exemplo n.º 6
0
 def test_create_fclayersEmpty_exception(self):
     with pytest.raises(AssertionError):
         ModelConfig(gym_env_name=_env_name, fc_layers=())
Exemplo n.º 7
0
 def test_create_envNotnameNotSet_exception(self):
     with pytest.raises(AssertionError):
         ModelConfig(gym_env_name=None)
Exemplo n.º 8
0
 def test_create_envNotRegistered_exception(self):
     with pytest.raises(AssertionError):
         ModelConfig(gym_env_name="MyEnv-v0")
Exemplo n.º 9
0
 def test_create(self):
     assert ModelConfig(gym_env_name=_env_name) is not None
     assert ModelConfig(gym_env_name=_env_name,
                        fc_layers=(10, 20)) is not None
Exemplo n.º 10
0
 def test_create_envNotnameNotSet_exception(self):
     with pytest.raises(AssertionError):
         # noinspection PyTypeChecker
         ModelConfig(gym_env_name=None)