예제 #1
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))
예제 #2
0
def test_not_enough_data_to_fill_batch_size_and_window_truncates_the_batch(memory):
    np.random.seed(7)
    memory.window = 2
    memory.record(*environment_input(1.0))
    memory.record(*environment_input(2.0))
    memory.record(*environment_input(3.0))
    assert len(memory.get_random_batch(3)) == 1
예제 #3
0
def test_is_ready_when_enough_prices_are_recorded_to_fill_the_window(memory):
    memory.window = 2
    assert not memory.ready()
    memory.record(*environment_input(1))
    assert not memory.ready()
    memory.record(*environment_input(2))
    assert memory.ready()
예제 #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))
예제 #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))
예제 #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))
예제 #7
0
def test_return_empty_batch_when_it_is_not_possible_to_provide_future_prices(memory):
    memory.record(*environment_input(1))
    assert memory.get_random_batch(1).empty