9283f13d67bcee7956ea7d5e9a9ca0a1a08d6c1d,tf_agents/replay_buffers/tf_uniform_replay_buffer_test.py,TFUniformReplayBufferTest,testClear,#TFUniformReplayBufferTest#,117

Before Change


    items_op = replay_buffer.gather_all()
    last_id_op = replay_buffer._get_last_id()

    with self.cached_session() as sess:
      sess.run(tf.global_variables_initializer())
      last_id = sess.run(last_id_op)
      empty_items = sess.run(items_op)
      sess.run(add_op)
      values_ = sess.run(values)
      sample_ = sess.run(sample)
      nest.map_structure(lambda x, y: self._assertContains([x], list(y)),
                         values_, sample_)
      self.assertNotEqual(last_id, sess.run(last_id_op))

      sess.run(clear_op)
      self.assertEqual(last_id, sess.run(last_id_op))

      def check_np_arrays_everything_equal(x, y):
        np.testing.assert_equal(x, y)
        self.assertEqual(x.dtype, y.dtype)

      nest.map_structure(check_np_arrays_everything_equal, empty_items,
                         sess.run(items_op))

  def testClearAllVariables(self):
    batch_size = 1
    spec = self._data_spec()
    replay_buffer = tf_uniform_replay_buffer.TFUniformReplayBuffer(

After Change


    nest.map_structure(lambda x, y: self._assertContains([x], list(y)),
                       values_, sample_)

  def testClear(self):
    batch_size = 1
    spec = self._data_spec()
    replay_buffer = tf_uniform_replay_buffer.TFUniformReplayBuffer(
        spec, batch_size=batch_size, max_length=10)

    values, add_op = _get_add_op(spec, replay_buffer, batch_size)
    sample, _ = replay_buffer.get_next(sample_batch_size=3)
    clear_op = replay_buffer.clear()
    items_op = replay_buffer.gather_all()
    last_id_op = replay_buffer._get_last_id()

    self.evaluate(tf.global_variables_initializer())
    last_id = self.evaluate(last_id_op)
    empty_items = self.evaluate(items_op)
    self.evaluate(add_op)
    values_ = self.evaluate(values)
    sample_ = self.evaluate(sample)
    nest.map_structure(lambda x, y: self._assertContains([x], list(y)),
                       values_, sample_)
    self.assertNotEqual(last_id, self.evaluate(last_id_op))

    self.evaluate(clear_op)
    self.assertEqual(last_id, self.evaluate(last_id_op))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 16

Instances


Project Name: tensorflow/agents
Commit Name: 9283f13d67bcee7956ea7d5e9a9ca0a1a08d6c1d
Time: 2019-02-04
Author: gjn@google.com
File Name: tf_agents/replay_buffers/tf_uniform_replay_buffer_test.py
Class Name: TFUniformReplayBufferTest
Method Name: testClear


Project Name: tensorflow/agents
Commit Name: 9283f13d67bcee7956ea7d5e9a9ca0a1a08d6c1d
Time: 2019-02-04
Author: gjn@google.com
File Name: tf_agents/replay_buffers/tf_uniform_replay_buffer_test.py
Class Name: TFUniformReplayBufferTest
Method Name: testClear


Project Name: tensorflow/agents
Commit Name: 9283f13d67bcee7956ea7d5e9a9ca0a1a08d6c1d
Time: 2019-02-04
Author: gjn@google.com
File Name: tf_agents/replay_buffers/tf_uniform_replay_buffer_test.py
Class Name: TFUniformReplayBufferTest
Method Name: testClearAllVariables


Project Name: tensorflow/agents
Commit Name: 9283f13d67bcee7956ea7d5e9a9ca0a1a08d6c1d
Time: 2019-02-04
Author: gjn@google.com
File Name: tf_agents/replay_buffers/tf_uniform_replay_buffer_test.py
Class Name: TFUniformReplayBufferTest
Method Name: testAddSingleSampleBatch


Project Name: tensorflow/agents
Commit Name: 9283f13d67bcee7956ea7d5e9a9ca0a1a08d6c1d
Time: 2019-02-04
Author: gjn@google.com
File Name: tf_agents/replay_buffers/tf_uniform_replay_buffer_test.py
Class Name: TFUniformReplayBufferTest
Method Name: testAdd