Exemplo n.º 1
0
 def const_buffer(self, pytestconfig):
     data = [
         {
             "state": {"state_1": t.zeros([1, 2])},
             "action": {"action_1": t.zeros([1, 3])},
             "next_state": {"next_state_1": t.zeros([1, 4])},
             "reward": 10.0,
             "terminal": True,
             "data_index": i,
             "not_concatenable": (i, "some_str"),
         }
         for i in range(self.SAMPLE_BUFFER_SIZE)
     ]
     buffer = Buffer(
         buffer_size=self.SAMPLE_BUFFER_SIZE,
         buffer_device=pytestconfig.getoption("gpu_device"),
     )
     for d in data:
         buffer.append(d)
     return buffer
Exemplo n.º 2
0
 def test_append(self, trans_list, require_attr, exception, match):
     buffer = Buffer(self.BUFFER_SIZE)
     if exception is not None:
         with pytest.raises(exception, match=match):
             for trans in trans_list:
                 buffer.append(trans, require_attr)
     else:
         for trans in trans_list:
             buffer.append(trans, require_attr)
Exemplo n.º 3
0
 def test_clear(self, trans_list):
     buffer = Buffer(self.BUFFER_SIZE)
     for trans in trans_list:
         buffer.append(trans)
     buffer.clear()
     assert buffer.size() == 0