Exemple #1
0
def test_fpm_memory_restores_with_correctly_when_exceeding_capacity(
        save_file, default):
    cfg = default.window(1).size(2).cfg

    m_saved = make_memory(cfg)
    record(m_saved, 3)
    m_saved.save(save_file)
    assert_batch(batch(2.0, 3.0), get_stable_batch(m_saved, 1, 11))

    m_restored = make_memory(cfg)
    m_restored.restore(save_file)
    assert_batch(batch(2.0, 3.0), get_stable_batch(m_restored, 1, 11))
Exemple #2
0
def test_random_batches_preserve_time_series(memory):
    np.random.seed(7)
    memory.record(*environment_input(1.0))
    memory.record(*environment_input(2.0))
    memory.record(*environment_input(3.0))
    memory.record(*environment_input(4.0))
    assert_batch(batch(2.0, 3.0, 4.0), memory.get_random_batch(2))
Exemple #3
0
def test_drop_history_when_memory_capacity_is_reached(memory):
    memory.capacity = 2
    record(memory, 3)
    assert_batch(batch(2.0, 3.0), get_stable_batch(memory, 1, 11))
Exemple #4
0
def test_not_enough_data_to_fill_batch_size_truncates_the_batch(memory):
    np.random.seed(7)
    memory.record(*environment_input(1.0))
    memory.record(*environment_input(2.0))
    assert_batch(batch(1.0, 2.0), memory.get_random_batch(3))
Exemple #5
0
def test_select_randomly_from_history(memory):
    np.random.seed(11)
    memory.record(*environment_input(1.0))
    memory.record(*environment_input(2.0))
    memory.record(*environment_input(3.0))
    assert_batch(batch(1.0, 2.0), memory.get_random_batch(1))
Exemple #6
0
def test_return_trivial_random_batch(memory):
    memory.record(*environment_input(1.0))
    memory.record(*environment_input(2.0))
    assert_batch(batch(1.0, 2.0), memory.get_random_batch(1))