diff options
author | Michael Schneeberger <michael.schneeberger@fhnw.ch> | 2023-02-09 10:36:19 +0100 |
---|---|---|
committer | Michael Schneeberger <michael.schneeberger@fhnw.ch> | 2023-02-09 10:36:19 +0100 |
commit | 393d1d7e5d4bb700bcbcbd2fd1fe3005bad17dd1 (patch) | |
tree | c301c32a74e3c5dd21ff262127a1b5667a321c2c /test_polymatrix | |
parent | sympy.expand a sympy expression before converting it to a polymatrix (diff) | |
download | polymatrix-393d1d7e5d4bb700bcbcbd2fd1fe3005bad17dd1.tar.gz polymatrix-393d1d7e5d4bb700bcbcbd2fd1fe3005bad17dd1.zip |
update test cases
Diffstat (limited to 'test_polymatrix')
-rw-r--r-- | test_polymatrix/test_expression/test_derivative.py | 8 | ||||
-rw-r--r-- | test_polymatrix/test_expression/test_divergence.py | 8 | ||||
-rw-r--r-- | test_polymatrix/test_expression/test_linearin.py | 8 | ||||
-rw-r--r-- | test_polymatrix/test_expression/test_quadraticin.py | 7 | ||||
-rw-r--r-- | test_polymatrix/test_expression/test_substitude.py | 8 | ||||
-rw-r--r-- | test_polymatrix/test_expression/test_truncate.py | 8 | ||||
-rw-r--r-- | test_polymatrix/test_tomatrixrepr.py | 10 |
7 files changed, 49 insertions, 8 deletions
diff --git a/test_polymatrix/test_expression/test_derivative.py b/test_polymatrix/test_expression/test_derivative.py index 93c98f4..27dfbeb 100644 --- a/test_polymatrix/test_expression/test_derivative.py +++ b/test_polymatrix/test_expression/test_derivative.py @@ -21,9 +21,15 @@ class TestDerivative(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + (1, 0): {((1, 1),): 1}, + (2, 0): {((2, 1),): 1}, + } + expr = init_derivative_expr( underlying=init_from_terms_expr(terms=underlying_terms, shape=(2, 1)), - variables=(0, 1, 2), + variables=init_from_terms_expr(terms=variable_terms, shape=(3, 1),), ) state = init_expression_state(n_param=3) diff --git a/test_polymatrix/test_expression/test_divergence.py b/test_polymatrix/test_expression/test_divergence.py index ad25577..387a30f 100644 --- a/test_polymatrix/test_expression/test_divergence.py +++ b/test_polymatrix/test_expression/test_divergence.py @@ -24,9 +24,15 @@ class TestDivergence(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + (1, 0): {((1, 1),): 1}, + (2, 0): {((2, 1),): 1}, + } + expr = init_divergence_expr( underlying=init_from_terms_expr(terms=underlying_terms, shape=(3, 1)), - variables=(0, 1, 2), + variables=init_from_terms_expr(terms=variable_terms, shape=(3, 1),), ) state = init_expression_state(n_param=2) diff --git a/test_polymatrix/test_expression/test_linearin.py b/test_polymatrix/test_expression/test_linearin.py index 53d324a..572c34c 100644 --- a/test_polymatrix/test_expression/test_linearin.py +++ b/test_polymatrix/test_expression/test_linearin.py @@ -1,4 +1,5 @@ import unittest +from polymatrix.expression.init.initfromsympyexpr import init_from_sympy_expr from polymatrix.expressionstate.init.initexpressionstate import init_expression_state from polymatrix.expression.init.initfromtermsexpr import init_from_terms_expr @@ -30,10 +31,15 @@ class TestLinearIn(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + (1, 0): {((1, 1),): 1}, + } + expr = init_linear_in_expr( underlying=init_from_terms_expr(terms=underlying_terms, shape=(2, 1)), monomials=init_from_terms_expr(terms=monomial_terms, shape=(4, 1),), - variables=(0, 1), + variables=init_from_terms_expr(terms=variable_terms, shape=(2, 1),), ) state = init_expression_state(n_param=2) diff --git a/test_polymatrix/test_expression/test_quadraticin.py b/test_polymatrix/test_expression/test_quadraticin.py index f25d8be..debf779 100644 --- a/test_polymatrix/test_expression/test_quadraticin.py +++ b/test_polymatrix/test_expression/test_quadraticin.py @@ -30,10 +30,15 @@ class TestQuadraticIn(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + (1, 0): {((1, 1),): 1}, + } + expr = init_quadratic_in_expr( underlying=init_from_terms_expr(terms=underlying_terms, shape=(1, 1)), monomials=init_from_terms_expr(terms=monomial_terms, shape=(3, 1)), - variables=(0, 1), + variables=init_from_terms_expr(terms=variable_terms, shape=(2, 1),), ) state = init_expression_state(n_param=2) diff --git a/test_polymatrix/test_expression/test_substitude.py b/test_polymatrix/test_expression/test_substitude.py index 21a8ab5..457d35e 100644 --- a/test_polymatrix/test_expression/test_substitude.py +++ b/test_polymatrix/test_expression/test_substitude.py @@ -24,10 +24,14 @@ class TestEval(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + } + expr = init_substitute_expr( underlying=init_from_terms_expr(terms=terms, shape=(1, 1)), - variables=(0,), - substitutions=(init_from_terms_expr(terms=substitution, shape=(1, 1)),), + variables=init_from_terms_expr(terms=variable_terms, shape=(1, 1),), + values=(init_from_terms_expr(terms=substitution, shape=(1, 1)),), ) state = init_expression_state(n_param=2) diff --git a/test_polymatrix/test_expression/test_truncate.py b/test_polymatrix/test_expression/test_truncate.py index 910bd37..d6cafbe 100644 --- a/test_polymatrix/test_expression/test_truncate.py +++ b/test_polymatrix/test_expression/test_truncate.py @@ -24,9 +24,15 @@ class TestTruncate(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + (1, 0): {((1, 1),): 1}, + } + + expr = init_truncate_expr( underlying=init_from_terms_expr(terms=terms, shape=(2, 2)), - variables=(0, 1), + variables=init_from_terms_expr(terms=variable_terms, shape=(2, 1),), degrees=(1, 2), ) diff --git a/test_polymatrix/test_tomatrixrepr.py b/test_polymatrix/test_tomatrixrepr.py index 1af25dd..88a35f2 100644 --- a/test_polymatrix/test_tomatrixrepr.py +++ b/test_polymatrix/test_tomatrixrepr.py @@ -24,10 +24,18 @@ class TestToMatrixRepr(unittest.TestCase): }, } + variable_terms = { + (0, 0): {((0, 1),): 1}, + (1, 0): {((1, 1),): 1}, + } + expr = init_from_terms_expr(terms=underlying_terms, shape=(3, 1)) state = init_expression_state(n_param=2) - state, result = polymatrix.to_matrix_repr((expr,), (0, 1)).apply(state) + state, result = polymatrix.to_matrix_repr( + (expr,), + init_from_terms_expr(terms=variable_terms, shape=(2, 1),), + ).apply(state) A0 = result.data[0][0] A1 = result.data[0][1] |