Пример #1
0
    def test_valid_episode(self, env_spec: EnvSpec, helpers: Helpers) -> None:
        wrapped_env, specs = helpers.get_wrapped_env(env_spec)
        env_loop_func = helpers.get_env_loop(env_spec)

        env_loop = env_loop_func(
            wrapped_env,
            MockedSystem(specs),
        )

        result = env_loop.run_episode()

        helpers.assert_valid_episode(result)
Пример #2
0
    def test_valid_multiple_episodes(self, env_spec: EnvSpec, helpers: Helpers) -> None:
        wrapped_env, specs = helpers.get_wrapped_env(env_spec)
        env_loop_func = helpers.get_env_loop(env_spec)

        train_loop = env_loop_func(wrapped_env, MockedSystem(specs), label="train_loop")
        eval_loop = env_loop_func(wrapped_env, MockedExecutor(specs), label="eval_loop")

        num_episodes = 10
        num_episodes_per_eval = 2

        for _ in range(num_episodes // num_episodes_per_eval):
            train_loop.run(num_episodes=num_episodes_per_eval)
            eval_loop.run(num_episodes=1)
Пример #3
0
    def test_initialize_env_loop(self, env_spec: EnvSpec, helpers: Helpers) -> None:
        wrapped_env, specs = helpers.get_wrapped_env(env_spec)
        env_loop_func = helpers.get_env_loop(env_spec)

        env_loop = env_loop_func(
            wrapped_env,
            MockedSystem(specs),
        )

        props_which_should_not_be_none = [
            env_loop,
            env_loop._environment,
            env_loop._executor,
            env_loop._counter,
            env_loop._logger,
            env_loop._should_update,
        ]
        assert helpers.verify_all_props_not_none(
            props_which_should_not_be_none
        ), "Failed to initialize env loop."