Ejemplo n.º 1
0
def test_box_space():
    size = 4
    box = bindings.Box(-1, 42, [size])

    # By default the data precision of python list is float. Force double.
    assert box.contains(bindings.Sample(bindings.Vector_d([0, pi, 12, 42]))), \
        "Box object failed to verify if a sample belongs to its space"
    assert not box.contains(bindings.Sample(bindings.Vector_d([0, pi, 12, 43]))), \
        "Box object failed to verify if a sample belongs to its space"
    assert not box.contains(bindings.Sample(bindings.Vector_d([0]))), \
        "Box object failed to verify if a sample belongs to its space"
    assert not box.contains(bindings.Sample(bindings.Vector_d([0, pi, 12, 43, 0]))), \
        "Box object failed to verify if a sample belongs to its space"

    for n in range(50):
        sample = box.sample()
        assert sample.getBuffer_d().size() == size, \
            "Wrong size of the sample extracted from a box space"
        assert isinstance(sample.getBuffer_d()[0], float), \
            "Wrong data type of the sample extracted from the box space"
        assert box.contains(sample), \
            "Sampled data is not contained in the box space object that created it"
Ejemplo n.º 2
0
def test_vectors():
    python_list = [1.0, 2.0, 3.0]
    vector = bindings.Vector_d(python_list)
    for i in range(0, vector.size()-1):
        assert python_list[i] == vector[i], "Vectors do not match"
Ejemplo n.º 3
0
def create_std_vector():
    python_list = [1.0, 2.0, 3.0]
    vector = bindings.Vector_d(python_list)
    return vector