Ejemplo n.º 1
0
 def test_active(self, envs):
     for env_list in envs:
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(env_list)
         subproc_wrapper.reset()
         active = subproc_wrapper.active()
         subproc_wrapper.close()
         assert len(active) == ENV_NUM
Ejemplo n.º 2
0
 def test_seed(self, envs, idx):
     for name, creators in zip(*envs):
         default_logger.info(f"Testing on env {name}")
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(creators)
         seeds = subproc_wrapper.seed()
         subproc_wrapper.close()
         assert len(seeds) == ENV_NUM
Ejemplo n.º 3
0
 def test_active(self, envs):
     for name, creators in zip(*envs):
         default_logger.info(f"Testing on env {name}")
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(creators)
         subproc_wrapper.reset()
         active = subproc_wrapper.active()
         subproc_wrapper.close()
         assert len(active) == ENV_NUM
Ejemplo n.º 4
0
 def test_render(self, envs, idx, render_num):
     for env_list in envs:
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(env_list)
         subproc_wrapper.reset(idx)
         rendered = subproc_wrapper.render(idx)
         subproc_wrapper.close()
         assert len(rendered) == render_num
         assert isinstance(rendered[0], np.ndarray)
         assert rendered[0].ndim == 3 and rendered[0].shape[-1] == 3
Ejemplo n.º 5
0
 def test_render(self, envs, idx, render_num):
     for name, creators in zip(*envs):
         default_logger.info(f"Testing on env {name}")
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(creators)
         subproc_wrapper.reset(idx)
         rendered = subproc_wrapper.render(idx)
         subproc_wrapper.close()
         assert len(rendered) == render_num
         assert isinstance(rendered[0], np.ndarray)
         assert rendered[0].ndim == 3 and rendered[0].shape[-1] == 3
Ejemplo n.º 6
0
    def test_reset(self, envs, idx, reset_num):
        for env_list in envs:
            subproc_wrapper = openai_gym.ParallelWrapperSubProc(env_list)
            obsrvs = subproc_wrapper.reset(idx)
            subproc_wrapper.close()

            assert len(obsrvs) == reset_num
            for obsrv in obsrvs:
                assert subproc_wrapper.observation_space.contains(obsrv), \
                    "Required observation form: {}, Actual observation: {}" \
                    .format(str(subproc_wrapper.observation_space), obsrv)
Ejemplo n.º 7
0
    def test_reset(self, envs, idx, reset_num):
        for name, creators in zip(*envs):
            default_logger.info(f"Testing on env {name}")
            subproc_wrapper = openai_gym.ParallelWrapperSubProc(creators)
            obsrvs = subproc_wrapper.reset(idx)
            subproc_wrapper.close()

            assert len(obsrvs) == reset_num
            for obsrv in obsrvs:
                assert subproc_wrapper.observation_space.contains(
                    obsrv
                ), "Required observation form: {}, Actual observation: {}".format(
                    str(subproc_wrapper.observation_space), obsrv)
Ejemplo n.º 8
0
    def test_step(self, envs, idx, act_num):
        for env_list in envs:
            subproc_wrapper = openai_gym.ParallelWrapperSubProc(env_list)
            action = [mock_action(subproc_wrapper.action_space)
                      for _ in range(act_num)]
            subproc_wrapper.reset(idx)
            obsrvs, reward, terminal, info = subproc_wrapper.step(action, idx)
            subproc_wrapper.close()

            assert len(obsrvs) == act_num
            assert len(reward) == act_num
            assert len(terminal) == act_num
            assert len(info) == act_num and isinstance(info[0], dict)
            for obsrv in obsrvs:
                assert subproc_wrapper.observation_space.contains(obsrv), \
                    "Required observation form: {}, Actual observation: {}" \
                    .format(str(subproc_wrapper.observation_space), obsrv)
Ejemplo n.º 9
0
    def test_step(self, envs, idx, act_num):
        for name, creators in zip(*envs):
            default_logger.info(f"Testing on env {name}")
            subproc_wrapper = openai_gym.ParallelWrapperSubProc(creators)
            action = [
                mock_action(subproc_wrapper.action_space)
                for _ in range(act_num)
            ]
            subproc_wrapper.reset(idx)
            obsrvs, reward, terminal, info = subproc_wrapper.step(action, idx)
            subproc_wrapper.close()

            assert len(obsrvs) == act_num
            assert len(reward) == act_num
            assert len(terminal) == act_num
            assert len(info) == act_num and isinstance(info[0], dict)
            for obsrv in obsrvs:
                assert subproc_wrapper.observation_space.contains(
                    obsrv
                ), "Required observation form: {}, Actual observation: {}".format(
                    str(subproc_wrapper.observation_space), obsrv)
Ejemplo n.º 10
0
 def test_size(self, envs):
     subproc_wrapper = openai_gym.ParallelWrapperSubProc(envs[0])
     assert subproc_wrapper.size() == ENV_NUM
     subproc_wrapper.close()
Ejemplo n.º 11
0
 def test_close(self, envs):
     for env_list in envs:
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(env_list)
         subproc_wrapper.close()
Ejemplo n.º 12
0
 def test_seed(self, envs, idx):
     for env_list in envs:
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(env_list)
         seeds = subproc_wrapper.seed()
         subproc_wrapper.close()
         assert len(seeds) == ENV_NUM
Ejemplo n.º 13
0
 def test_close(self, envs):
     for name, creators in zip(*envs):
         default_logger.info(f"Testing on env {name}")
         subproc_wrapper = openai_gym.ParallelWrapperSubProc(creators)
         subproc_wrapper.close()