Esempio n. 1
0
def test_conversion1():
    a = list2numpy([x**2, x])
    # looks like an array?
    assert isinstance(a, numpy.ndarray)
    assert a[0] == x**2
    assert a[1] == x
    assert len(a) == 2
Esempio n. 2
0
def test_conversion2():
    a = 2 * list2numpy([x**2, x])
    b = list2numpy([2 * x**2, 2 * x])
    assert (a == b).all()

    one = Integer(1)
    zero = Integer(0)
    X = list2numpy([one, zero, zero])
    Y = one * X
    X = list2numpy([Symbol("a") + Rational(1, 2)])
    Y = X + X
    assert Y == numpy.array([1 + 2 * Symbol("a")])
    Y = Y + 1
    assert Y == numpy.array([2 + 2 * Symbol("a")])
    Y = X - X
    assert Y == numpy.array([0])
Esempio n. 3
0
def test_list2numpy():
    assert (numpy.array([x**2, x]) == list2numpy([x**2, x])).all()