def test_value_accumulator_can_be_stored_as_bytes():
    values = [4.2, -1.3, 10.8]
    acc = ValueAccumulator(values)

    data = acc.to_bytes()
    assert isinstance(data, bytes)

    restored_acc = ValueAccumulator.from_bytes(data)
    assert acc == restored_acc
def test_value_accumulator_with_one_value_is_stored_as_single_float64():
    acc = ValueAccumulator()
    acc.add(4.2)

    data = acc.to_bytes()
    assert struct.unpack('d', data)[0] == 4.2

    restored_acc = ValueAccumulator.from_bytes(data)
    assert acc == restored_acc