コード例 #1
0
def test_get_indices_add():
    x = IndexedBase('x')
    y = IndexedBase('y')
    A = IndexedBase('A')
    i, j, k = Idx('i'), Idx('j'), Idx('k')
    assert get_indices(x[i] + 2*y[i]) == (set([i,]), {})
    assert get_indices(y[i] + 2*A[i, j]*x[j]) == (set([i,]), {})
    assert get_indices(y[i] + 2*(x[i] + A[i, j]*x[j])) == (set([i,]), {})
    assert get_indices(y[i] + x[i]*(A[j, j] + 1)) == (set([i,]), {})
    assert get_indices(y[i] + x[i]*x[j]*(y[j] + A[j, k]*x[k])) == (set([i,]), {})
コード例 #2
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_get_indices_add():
    x = IndexedBase("x")
    y = IndexedBase("y")
    A = IndexedBase("A")
    i, j, k = Idx("i"), Idx("j"), Idx("k")
    assert get_indices(x[i] + 2 * y[i]) == (set([
        i,
    ]), {})
    assert get_indices(y[i] + 2 * A[i, j] * x[j]) == (set([
        i,
    ]), {})
    assert get_indices(y[i] + 2 * (x[i] + A[i, j] * x[j])) == (set([
        i,
    ]), {})
    assert get_indices(y[i] + x[i] * (A[j, j] + 1)) == (set([
        i,
    ]), {})
    assert get_indices(y[i] + x[i] * x[j] * (y[j] + A[j, k] * x[k])) == (set([
        i,
    ]), {})
コード例 #3
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_ufunc_support():
    f = Function("f")
    g = Function("g")
    x = IndexedBase("x")
    y = IndexedBase("y")
    i, j = Idx("i"), Idx("j")
    a = symbols("a")

    assert get_indices(f(x[i])) == (set([i]), {})
    assert get_indices(f(x[i], y[j])) == (set([i, j]), {})
    assert get_indices(f(y[i]) * g(x[i])) == (set(), {})
    assert get_indices(f(a, x[i])) == (set([i]), {})
    assert get_indices(f(a, y[i], x[j]) * g(x[i])) == (set([j]), {})
    assert get_indices(g(f(x[i]))) == (set([i]), {})

    assert get_contraction_structure(f(x[i])) == {None: set([f(x[i])])}
    assert get_contraction_structure(f(y[i]) * g(x[i])) == {
        (i, ): set([f(y[i]) * g(x[i])])
    }
    assert get_contraction_structure(f(y[i]) * g(f(x[i]))) == {
        (i, ): set([f(y[i]) * g(f(x[i]))])
    }
    assert get_contraction_structure(f(x[j], y[i]) * g(x[i])) == {
        (i, ): set([f(x[j], y[i]) * g(x[i])])
    }
コード例 #4
0
def test_ufunc_support():
    f = Function('f')
    g = Function('g')
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j, k = Idx('i'), Idx('j'), Idx('k')
    a = symbols('a')

    assert get_indices(f(x[i])) == (set([i]), {})
    assert get_indices(f(x[i], y[j])) == (set([i, j]), {})
    assert get_indices(f(y[i]) * g(x[i])) == (set(), {})
    assert get_indices(f(a, x[i])) == (set([i]), {})
    assert get_indices(f(a, y[i], x[j]) * g(x[i])) == (set([j]), {})
    assert get_indices(g(f(x[i]))) == (set([i]), {})

    assert get_contraction_structure(f(x[i])) == {None: set([f(x[i])])}
    assert get_contraction_structure(f(y[i]) * g(x[i])) == {
        (i, ): set([f(y[i]) * g(x[i])])
    }
    assert get_contraction_structure(f(y[i]) * g(f(x[i]))) == {
        (i, ): set([f(y[i]) * g(f(x[i]))])
    }
    assert get_contraction_structure(f(x[j], y[i]) * g(x[i])) == {
        (i, ): set([f(x[j], y[i]) * g(x[i])])
    }
