diff options
Diffstat (limited to 'test_polymatrix')
18 files changed, 0 insertions, 828 deletions
diff --git a/test_polymatrix/__init__.py b/test_polymatrix/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/test_polymatrix/__init__.py +++ /dev/null diff --git a/test_polymatrix/test_expression/__init__.py b/test_polymatrix/test_expression/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/test_polymatrix/test_expression/__init__.py +++ /dev/null diff --git a/test_polymatrix/test_expression/test_addition.py b/test_polymatrix/test_expression/test_addition.py deleted file mode 100644 index e3e7f05..0000000 --- a/test_polymatrix/test_expression/test_addition.py +++ /dev/null @@ -1,63 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestAddition(unittest.TestCase): - - def test_1(self): - left_terms = { - (0, 0): { - tuple(): 1.0, - ((0, 1),): 1.0, - }, - (1, 0): { - ((0, 2),): 1.0, - }, - } - - right_terms = { - (0, 0): { - tuple(): 3.0, - ((1, 1),): 2.0, - }, - (1, 1): { - tuple(): 1.0, - }, - } - - left = polymatrix.expression.initexpressionbase.init_from_terms_expr( - terms=left_terms, - shape=(2, 2), - ) - - right = polymatrix.expression.initexpressionbase.init_from_terms_expr( - terms=right_terms, - shape=(2, 2), - ) - - expr = polymatrix.expression.initexpressionbase.init_addition_expr( - left=left, - right=right, - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictContainsSubset({ - tuple(): 4.0, - ((0, 1),): 1.0, - ((1, 1),): 2.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictContainsSubset({ - ((0, 2),): 1.0, - }, data) - - data = val.get_poly(1, 1) - self.assertDictContainsSubset({ - tuple(): 1.0, - }, data) diff --git a/test_polymatrix/test_expression/test_blockdiag.py b/test_polymatrix/test_expression/test_blockdiag.py deleted file mode 100644 index 4a67c77..0000000 --- a/test_polymatrix/test_expression/test_blockdiag.py +++ /dev/null @@ -1,57 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestBlockDiag(unittest.TestCase): - - def test_1(self): - terms1 = { - (0, 0): { - ((1, 1),): 1.0, - }, - (1, 0): { - tuple(): 2.0, - }, - } - - terms2 = { - (0, 0): { - tuple(): 3.0, - }, - (1, 1): { - tuple(): 4.0, - }, - } - - expr = polymatrix.expression.initexpressionbase.init_block_diag_expr( - underlying=( - polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms1, shape=(2, 2),), - polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms2, shape=(2, 2),), - ), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - ((1, 1),): 1.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual({ - tuple(): 2.0, - }, data) - - data = val.get_poly(2, 2) - self.assertDictEqual({ - tuple(): 3.0, - }, data) - - data = val.get_poly(3, 3) - self.assertDictEqual({ - tuple(): 4.0, - }, data) - diff --git a/test_polymatrix/test_expression/test_derivative.py b/test_polymatrix/test_expression/test_derivative.py deleted file mode 100644 index e8f551b..0000000 --- a/test_polymatrix/test_expression/test_derivative.py +++ /dev/null @@ -1,55 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestDerivative(unittest.TestCase): - - def test_1(self): - underlying_terms = { - (0, 0): { - ((0, 1),): 2.0, - ((1, 2),): 3.0, - }, - (1, 0): { - tuple(): 5.0, - ((0, 1), (2, 3)): 4.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - (1, 0): {((1, 1),): 1}, - (2, 0): {((2, 1),): 1}, - } - - expr = polymatrix.expression.initexpressionbase.init_derivative_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=underlying_terms, shape=(2, 1)), - variables=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(3, 1),), - ) - - state = init_expression_state(n_param=3) - state, val = expr.apply(state) - - self.assertTupleEqual(val.shape, (2, 3)) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 2.0, - }, data) - - data = val.get_poly(0, 1) - self.assertDictEqual({ - ((1, 1),): 6.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual({ - ((2, 3),): 4.0, - }, data) - - data = val.get_poly(1, 2) - self.assertDictEqual({ - ((0, 1), (2, 2)): 12.0, - }, data) diff --git a/test_polymatrix/test_expression/test_divergence.py b/test_polymatrix/test_expression/test_divergence.py deleted file mode 100644 index 2d2b6ad..0000000 --- a/test_polymatrix/test_expression/test_divergence.py +++ /dev/null @@ -1,43 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestDivergence(unittest.TestCase): - - def test_1(self): - underlying_terms = { - (0, 0): { - ((0, 1),): 2.0, - ((1, 1),): 3.0, - }, - (1, 0): { - tuple(): 5.0, - ((0, 1),): 3.0, - }, - (2, 0): { - ((0, 1),): 2.0, - ((1, 1), (2, 3)): 3.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - (1, 0): {((1, 1),): 1}, - (2, 0): {((2, 1),): 1}, - } - - expr = polymatrix.expression.initexpressionbase.init_divergence_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=underlying_terms, shape=(3, 1)), - variables=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(3, 1),), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 2.0, - ((1, 1), (2, 2)): 9.0, - }, data) diff --git a/test_polymatrix/test_expression/test_eval.py b/test_polymatrix/test_expression/test_eval.py deleted file mode 100644 index 5787f2a..0000000 --- a/test_polymatrix/test_expression/test_eval.py +++ /dev/null @@ -1,40 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestEval(unittest.TestCase): - - def test_1(self): - terms = { - (0, 0): { - ((0, 1), (2, 1)): 2.0, - ((0, 1), (1, 1), (3, 1)): 3.0, - }, (1, 0):{ - tuple(): 1.0, - ((1, 2),): 1.0, - ((2, 1),): 1.0, - }, - } - - expr = polymatrix.expression.initexpressionbase.init_eval_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms, shape=(2, 1)), - variables=(0, 1), - values=(2.0, 3.0), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - ((2, 1),): 4.0, - ((3, 1),): 18.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual({ - tuple(): 10.0, - ((2, 1),): 1, - }, data) diff --git a/test_polymatrix/test_expression/test_linearin.py b/test_polymatrix/test_expression/test_linearin.py deleted file mode 100644 index d0fb0d9..0000000 --- a/test_polymatrix/test_expression/test_linearin.py +++ /dev/null @@ -1,55 +0,0 @@ -import unittest -from polymatrix.expression.initexpressionbase import init_from_ - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestLinearIn(unittest.TestCase): - - def test_1(self): - underlying_terms = { - (0, 0): { - ((0, 1),): 2.0, - ((1, 1),): 3.0, - }, - } - - monomial_terms = { - (0, 0): { - ((0, 1),): 1.0, - }, - (1, 0): { - ((2, 1),): 1.0, - }, - (2, 0): { - ((1, 1),): 1.0, - }, - (3, 0): { - ((3, 1),): 1.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - (1, 0): {((1, 1),): 1}, - } - - expr = polymatrix.expression.initexpressionbase.init_linear_in_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=underlying_terms, shape=(2, 1)), - monomials=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=monomial_terms, shape=(4, 1),), - variables=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(2, 1),), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 2.0, - }, data) - - data = val.get_poly(0, 2) - self.assertDictEqual({ - tuple(): 3.0, - }, data) diff --git a/test_polymatrix/test_expression/test_matrixmult.py b/test_polymatrix/test_expression/test_matrixmult.py deleted file mode 100644 index b15f7eb..0000000 --- a/test_polymatrix/test_expression/test_matrixmult.py +++ /dev/null @@ -1,62 +0,0 @@ -import unittest -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state - -import polymatrix.expression.initexpressionbase - - -class TestMatrixMult(unittest.TestCase): - - def test_1(self): - left_terms = { - (0, 0): { - tuple(): 1.0, - ((0, 1),): 1.0, - }, - (0, 1): { - ((0, 1),): 1.0, - }, - (1, 1): { - ((0, 2),): 1.0, - }, - } - - right_terms = { - (0, 0): { - tuple(): 3.0, - ((1, 1),): 2.0, - }, - (1, 0): { - tuple(): 1.0, - }, - } - - left = polymatrix.expression.initexpressionbase.init_from_terms_expr( - terms=left_terms, - shape=(2, 2), - ) - - right = polymatrix.expression.initexpressionbase.init_from_terms_expr( - terms=right_terms, - shape=(2, 1), - ) - - expr = polymatrix.expression.initexpressionbase.init_matrix_mult_expr( - left=left, - right=right, - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 3.0, - ((0, 1),): 4.0, - ((1, 1),): 2.0, - ((0, 1), (1, 1),): 2.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual({ - ((0, 2),): 1.0, - }, data) diff --git a/test_polymatrix/test_expression/test_quadraticin.py b/test_polymatrix/test_expression/test_quadraticin.py deleted file mode 100644 index 7f3767d..0000000 --- a/test_polymatrix/test_expression/test_quadraticin.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestQuadraticIn(unittest.TestCase): - - def test_1(self): - underlying_terms = { - (0, 0): { - ((0, 1),): 1.0, # x1 - ((0, 1), (2, 1)): 2.0, # x1 - ((0, 2), (3, 1)): 3.0, # x1 x1 - ((0, 2), (1, 2), (4, 1)): 4.0, # x1 x1 x2 x2 - ((0, 2), (1, 1), (5, 1)): 5.0, # x1 x1 x2 - } - } - - monomial_terms = { - (0, 0): { - tuple(): 1.0, - }, - (1, 0): { - ((0, 1),): 1.0, - }, - (2, 0): { - ((0, 1), (1, 1)): 1.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - (1, 0): {((1, 1),): 1}, - } - - expr = polymatrix.expression.initexpressionbase.init_quadratic_in_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=underlying_terms, shape=(1, 1)), - monomials=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=monomial_terms, shape=(3, 1)), - variables=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(2, 1),), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 1) - self.assertDictContainsSubset({ - tuple(): 1.0, - ((2, 1),): 2.0, - }, data) - - data = val.get_poly(1, 1) - self.assertDictContainsSubset({ - ((3, 1),): 3.0, - }, data) - - data = val.get_poly(2, 2) - self.assertDictContainsSubset({ - ((4, 1),): 4.0, - }, data) - - data = val.get_poly(1, 2) - self.assertDictContainsSubset({ - ((5, 1),): 5.0, - }, data) -
\ No newline at end of file diff --git a/test_polymatrix/test_expression/test_substitude.py b/test_polymatrix/test_expression/test_substitude.py deleted file mode 100644 index 4a1f224..0000000 --- a/test_polymatrix/test_expression/test_substitude.py +++ /dev/null @@ -1,46 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestEval(unittest.TestCase): - - def test_1(self): - terms = { - (0, 0): { - tuple(): 2.0, - ((0, 2),): 3.0, - ((1, 1),): 1.0, - ((2, 2),): 1.0, - }, - } - - substitution = { - (0, 0): { - ((1, 1),): 1.0, - ((2, 1),): 1.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - } - - expr = polymatrix.expression.initexpressionbase.init_substitute_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms, shape=(1, 1)), - variables=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(1, 1),), - values=(polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=substitution, shape=(1, 1)),), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 2.0, - ((1, 1),): 1.0, - ((1, 2),): 3.0, - ((1, 1), (2, 1)): 6.0, - ((2, 2),): 4.0 - }, data) diff --git a/test_polymatrix/test_expression/test_subtractmonomials.py b/test_polymatrix/test_expression/test_subtractmonomials.py deleted file mode 100644 index 77fcc84..0000000 --- a/test_polymatrix/test_expression/test_subtractmonomials.py +++ /dev/null @@ -1,51 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestDerivative(unittest.TestCase): - - def test_1(self): - monomials1 = { - (0, 0): { - ((0, 1),): 1.0, - }, - (1, 0): { - ((0, 1), (1, 2)): 1.0, - }, - } - - monomials2 = { - (0, 0): { - ((0, 1),): 1.0, - }, - (1, 0): { - ((1, 1),): 1.0, - }, - } - - expr = polymatrix.expression.initexpressionbase.init_subtract_monomials_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=monomials1, shape=(2, 1)), - monomials=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=monomials2, shape=(2, 1)), - ) - - state = init_expression_state(n_param=3) - state, val = expr.apply(state) - - self.assertTupleEqual(val.shape, (3, 1)) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 1.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual({ - ((1, 2),): 1.0, - }, data) - - data = val.get_poly(2, 0) - self.assertDictEqual({ - ((0, 1), (1, 1)): 1.0, - }, data) diff --git a/test_polymatrix/test_expression/test_sum.py b/test_polymatrix/test_expression/test_sum.py deleted file mode 100644 index 27c4766..0000000 --- a/test_polymatrix/test_expression/test_sum.py +++ /dev/null @@ -1,33 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestSum(unittest.TestCase): - - def test_1(self): - terms = { - (0, 0): { - tuple(): 2.0, - ((0, 1),): 3.0, - }, - (0, 1):{ - tuple(): 1.0, - ((0, 2),): 1.0, - }, - } - - expr = polymatrix.expression.initexpressionbase.init_sum_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms, shape=(1, 2)), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 3.0, - ((0, 1),): 3.0, - ((0, 2),): 1.0, - }, data) diff --git a/test_polymatrix/test_expression/test_symmetric.py b/test_polymatrix/test_expression/test_symmetric.py deleted file mode 100644 index 5313ff1..0000000 --- a/test_polymatrix/test_expression/test_symmetric.py +++ /dev/null @@ -1,51 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestQuadraticIn(unittest.TestCase): - - def test_1(self): - terms = { - (0, 0): { - ((0, 1),): 1.0, - }, - (1, 0): { - ((1, 1),): 1.0, - }, - (0, 1): { - ((1, 1),): 1.0, - ((2, 1),): 1.0, - }, - } - - underlying = polymatrix.expression.initexpressionbase.init_from_terms_expr( - terms=terms, - shape=(2, 2), - ) - - expr = polymatrix.expression.initexpressionbase.init_symmetric_expr( - underlying=underlying, - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictContainsSubset({ - ((0, 1),): 1.0, - }, data) - - data = val.get_poly(0, 1) - self.assertDictContainsSubset({ - ((1, 1),): 1.0, - ((2, 1),): 0.5, - }, data) - - data = val.get_poly(1, 0) - self.assertDictContainsSubset({ - ((1, 1),): 1.0, - ((2, 1),): 0.5, - }, data) -
\ No newline at end of file diff --git a/test_polymatrix/test_expression/test_toconstant.py b/test_polymatrix/test_expression/test_toconstant.py deleted file mode 100644 index c85c482..0000000 --- a/test_polymatrix/test_expression/test_toconstant.py +++ /dev/null @@ -1,42 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestToConstant(unittest.TestCase): - - def test_1(self): - terms = { - (0, 0): { - tuple(): 2.0, - ((0, 1),): 1.0, - }, - (1, 0): { - ((0, 2), (1, 1)): 1.0, - ((0, 3), (1, 1)): 1.0, - }, - (0, 1): { - tuple(): 5.0, - ((0, 2), (2, 1),): 1.0, - ((3, 1),): 1.0, - }, - } - - expr = polymatrix.expression.initexpressionbase.init_to_constant_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms, shape=(2, 2)), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - tuple(): 2.0, - }, data) - - data = val.get_poly(0, 1) - self.assertDictEqual({ - tuple(): 5.0, - }, data) -
\ No newline at end of file diff --git a/test_polymatrix/test_expression/test_truncate.py b/test_polymatrix/test_expression/test_truncate.py deleted file mode 100644 index c73e98d..0000000 --- a/test_polymatrix/test_expression/test_truncate.py +++ /dev/null @@ -1,53 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestTruncate(unittest.TestCase): - - def test_1(self): - terms = { - (0, 0): { - ((0, 1),): 1.0, # x1 x1 - }, - (1, 0): { - ((0, 2), (1, 1)): 1.0, # x1 x1 x2 - ((0, 3), (1, 1)): 1.0, # x1 x1 x1 x2 - }, - (0, 1): { - ((0, 2), (2, 1),): 1.0, # x1 x1 - ((3, 1),): 1.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - (1, 0): {((1, 1),): 1}, - } - - - expr = polymatrix.expression.initexpressionbase.init_truncate_expr( - underlying=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms, shape=(2, 2)), - variables=polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(2, 1),), - degrees=(1, 2), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - ((0, 1),): 1.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual( - {}, data - ) - - data = val.get_poly(0, 1) - self.assertDictEqual({ - ((0, 2), (2, 1)): 1.0, # x1 x1 - }, data) -
\ No newline at end of file diff --git a/test_polymatrix/test_expression/test_vstack.py b/test_polymatrix/test_expression/test_vstack.py deleted file mode 100644 index 27e52f9..0000000 --- a/test_polymatrix/test_expression/test_vstack.py +++ /dev/null @@ -1,57 +0,0 @@ -import unittest - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state -import polymatrix.expression.initexpressionbase - - -class TestVStack(unittest.TestCase): - - def test_1(self): - terms1 = { - (0, 0): { - ((1, 1),): 1.0, - }, - (1, 0): { - tuple(): 2.0, - }, - } - - terms2 = { - (0, 0): { - tuple(): 3.0, - }, - (1, 1): { - tuple(): 4.0, - }, - } - - expr = polymatrix.expression.initexpressionbase.init_v_stack_expr( - underlying=( - polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms1, shape=(2, 2),), - polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=terms2, shape=(2, 2),), - ), - ) - - state = init_expression_state(n_param=2) - state, val = expr.apply(state) - - data = val.get_poly(0, 0) - self.assertDictEqual({ - ((1, 1),): 1.0, - }, data) - - data = val.get_poly(1, 0) - self.assertDictEqual({ - tuple(): 2.0, - }, data) - - data = val.get_poly(2, 0) - self.assertDictEqual({ - tuple(): 3.0, - }, data) - - data = val.get_poly(3, 1) - self.assertDictEqual({ - tuple(): 4.0, - }, data) - diff --git a/test_polymatrix/test_tomatrixrepr.py b/test_polymatrix/test_tomatrixrepr.py deleted file mode 100644 index dc023ca..0000000 --- a/test_polymatrix/test_tomatrixrepr.py +++ /dev/null @@ -1,54 +0,0 @@ -import unittest -import polymatrix.expression.initexpressionbase - -from polymatrix.expressionstate.init.initexpressionstate import init_expression_state - - -class TestToMatrixRepr(unittest.TestCase): - - def test_1(self): - underlying_terms = { - (0, 0): { - tuple(): 1.0, - ((1, 1),): 2.0, - }, - (1, 0): { - ((0, 1),): 4.0, - ((0, 1), (1, 1)): 3.0, - ((1, 2),): 5.0, - }, - (2, 0): { - ((0, 1), (1, 2)): 3.0, - }, - } - - variable_terms = { - (0, 0): {((0, 1),): 1}, - (1, 0): {((1, 1),): 1}, - } - - expr = polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=underlying_terms, shape=(3, 1)) - - state = init_expression_state(n_param=2) - state, result = polymatrix.to_matrix_repr( - (expr,), - polymatrix.expression.initexpressionbase.init_from_terms_expr(terms=variable_terms, shape=(2, 1),), - ).apply(state) - - A0 = result.data[0][0] - A1 = result.data[0][1] - A2 = result.data[0][2] - A3 = result.data[0][3] - - self.assertEquals(A0[0, 0], 1.0) - - self.assertEquals(A1[0, 1], 2.0) - self.assertEquals(A1[1, 0], 4.0) - - self.assertEquals(A2[1, 1], 1.5) - self.assertEquals(A2[1, 2], 1.5) - self.assertEquals(A2[1, 3], 5.0) - - self.assertEquals(A3[2, 3], 1.0) - self.assertEquals(A3[2, 5], 1.0) - self.assertEquals(A3[2, 6], 1.0) |