import context context.set_path() from mplot.data_structures import CircularList def test_clist_create_empty(): cl = CircularList() assert cl == [] def test_clist_create_from_list(): l = [1, 2, 3] cl = CircularList(l) assert cl == l def test_index_wrap(): cl = CircularList([1, 2, 3]) assert cl[0] == 1 assert cl[1] == 2 assert cl[2] == 3 assert cl[3] == 1 assert cl[1000] == 2 assert cl[-1] == 3 assert cl[-4] == 3 def test_enumerate(): l = [1, 2, 3] cl = CircularList(l) l2 = [0, 0, 0, 0, 0]
def set_path(path): return context.set_path(path)
from context import set_path set_path() from a3c.base_worker import BaseWorker class Worker(BaseWorker): def initialize(self, actions): super().initialize() self.actions = actions def reset(self): env_obs = super().reset() self.actions.reset() return env_obs, 0 def do_actions(self, choice, caller_vars): env_obs = caller_vars["env_obs"] feed_back = self.actions.act(choice, env_obs[0]) while True: act_call, feed = self.actions.action_step(env_obs) env_obs = self.env.step(actions=[act_call]) feed_back += feed if not self.actions.actionq: break return env_obs, feed_back