コード例 #5
0
ファイル: test_index_methods.py プロジェクト: AALEKH/sympy
def test_get_indices_Pow():
    x = IndexedBase('x')
    y = IndexedBase('y')
    A = IndexedBase('A')
    i, j, k = Idx('i'), Idx('j'), Idx('k')
    assert get_indices(Pow(x[i], y[j])) == (set([i, j]), {})
    assert get_indices(Pow(x[i, k], y[j, k])) == (set([i, j, k]), {})
    assert get_indices(Pow(A[i, k], y[k] + A[k, j]*x[j])) == (set([i, k]), {})
    assert get_indices(Pow(2, x[i])) == get_indices(exp(x[i]))

    # test of a design decision, this may change:
    assert get_indices(Pow(x[i], 2)) == (set([i, ]), {})
コード例 #6
0
def test_get_indices_Pow():
    x = IndexedBase('x')
    y = IndexedBase('y')
    A = IndexedBase('A')
    i, j, k = Idx('i'), Idx('j'), Idx('k')
    assert get_indices(Pow(x[i], y[j])) == (set([i,j]), {})
    assert get_indices(Pow(x[i, k], y[j, k])) == (set([i, j, k]), {})
    assert get_indices(Pow(A[i, k], y[k] + A[k, j]*x[j])) == (set([i, k]), {})
    assert get_indices(Pow(2, x[i])) == get_indices(exp(x[i]))

    # test of a design decision, this may change:
    assert get_indices(Pow(x[i], 2)) == (set([i,]), {})
コード例 #7
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_get_indices_Pow():
    x = IndexedBase("x")
    y = IndexedBase("y")
    A = IndexedBase("A")
    i, j, k = Idx("i"), Idx("j"), Idx("k")
    assert get_indices(Pow(x[i], y[j])) == (set([i, j]), {})
    assert get_indices(Pow(x[i, k], y[j, k])) == (set([i, j, k]), {})
    assert get_indices(Pow(A[i, k], y[k] + A[k, j] * x[j])) == (set([i,
                                                                     k]), {})
    assert get_indices(Pow(2, x[i])) == get_indices(exp(x[i]))

    # test of a design decision, this may change:
    assert get_indices(Pow(x[i], 2)) == (set([
        i,
    ]), {})
コード例 #8
0
ファイル: test_index_methods.py プロジェクト: BDGLunde/sympy
def test_ufunc_support():
    f = Function('f')
    g = Function('g')
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j, k = Idx('i'), Idx('j'), Idx('k')
    a = symbols('a')

    assert get_indices(f(x[i])) == (set([i]), {})
    assert get_indices(f(x[i], y[j])) == (set([i, j]), {})
    assert get_indices(f(y[i])*g(x[i])) == (set(), {})
    assert get_indices(f(a, x[i])) == (set([i]), {})
    assert get_indices(f(a, y[i], x[j])*g(x[i])) == (set([j]), {})
    assert get_indices(g(f(x[i]))) == (set([i]), {})

    assert get_contraction_structure(f(x[i])) == {None: set([f(x[i])])}
    assert get_contraction_structure(f(y[i])*g(x[i])) == {(i,): set([f(y[i])*g(x[i])])}
    assert get_contraction_structure(f(y[i])*g(f(x[i]))) == {(i,): set([f(y[i])*g(f(x[i]))])}
    assert get_contraction_structure(f(x[j], y[i])*g(x[i])) == {(i,): set([f(x[j], y[i])*g(x[i])])}
コード例 #9
0
ファイル: test_index_methods.py プロジェクト: AALEKH/sympy
def test_get_indices_Idx():
    f = Function('f')
    i, j = Idx('i'), Idx('j')
    assert get_indices(f(i)*j) == (set([i, j]), {})
    assert get_indices(f(j, i)) == (set([j, i]), {})
    assert get_indices(f(i)*i) == (set(), {})
コード例 #10
0
ファイル: test_index_methods.py プロジェクト: AALEKH/sympy
def test_trivial_indices():
    x, y = symbols('x y')
    assert get_indices(x) == (set([]), {})
    assert get_indices(x*y) == (set([]), {})
    assert get_indices(x + y) == (set([]), {})
    assert get_indices(x**y) == (set([]), {})
