示例#1
0
def test_types_vector_comparison():
    a = Vector([1.0, 2.0])
    b = Vector([1.0, 1.5])

    assert_((a > b)[1])
    assert_((a == b)[0])
    assert_((a != b)[1])

    b.value = asarray([1.0, 2.0])

    assert_(all(a == b))
示例#2
0
def test_types_vector_listen():
    a = Vector([1.0, 2.0])

    class Listener(object):
        def __init__(self):
            self.value = None

        def __call__(self):
            self.value = asarray([3.0, -1.0])

    l = Listener()
    a.listen(l)
    a.value = asarray([3.0, -1.0])
    assert_allclose(l.value, [3.0, -1.0])