Пример #1
0
def test_variables_set():
    a = Scalar(1.0)
    b = a
    a.value = 2.0
    assert_(a is b)
    assert_(a.raw is b.raw)

    v = Variables(dict(a=Scalar(1.0), b=Scalar(1.5)))
    v.set({"a": 0.5})
    assert_allclose(v.get("a"), 0.5)
Пример #2
0
def test_types_scalar_comparison():
    a = Scalar(1.0)
    b = Scalar(2.0)

    assert_(a < b)
    assert_(a <= b)
    assert_(a != b)

    b.value = 1.0

    assert_(a == b)
Пример #3
0
def test_types_scalar_listen():
    a = Scalar(1.0)

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

        def __call__(self):
            self.value = 3.0

    l = Listener()
    a.listen(l)
    a.value = 3.0

    assert_(l.value == 3.0)