Пример #1
0
def test_get_last_ix_for_one_record(tub_path):
    inputs = ['cam/image_array', 'angle', 'throttle']
    types = ['image_array', 'float', 'float']
    t = Tub(tub_path, inputs=inputs, types=types)
    record = create_sample_record()
    t.put_record(record)
    assert t.get_last_ix() == 0
Пример #2
0
def test_tub_put_image(tub_path):
    """ Add an encoded image to the tub """
    inputs = ['user/speed', 'cam/image']
    types = ['float', 'image']
    img = Image.new('RGB', (120, 160))
    t=Tub(path=tub_path, inputs=inputs, types=types)
    t.put_record({'cam/image': img, 'user/speed': 0.2, })
    assert t.get_record(t.get_last_ix())['user/speed'] == 0.2
Пример #3
0
def test_recreating_tub(tub):
    """ Recreating a Tub should restore it to working state """
    assert tub.get_num_records() == 10
    assert tub.current_ix == 10
    assert tub.get_last_ix() == 9
    path = tub.path
    tub = None

    inputs = ['cam/image_array', 'angle', 'throttle']
    types = ['image_array', 'float', 'float']
    t = Tub(path, inputs=inputs, types=types)
    assert t.get_num_records() == 10
    assert t.current_ix == 10
    assert t.get_last_ix() == 9
Пример #4
0
def test_get_last_ix_for_empty_tub(tub_path):
    inputs = ['cam/image_array', 'angle', 'throttle']
    types = ['image_array', 'float', 'float']
    t = Tub(tub_path, inputs=inputs, types=types)
    assert t.get_last_ix() == -1