コード例 #11
0
def test_trivial_indices():
    x, y = symbols('x y')
    assert get_indices(x) == (set([]), {})
    assert get_indices(x * y) == (set([]), {})
    assert get_indices(x + y) == (set([]), {})
    assert get_indices(x**y) == (set([]), {})
コード例 #12
0
def test_scalar_broadcast():
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j = Idx('i'), Idx('j')
    assert get_indices(x[i] + y[i, i]) == (set([i]), {})
コード例 #13
0
def test_get_indices_exceptions():
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j = Idx('i'), Idx('j')
    raises(IndexConformanceException, lambda: get_indices(x[i] + y[j]))
コード例 #14
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_get_indices_exceptions():
    x = IndexedBase("x")
    y = IndexedBase("y")
    i, j = Idx("i"), Idx("j")
    raises(IndexConformanceException, lambda: get_indices(x[i] + y[j]))
コード例 #15
0
ファイル: test_index_methods.py プロジェクト: AALEKH/sympy
def test_scalar_broadcast():
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j = Idx('i'), Idx('j')
    assert get_indices(x[i] + y[i, i]) == (set([i]), {})
コード例 #16
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_get_indices_Idx():
    f = Function("f")
    i, j = Idx("i"), Idx("j")
    assert get_indices(f(i) * j) == (set([i, j]), {})
    assert get_indices(f(j, i)) == (set([j, i]), {})
    assert get_indices(f(i) * i) == (set(), {})
コード例 #17
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_get_indices_mul():
    x = IndexedBase("x")
    y = IndexedBase("y")
    i, j = Idx("i"), Idx("j")
    assert get_indices(x[j] * y[i]) == (set([i, j]), {})
    assert get_indices(x[i] * y[j]) == (set([i, j]), {})
コード例 #18
0
def test_get_indices_Indexed():
    x = IndexedBase('x')
    i, j = Idx('i'), Idx('j')
    assert get_indices(x[i, j]) == ({i, j}, {})
    assert get_indices(x[j, i]) == ({j, i}, {})
コード例 #19
0
ファイル: test_index_methods.py プロジェクト: AALEKH/sympy
def test_get_indices_mul():
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j = Idx('i'), Idx('j')
    assert get_indices(x[j]*y[i]) == (set([i, j]), {})
    assert get_indices(x[i]*y[j]) == (set([i, j]), {})
コード例 #20
0
def test_get_indices_Idx():
    f = Function('f')
    i, j = Idx('i'), Idx('j')
    assert get_indices(f(i) * j) == (set([i, j]), {})
    assert get_indices(f(j, i)) == (set([j, i]), {})
    assert get_indices(f(i) * i) == (set(), {})
コード例 #21
0
ファイル: test_index_methods.py プロジェクト: AALEKH/sympy
def test_get_indices_exceptions():
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j = Idx('i'), Idx('j')
    raises(IndexConformanceException, lambda: get_indices(x[i] + y[j]))
コード例 #22
0
def test_get_indices_mul():
    x = IndexedBase('x')
    y = IndexedBase('y')
    i, j = Idx('i'), Idx('j')
    assert get_indices(x[j] * y[i]) == (set([i, j]), {})
    assert get_indices(x[i] * y[j]) == (set([i, j]), {})
コード例 #23
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_get_indices_Indexed():
    x = IndexedBase("x")
    i, j = Idx("i"), Idx("j")
    assert get_indices(x[i, j]) == (set([i, j]), {})
    assert get_indices(x[j, i]) == (set([j, i]), {})
コード例 #24
0
ファイル: test_index_methods.py プロジェクト: msgoff/sympy
def test_scalar_broadcast():
    x = IndexedBase("x")
    y = IndexedBase("y")
    i, j = Idx("i"), Idx("j")
    assert get_indices(x[i] + y[i, i]) == (set([i]), {})
    assert get_indices(x[i] + y[j, j]) == (set([i]), {})