From c12f2fa5bea44fa26b46e052da3db47ac11a2043 Mon Sep 17 00:00:00 2001 From: Michael Schneeberger Date: Tue, 20 Feb 2024 10:20:24 +0100 Subject: flatten polymatrix.polymatrix and polymatrix.statemonad structure for better readibility --- polymatrix/denserepr/from_.py | 4 +- polymatrix/expression/expression.py | 2 +- polymatrix/expression/init.py | 2 +- polymatrix/expression/mixins/additionexprmixin.py | 6 +- polymatrix/expression/mixins/blockdiagexprmixin.py | 4 +- polymatrix/expression/mixins/cacheexprmixin.py | 6 +- .../expression/mixins/combinationsexprmixin.py | 4 +- .../expression/mixins/derivativeexprmixin.py | 4 +- .../expression/mixins/determinantexprmixin.py | 4 +- polymatrix/expression/mixins/diagexprmixin.py | 2 +- .../expression/mixins/divergenceexprmixin.py | 4 +- polymatrix/expression/mixins/divisionexprmixin.py | 4 +- polymatrix/expression/mixins/elemmultexprmixin.py | 6 +- polymatrix/expression/mixins/evalexprmixin.py | 4 +- .../expression/mixins/expressionbasemixin.py | 2 +- polymatrix/expression/mixins/eyeexprmixin.py | 4 +- polymatrix/expression/mixins/filterexprmixin.py | 4 +- .../expression/mixins/filterlinearpartexprmixin.py | 4 +- .../mixins/fromsymmetricmatrixexprmixin.py | 4 +- polymatrix/expression/mixins/fromtermsexprmixin.py | 4 +- polymatrix/expression/mixins/fromtupleexprmixin.py | 4 +- polymatrix/expression/mixins/getitemexprmixin.py | 6 +- .../mixins/halfnewtonpolytopeexprmixin.py | 4 +- .../expression/mixins/legendreseriesmixin.py | 4 +- polymatrix/expression/mixins/linearinexprmixin.py | 4 +- .../expression/mixins/linearmatrixinexprmixin.py | 4 +- .../expression/mixins/linearmonomialsexprmixin.py | 4 +- .../expression/mixins/matrixmultexprmixin.py | 4 +- polymatrix/expression/mixins/maxdegreeexprmixin.py | 4 +- polymatrix/expression/mixins/maxexprmixin.py | 4 +- .../expression/mixins/parametrizeexprmixin.py | 4 +- .../mixins/parametrizematrixexprmixin.py | 4 +- polymatrix/expression/mixins/productexprmixin.py | 4 +- .../expression/mixins/quadraticinexprmixin.py | 4 +- .../mixins/quadraticmonomialsexprmixin.py | 4 +- polymatrix/expression/mixins/repmatexprmixin.py | 2 +- polymatrix/expression/mixins/reshapeexprmixin.py | 2 +- .../expression/mixins/setelementatexprmixin.py | 6 +- polymatrix/expression/mixins/squeezeexprmixin.py | 4 +- .../expression/mixins/substituteexprmixin.py | 4 +- .../mixins/subtractmonomialsexprmixin.py | 4 +- polymatrix/expression/mixins/sumexprmixin.py | 4 +- polymatrix/expression/mixins/symmetricexprmixin.py | 4 +- .../expression/mixins/toconstantexprmixin.py | 4 +- .../expression/mixins/toquadraticexprmixin.py | 4 +- .../expression/mixins/tosortedvariablesmixin.py | 4 +- .../mixins/tosymmetricmatrixexprmixin.py | 4 +- polymatrix/expression/mixins/transposeexprmixin.py | 6 +- polymatrix/expression/mixins/truncateexprmixin.py | 4 +- polymatrix/expression/mixins/vstackexprmixin.py | 4 +- polymatrix/expression/to.py | 4 +- polymatrix/expressionstate/mixins.py | 2 +- polymatrix/polymatrix/abc.py | 7 +++ polymatrix/polymatrix/impl.py | 9 +++ polymatrix/polymatrix/impl/__init__.py | 0 polymatrix/polymatrix/impl/polymatriximpl.py | 8 --- polymatrix/polymatrix/init.py | 12 ++++ polymatrix/polymatrix/init/__init__.py | 0 polymatrix/polymatrix/init/initpolymatrix.py | 12 ---- polymatrix/polymatrix/mixins.py | 37 ++++++++++++ polymatrix/polymatrix/mixins/__init__.py | 0 .../polymatrix/mixins/polymatrixasdictmixin.py | 19 ------ polymatrix/polymatrix/mixins/polymatrixmixin.py | 22 ------- polymatrix/polymatrix/polymatrix.py | 4 -- polymatrix/statemonad/__init__.py | 4 +- polymatrix/statemonad/abc.py | 7 +++ polymatrix/statemonad/impl.py | 9 +++ polymatrix/statemonad/impl/__init__.py | 0 polymatrix/statemonad/impl/statemonadimpl.py | 8 --- polymatrix/statemonad/init.py | 11 ++++ polymatrix/statemonad/init/__init__.py | 0 polymatrix/statemonad/init/initstatemonad.py | 10 ---- polymatrix/statemonad/mixins.py | 69 ++++++++++++++++++++++ polymatrix/statemonad/mixins/__init__.py | 0 polymatrix/statemonad/mixins/statemixin.py | 8 --- polymatrix/statemonad/mixins/statemonadmixin.py | 63 -------------------- polymatrix/statemonad/statemonad.py | 4 -- 77 files changed, 266 insertions(+), 263 deletions(-) create mode 100644 polymatrix/polymatrix/abc.py create mode 100644 polymatrix/polymatrix/impl.py delete mode 100644 polymatrix/polymatrix/impl/__init__.py delete mode 100644 polymatrix/polymatrix/impl/polymatriximpl.py create mode 100644 polymatrix/polymatrix/init.py delete mode 100644 polymatrix/polymatrix/init/__init__.py delete mode 100644 polymatrix/polymatrix/init/initpolymatrix.py create mode 100644 polymatrix/polymatrix/mixins.py delete mode 100644 polymatrix/polymatrix/mixins/__init__.py delete mode 100644 polymatrix/polymatrix/mixins/polymatrixasdictmixin.py delete mode 100644 polymatrix/polymatrix/mixins/polymatrixmixin.py delete mode 100644 polymatrix/polymatrix/polymatrix.py create mode 100644 polymatrix/statemonad/abc.py create mode 100644 polymatrix/statemonad/impl.py delete mode 100644 polymatrix/statemonad/impl/__init__.py delete mode 100644 polymatrix/statemonad/impl/statemonadimpl.py create mode 100644 polymatrix/statemonad/init.py delete mode 100644 polymatrix/statemonad/init/__init__.py delete mode 100644 polymatrix/statemonad/init/initstatemonad.py create mode 100644 polymatrix/statemonad/mixins.py delete mode 100644 polymatrix/statemonad/mixins/__init__.py delete mode 100644 polymatrix/statemonad/mixins/statemixin.py delete mode 100644 polymatrix/statemonad/mixins/statemonadmixin.py delete mode 100644 polymatrix/statemonad/statemonad.py diff --git a/polymatrix/denserepr/from_.py b/polymatrix/denserepr/from_.py index 13b77b7..b61af86 100644 --- a/polymatrix/denserepr/from_.py +++ b/polymatrix/denserepr/from_.py @@ -9,8 +9,8 @@ from polymatrix.expression.expression import Expression from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable -from polymatrix.statemonad.init.initstatemonad import init_state_monad -from polymatrix.statemonad.mixins.statemonadmixin import StateMonadMixin +from polymatrix.statemonad.init import init_state_monad +from polymatrix.statemonad.mixins import StateMonadMixin from polymatrix.expression.utils.monomialtoindex import monomial_to_index diff --git a/polymatrix/expression/expression.py b/polymatrix/expression/expression.py index 8cfcb82..dc2f144 100644 --- a/polymatrix/expression/expression.py +++ b/polymatrix/expression/expression.py @@ -10,7 +10,7 @@ from polymatrix.utils.getstacklines import get_stack_lines from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expression.op import diff, linear_in, linear_monomials, legendre -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/init.py b/polymatrix/expression/init.py index 7a4ea36..b7be83a 100644 --- a/polymatrix/expression/init.py +++ b/polymatrix/expression/init.py @@ -8,7 +8,7 @@ from polymatrix.utils.getstacklines import FrameSummary from polymatrix.utils.getstacklines import get_stack_lines from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expression.utils.formatsubstitutions import format_substitutions -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.impl import FromTupleExprImpl, AdditionExprImpl diff --git a/polymatrix/expression/mixins/additionexprmixin.py b/polymatrix/expression/mixins/additionexprmixin.py index cf64254..2cbbe1e 100644 --- a/polymatrix/expression/mixins/additionexprmixin.py +++ b/polymatrix/expression/mixins/additionexprmixin.py @@ -5,9 +5,9 @@ import dataclassabc from polymatrix.utils.getstacklines import FrameSummary from polymatrix.utils.tooperatorexception import to_operator_exception -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.init import init_poly_matrix +from polymatrix.polymatrix.mixins import PolyMatrixMixin +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin diff --git a/polymatrix/expression/mixins/blockdiagexprmixin.py b/polymatrix/expression/mixins/blockdiagexprmixin.py index 2226025..3ed5766 100644 --- a/polymatrix/expression/mixins/blockdiagexprmixin.py +++ b/polymatrix/expression/mixins/blockdiagexprmixin.py @@ -2,10 +2,10 @@ import abc import itertools import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/cacheexprmixin.py b/polymatrix/expression/mixins/cacheexprmixin.py index 55df49e..937b0f3 100644 --- a/polymatrix/expression/mixins/cacheexprmixin.py +++ b/polymatrix/expression/mixins/cacheexprmixin.py @@ -1,12 +1,12 @@ import abc import dataclasses -from polymatrix.polymatrix.mixins.polymatrixasdictmixin import PolyMatrixAsDictMixin +from polymatrix.polymatrix.mixins import PolyMatrixAsDictMixin -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class CacheExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/combinationsexprmixin.py b/polymatrix/expression/mixins/combinationsexprmixin.py index e513e8b..395f068 100644 --- a/polymatrix/expression/mixins/combinationsexprmixin.py +++ b/polymatrix/expression/mixins/combinationsexprmixin.py @@ -2,9 +2,9 @@ import abc import itertools -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.multiplymonomials import multiply_monomials diff --git a/polymatrix/expression/mixins/derivativeexprmixin.py b/polymatrix/expression/mixins/derivativeexprmixin.py index 940516a..bab3c91 100644 --- a/polymatrix/expression/mixins/derivativeexprmixin.py +++ b/polymatrix/expression/mixins/derivativeexprmixin.py @@ -2,9 +2,9 @@ import abc import typing -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getderivativemonomials import get_derivative_monomials from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/determinantexprmixin.py b/polymatrix/expression/mixins/determinantexprmixin.py index 0adc589..ef18e91 100644 --- a/polymatrix/expression/mixins/determinantexprmixin.py +++ b/polymatrix/expression/mixins/determinantexprmixin.py @@ -4,9 +4,9 @@ import collections import dataclasses from numpy import var -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/diagexprmixin.py b/polymatrix/expression/mixins/diagexprmixin.py index 497fa08..1867f8a 100644 --- a/polymatrix/expression/mixins/diagexprmixin.py +++ b/polymatrix/expression/mixins/diagexprmixin.py @@ -3,7 +3,7 @@ import dataclassabc from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class DiagExprMixin(ExpressionBaseMixin): """ diff --git a/polymatrix/expression/mixins/divergenceexprmixin.py b/polymatrix/expression/mixins/divergenceexprmixin.py index 1cf55b9..4dc61cd 100644 --- a/polymatrix/expression/mixins/divergenceexprmixin.py +++ b/polymatrix/expression/mixins/divergenceexprmixin.py @@ -3,9 +3,9 @@ import abc import collections import typing -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getderivativemonomials import get_derivative_monomials from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/divisionexprmixin.py b/polymatrix/expression/mixins/divisionexprmixin.py index 2321fe7..90919a5 100644 --- a/polymatrix/expression/mixins/divisionexprmixin.py +++ b/polymatrix/expression/mixins/divisionexprmixin.py @@ -5,9 +5,9 @@ import dataclasses from polymatrix.expression.mixins.elemmultexprmixin import ElemMultExprMixin from polymatrix.utils.getstacklines import FrameSummary from polymatrix.utils.tooperatorexception import to_operator_exception -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/elemmultexprmixin.py b/polymatrix/expression/mixins/elemmultexprmixin.py index 4ea6cfa..96b793c 100644 --- a/polymatrix/expression/mixins/elemmultexprmixin.py +++ b/polymatrix/expression/mixins/elemmultexprmixin.py @@ -4,10 +4,10 @@ import itertools import typing import dataclassabc -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.mixins import PolyMatrixMixin +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.mergemonomialindices import merge_monomial_indices diff --git a/polymatrix/expression/mixins/evalexprmixin.py b/polymatrix/expression/mixins/evalexprmixin.py index 7c8ac67..30dc178 100644 --- a/polymatrix/expression/mixins/evalexprmixin.py +++ b/polymatrix/expression/mixins/evalexprmixin.py @@ -3,9 +3,9 @@ import abc import itertools import math -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/expressionbasemixin.py b/polymatrix/expression/mixins/expressionbasemixin.py index 58d6aba..1412f6a 100644 --- a/polymatrix/expression/mixins/expressionbasemixin.py +++ b/polymatrix/expression/mixins/expressionbasemixin.py @@ -1,7 +1,7 @@ import abc from polymatrix.expressionstate.abc import ExpressionState -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix class ExpressionBaseMixin( diff --git a/polymatrix/expression/mixins/eyeexprmixin.py b/polymatrix/expression/mixins/eyeexprmixin.py index d036e82..4a294ac 100644 --- a/polymatrix/expression/mixins/eyeexprmixin.py +++ b/polymatrix/expression/mixins/eyeexprmixin.py @@ -2,10 +2,10 @@ import abc import itertools import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/filterexprmixin.py b/polymatrix/expression/mixins/filterexprmixin.py index 07089a0..1cf90d8 100644 --- a/polymatrix/expression/mixins/filterexprmixin.py +++ b/polymatrix/expression/mixins/filterexprmixin.py @@ -1,9 +1,9 @@ import abc -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/filterlinearpartexprmixin.py b/polymatrix/expression/mixins/filterlinearpartexprmixin.py index 01891c6..8eaf2ef 100644 --- a/polymatrix/expression/mixins/filterlinearpartexprmixin.py +++ b/polymatrix/expression/mixins/filterlinearpartexprmixin.py @@ -2,9 +2,9 @@ import abc import collections -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/fromsymmetricmatrixexprmixin.py b/polymatrix/expression/mixins/fromsymmetricmatrixexprmixin.py index 78ca85b..a31655f 100644 --- a/polymatrix/expression/mixins/fromsymmetricmatrixexprmixin.py +++ b/polymatrix/expression/mixins/fromsymmetricmatrixexprmixin.py @@ -4,10 +4,10 @@ import dataclasses import math from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class FromSymmetricMatrixExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/fromtermsexprmixin.py b/polymatrix/expression/mixins/fromtermsexprmixin.py index e979434..00f1b64 100644 --- a/polymatrix/expression/mixins/fromtermsexprmixin.py +++ b/polymatrix/expression/mixins/fromtermsexprmixin.py @@ -3,10 +3,10 @@ import abc from numpy import poly import sympy -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class FromTermsExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/fromtupleexprmixin.py b/polymatrix/expression/mixins/fromtupleexprmixin.py index fa3dc43..302bcc6 100644 --- a/polymatrix/expression/mixins/fromtupleexprmixin.py +++ b/polymatrix/expression/mixins/fromtupleexprmixin.py @@ -6,8 +6,8 @@ import numpy as np from polymatrix.utils.getstacklines import FrameSummary from polymatrix.utils.tooperatorexception import to_operator_exception -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.init import init_poly_matrix +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin diff --git a/polymatrix/expression/mixins/getitemexprmixin.py b/polymatrix/expression/mixins/getitemexprmixin.py index d5d2279..a3b513f 100644 --- a/polymatrix/expression/mixins/getitemexprmixin.py +++ b/polymatrix/expression/mixins/getitemexprmixin.py @@ -2,11 +2,11 @@ import abc import dataclasses import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/halfnewtonpolytopeexprmixin.py b/polymatrix/expression/mixins/halfnewtonpolytopeexprmixin.py index ce5abcf..c6a470f 100644 --- a/polymatrix/expression/mixins/halfnewtonpolytopeexprmixin.py +++ b/polymatrix/expression/mixins/halfnewtonpolytopeexprmixin.py @@ -6,10 +6,10 @@ import math from polymatrix.expression.utils.getmonomialindices import get_monomial_indices from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class HalfNewtonPolytopeExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/legendreseriesmixin.py b/polymatrix/expression/mixins/legendreseriesmixin.py index 22b7253..98139ae 100644 --- a/polymatrix/expression/mixins/legendreseriesmixin.py +++ b/polymatrix/expression/mixins/legendreseriesmixin.py @@ -1,8 +1,8 @@ import abc from polymatrix.utils.getstacklines import FrameSummary -from polymatrix.polymatrix.polymatrix import PolyMatrix -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.abc import PolyMatrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin diff --git a/polymatrix/expression/mixins/linearinexprmixin.py b/polymatrix/expression/mixins/linearinexprmixin.py index dedbd70..0bc99e9 100644 --- a/polymatrix/expression/mixins/linearinexprmixin.py +++ b/polymatrix/expression/mixins/linearinexprmixin.py @@ -2,9 +2,9 @@ import abc import collections -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getmonomialindices import get_monomial_indices from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/linearmatrixinexprmixin.py b/polymatrix/expression/mixins/linearmatrixinexprmixin.py index aa728d0..8e0f997 100644 --- a/polymatrix/expression/mixins/linearmatrixinexprmixin.py +++ b/polymatrix/expression/mixins/linearmatrixinexprmixin.py @@ -3,9 +3,9 @@ import abc import collections from numpy import var -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/linearmonomialsexprmixin.py b/polymatrix/expression/mixins/linearmonomialsexprmixin.py index 1020946..1d077e2 100644 --- a/polymatrix/expression/mixins/linearmonomialsexprmixin.py +++ b/polymatrix/expression/mixins/linearmonomialsexprmixin.py @@ -2,10 +2,10 @@ import abc import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable from polymatrix.expression.utils.sortmonomials import sort_monomials diff --git a/polymatrix/expression/mixins/matrixmultexprmixin.py b/polymatrix/expression/mixins/matrixmultexprmixin.py index cede447..7014157 100644 --- a/polymatrix/expression/mixins/matrixmultexprmixin.py +++ b/polymatrix/expression/mixins/matrixmultexprmixin.py @@ -2,9 +2,9 @@ import abc from polymatrix.utils.getstacklines import FrameSummary -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.multiplypolynomial import multiply_polynomial from polymatrix.utils.tooperatorexception import to_operator_exception diff --git a/polymatrix/expression/mixins/maxdegreeexprmixin.py b/polymatrix/expression/mixins/maxdegreeexprmixin.py index 9f8d647..0094b9b 100644 --- a/polymatrix/expression/mixins/maxdegreeexprmixin.py +++ b/polymatrix/expression/mixins/maxdegreeexprmixin.py @@ -1,9 +1,9 @@ import abc -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/maxexprmixin.py b/polymatrix/expression/mixins/maxexprmixin.py index 884c911..5366a83 100644 --- a/polymatrix/expression/mixins/maxexprmixin.py +++ b/polymatrix/expression/mixins/maxexprmixin.py @@ -1,10 +1,10 @@ import abc -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class MaxExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/parametrizeexprmixin.py b/polymatrix/expression/mixins/parametrizeexprmixin.py index ad2fce1..c16fcf4 100644 --- a/polymatrix/expression/mixins/parametrizeexprmixin.py +++ b/polymatrix/expression/mixins/parametrizeexprmixin.py @@ -2,10 +2,10 @@ import abc import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class ParametrizeExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/parametrizematrixexprmixin.py b/polymatrix/expression/mixins/parametrizematrixexprmixin.py index d3d2694..a4cc43d 100644 --- a/polymatrix/expression/mixins/parametrizematrixexprmixin.py +++ b/polymatrix/expression/mixins/parametrizematrixexprmixin.py @@ -2,10 +2,10 @@ import abc import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class ParametrizeMatrixExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/productexprmixin.py b/polymatrix/expression/mixins/productexprmixin.py index c11c416..c60ffc2 100644 --- a/polymatrix/expression/mixins/productexprmixin.py +++ b/polymatrix/expression/mixins/productexprmixin.py @@ -4,8 +4,8 @@ import itertools from polymatrix.utils.getstacklines import FrameSummary from polymatrix.utils.tooperatorexception import to_operator_exception -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.init import init_poly_matrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.multiplymonomials import multiply_monomials from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin diff --git a/polymatrix/expression/mixins/quadraticinexprmixin.py b/polymatrix/expression/mixins/quadraticinexprmixin.py index da7d130..f567f5e 100644 --- a/polymatrix/expression/mixins/quadraticinexprmixin.py +++ b/polymatrix/expression/mixins/quadraticinexprmixin.py @@ -2,9 +2,9 @@ import abc import collections -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getmonomialindices import get_monomial_indices from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py b/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py index 71abc93..d53613a 100644 --- a/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py +++ b/polymatrix/expression/mixins/quadraticmonomialsexprmixin.py @@ -2,10 +2,10 @@ import abc import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable from polymatrix.expression.utils.splitmonomialindices import split_monomial_indices diff --git a/polymatrix/expression/mixins/repmatexprmixin.py b/polymatrix/expression/mixins/repmatexprmixin.py index 00eaee2..4726e88 100644 --- a/polymatrix/expression/mixins/repmatexprmixin.py +++ b/polymatrix/expression/mixins/repmatexprmixin.py @@ -3,7 +3,7 @@ import dataclassabc from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class RepMatExprMixin(ExpressionBaseMixin): @property diff --git a/polymatrix/expression/mixins/reshapeexprmixin.py b/polymatrix/expression/mixins/reshapeexprmixin.py index 4377e31..71042a3 100644 --- a/polymatrix/expression/mixins/reshapeexprmixin.py +++ b/polymatrix/expression/mixins/reshapeexprmixin.py @@ -7,7 +7,7 @@ import numpy as np from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class ReshapeExprMixin(ExpressionBaseMixin): @property diff --git a/polymatrix/expression/mixins/setelementatexprmixin.py b/polymatrix/expression/mixins/setelementatexprmixin.py index 4757a72..51428cb 100644 --- a/polymatrix/expression/mixins/setelementatexprmixin.py +++ b/polymatrix/expression/mixins/setelementatexprmixin.py @@ -3,11 +3,11 @@ import abc import dataclasses import typing import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/squeezeexprmixin.py b/polymatrix/expression/mixins/squeezeexprmixin.py index 2a8d849..28fec73 100644 --- a/polymatrix/expression/mixins/squeezeexprmixin.py +++ b/polymatrix/expression/mixins/squeezeexprmixin.py @@ -1,9 +1,9 @@ import abc -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/substituteexprmixin.py b/polymatrix/expression/mixins/substituteexprmixin.py index b2e086d..64670e9 100644 --- a/polymatrix/expression/mixins/substituteexprmixin.py +++ b/polymatrix/expression/mixins/substituteexprmixin.py @@ -4,9 +4,9 @@ import itertools import math import typing -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable from polymatrix.expression.utils.multiplypolynomial import multiply_polynomial diff --git a/polymatrix/expression/mixins/subtractmonomialsexprmixin.py b/polymatrix/expression/mixins/subtractmonomialsexprmixin.py index e48482e..67ee6f0 100644 --- a/polymatrix/expression/mixins/subtractmonomialsexprmixin.py +++ b/polymatrix/expression/mixins/subtractmonomialsexprmixin.py @@ -2,10 +2,10 @@ import abc import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.utils.getmonomialindices import get_monomial_indices from polymatrix.expression.utils.sortmonomials import sort_monomials from polymatrix.expression.utils.subtractmonomialindices import SubtractError, subtract_monomial_indices diff --git a/polymatrix/expression/mixins/sumexprmixin.py b/polymatrix/expression/mixins/sumexprmixin.py index e60255e..92be990 100644 --- a/polymatrix/expression/mixins/sumexprmixin.py +++ b/polymatrix/expression/mixins/sumexprmixin.py @@ -3,10 +3,10 @@ import abc import collections import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class SumExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/symmetricexprmixin.py b/polymatrix/expression/mixins/symmetricexprmixin.py index 1624acc..bcdf316 100644 --- a/polymatrix/expression/mixins/symmetricexprmixin.py +++ b/polymatrix/expression/mixins/symmetricexprmixin.py @@ -3,10 +3,10 @@ import abc import collections import itertools import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/toconstantexprmixin.py b/polymatrix/expression/mixins/toconstantexprmixin.py index d8c055b..40693d3 100644 --- a/polymatrix/expression/mixins/toconstantexprmixin.py +++ b/polymatrix/expression/mixins/toconstantexprmixin.py @@ -2,9 +2,9 @@ import abc import collections -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/toquadraticexprmixin.py b/polymatrix/expression/mixins/toquadraticexprmixin.py index 63f3343..6ba2d3a 100644 --- a/polymatrix/expression/mixins/toquadraticexprmixin.py +++ b/polymatrix/expression/mixins/toquadraticexprmixin.py @@ -3,9 +3,9 @@ import abc import collections import dataclasses -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/tosortedvariablesmixin.py b/polymatrix/expression/mixins/tosortedvariablesmixin.py index 65f27f1..9768bcc 100644 --- a/polymatrix/expression/mixins/tosortedvariablesmixin.py +++ b/polymatrix/expression/mixins/tosortedvariablesmixin.py @@ -2,9 +2,9 @@ import abc from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/tosymmetricmatrixexprmixin.py b/polymatrix/expression/mixins/tosymmetricmatrixexprmixin.py index d8d1dbe..164f159 100644 --- a/polymatrix/expression/mixins/tosymmetricmatrixexprmixin.py +++ b/polymatrix/expression/mixins/tosymmetricmatrixexprmixin.py @@ -2,10 +2,10 @@ import abc from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin from polymatrix.expressionstate.mixins import ExpressionStateMixin -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin class ToSymmetricMatrixExprMixin(ExpressionBaseMixin): diff --git a/polymatrix/expression/mixins/transposeexprmixin.py b/polymatrix/expression/mixins/transposeexprmixin.py index 858136b..e1a468d 100644 --- a/polymatrix/expression/mixins/transposeexprmixin.py +++ b/polymatrix/expression/mixins/transposeexprmixin.py @@ -3,11 +3,11 @@ import abc import dataclasses import typing import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/mixins/truncateexprmixin.py b/polymatrix/expression/mixins/truncateexprmixin.py index 8e01cf9..05afd55 100644 --- a/polymatrix/expression/mixins/truncateexprmixin.py +++ b/polymatrix/expression/mixins/truncateexprmixin.py @@ -1,9 +1,9 @@ import abc -from polymatrix.polymatrix.init.initpolymatrix import init_poly_matrix +from polymatrix.polymatrix.init import init_poly_matrix from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable diff --git a/polymatrix/expression/mixins/vstackexprmixin.py b/polymatrix/expression/mixins/vstackexprmixin.py index ef842e0..104a608 100644 --- a/polymatrix/expression/mixins/vstackexprmixin.py +++ b/polymatrix/expression/mixins/vstackexprmixin.py @@ -2,10 +2,10 @@ import abc import itertools import dataclassabc -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin +from polymatrix.polymatrix.mixins import PolyMatrixMixin from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin -from polymatrix.polymatrix.polymatrix import PolyMatrix +from polymatrix.polymatrix.abc import PolyMatrix from polymatrix.expressionstate.abc import ExpressionState diff --git a/polymatrix/expression/to.py b/polymatrix/expression/to.py index 6d6286e..5bec552 100644 --- a/polymatrix/expression/to.py +++ b/polymatrix/expression/to.py @@ -6,8 +6,8 @@ from polymatrix.expression.mixins.parametrizeexprmixin import ParametrizeExprMix from polymatrix.expression.mixins.parametrizematrixexprmixin import ParametrizeMatrixExprMixin from polymatrix.expression.utils.getvariableindices import get_variable_indices_from_variable from polymatrix.expressionstate.abc import ExpressionState -from polymatrix.statemonad.init.initstatemonad import init_state_monad -from polymatrix.statemonad.mixins.statemonadmixin import StateMonadMixin +from polymatrix.statemonad.init import init_state_monad +from polymatrix.statemonad.mixins import StateMonadMixin def shape( diff --git a/polymatrix/expressionstate/mixins.py b/polymatrix/expressionstate/mixins.py index 538f652..ad23ea2 100644 --- a/polymatrix/expressionstate/mixins.py +++ b/polymatrix/expressionstate/mixins.py @@ -2,7 +2,7 @@ import abc import dataclasses import typing -from polymatrix.statemonad.mixins.statemixin import StateCacheMixin +from polymatrix.statemonad.mixins import StateCacheMixin class ExpressionStateMixin( diff --git a/polymatrix/polymatrix/abc.py b/polymatrix/polymatrix/abc.py new file mode 100644 index 0000000..aee2b40 --- /dev/null +++ b/polymatrix/polymatrix/abc.py @@ -0,0 +1,7 @@ +import abc + +from polymatrix.polymatrix.mixins import PolyMatrixAsDictMixin + + +class PolyMatrix(PolyMatrixAsDictMixin, abc.ABC): + pass diff --git a/polymatrix/polymatrix/impl.py b/polymatrix/polymatrix/impl.py new file mode 100644 index 0000000..f44dc9c --- /dev/null +++ b/polymatrix/polymatrix/impl.py @@ -0,0 +1,9 @@ +import dataclassabc + +from polymatrix.polymatrix.abc import PolyMatrix + + +@dataclassabc.dataclassabc(frozen=True) +class PolyMatrixImpl(PolyMatrix): + terms: dict + shape: tuple[int, ...] diff --git a/polymatrix/polymatrix/impl/__init__.py b/polymatrix/polymatrix/impl/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polymatrix/polymatrix/impl/polymatriximpl.py b/polymatrix/polymatrix/impl/polymatriximpl.py deleted file mode 100644 index cfca663..0000000 --- a/polymatrix/polymatrix/impl/polymatriximpl.py +++ /dev/null @@ -1,8 +0,0 @@ -import dataclassabc -from polymatrix.polymatrix.polymatrix import PolyMatrix - - -@dataclassabc.dataclassabc(frozen=True) -class PolyMatrixImpl(PolyMatrix): - terms: dict - shape: tuple[int, ...] diff --git a/polymatrix/polymatrix/init.py b/polymatrix/polymatrix/init.py new file mode 100644 index 0000000..7f0b60f --- /dev/null +++ b/polymatrix/polymatrix/init.py @@ -0,0 +1,12 @@ +from polymatrix.polymatrix.impl import PolyMatrixImpl + + +def init_poly_matrix( + terms: dict, + shape: tuple, +): + + return PolyMatrixImpl( + terms=terms, + shape=shape, +) diff --git a/polymatrix/polymatrix/init/__init__.py b/polymatrix/polymatrix/init/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polymatrix/polymatrix/init/initpolymatrix.py b/polymatrix/polymatrix/init/initpolymatrix.py deleted file mode 100644 index 412adfb..0000000 --- a/polymatrix/polymatrix/init/initpolymatrix.py +++ /dev/null @@ -1,12 +0,0 @@ -from polymatrix.polymatrix.impl.polymatriximpl import PolyMatrixImpl - - -def init_poly_matrix( - terms: dict, - shape: tuple, -): - - return PolyMatrixImpl( - terms=terms, - shape=shape, -) diff --git a/polymatrix/polymatrix/mixins.py b/polymatrix/polymatrix/mixins.py new file mode 100644 index 0000000..a097615 --- /dev/null +++ b/polymatrix/polymatrix/mixins.py @@ -0,0 +1,37 @@ +import abc +import typing + + +class PolyMatrixMixin(abc.ABC): + @property + @abc.abstractclassmethod + def shape(self) -> tuple[int, int]: + ... + + def gen_terms(self) -> typing.Generator[tuple[tuple[int, int], dict[tuple[int, ...], float]], None, None]: + for row in range(self.shape[0]): + for col in range(self.shape[1]): + polynomial = self.get_poly(row, col) + if polynomial is None: + continue + + yield (row, col), polynomial + + @abc.abstractclassmethod + def get_poly(self, row: int, col: int) -> typing.Optional[dict[tuple[int, ...], float]]: + ... + + +class PolyMatrixAsDictMixin( + PolyMatrixMixin, + abc.ABC, +): + @property + @abc.abstractmethod + def terms(self) -> dict[tuple[int, int], dict[tuple[int, ...], float]]: + ... + + # overwrites abstract method of `PolyMatrixMixin` + def get_poly(self, row: int, col: int) -> typing.Optional[dict[tuple[int, ...], float]]: + if (row, col) in self.terms: + return self.terms[row, col] diff --git a/polymatrix/polymatrix/mixins/__init__.py b/polymatrix/polymatrix/mixins/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polymatrix/polymatrix/mixins/polymatrixasdictmixin.py b/polymatrix/polymatrix/mixins/polymatrixasdictmixin.py deleted file mode 100644 index 93b6385..0000000 --- a/polymatrix/polymatrix/mixins/polymatrixasdictmixin.py +++ /dev/null @@ -1,19 +0,0 @@ -import abc -import typing - -from polymatrix.polymatrix.mixins.polymatrixmixin import PolyMatrixMixin - - -class PolyMatrixAsDictMixin( - PolyMatrixMixin, - abc.ABC, -): - @property - @abc.abstractmethod - def terms(self) -> dict[tuple[int, int], dict[tuple[int, ...], float]]: - ... - - # overwrites abstract method of `PolyMatrixMixin` - def get_poly(self, row: int, col: int) -> typing.Optional[dict[tuple[int, ...], float]]: - if (row, col) in self.terms: - return self.terms[row, col] diff --git a/polymatrix/polymatrix/mixins/polymatrixmixin.py b/polymatrix/polymatrix/mixins/polymatrixmixin.py deleted file mode 100644 index e67a6fa..0000000 --- a/polymatrix/polymatrix/mixins/polymatrixmixin.py +++ /dev/null @@ -1,22 +0,0 @@ -import abc -import typing - - -class PolyMatrixMixin(abc.ABC): - @property - @abc.abstractclassmethod - def shape(self) -> tuple[int, int]: - ... - - def gen_terms(self) -> typing.Generator[tuple[tuple[int, int], dict[tuple[int, ...], float]], None, None]: - for row in range(self.shape[0]): - for col in range(self.shape[1]): - polynomial = self.get_poly(row, col) - if polynomial is None: - continue - - yield (row, col), polynomial - - @abc.abstractclassmethod - def get_poly(self, row: int, col: int) -> typing.Optional[dict[tuple[int, ...], float]]: - ... diff --git a/polymatrix/polymatrix/polymatrix.py b/polymatrix/polymatrix/polymatrix.py deleted file mode 100644 index b8523f6..0000000 --- a/polymatrix/polymatrix/polymatrix.py +++ /dev/null @@ -1,4 +0,0 @@ -from polymatrix.polymatrix.mixins.polymatrixasdictmixin import PolyMatrixAsDictMixin - -class PolyMatrix(PolyMatrixAsDictMixin): - pass diff --git a/polymatrix/statemonad/__init__.py b/polymatrix/statemonad/__init__.py index bb280e0..915eb31 100644 --- a/polymatrix/statemonad/__init__.py +++ b/polymatrix/statemonad/__init__.py @@ -1,5 +1,5 @@ -from polymatrix.statemonad.init.initstatemonad import init_state_monad -from polymatrix.statemonad.statemonad import StateMonad +from polymatrix.statemonad.init import init_state_monad +from polymatrix.statemonad.abc import StateMonad def from_(val): diff --git a/polymatrix/statemonad/abc.py b/polymatrix/statemonad/abc.py new file mode 100644 index 0000000..ffb52de --- /dev/null +++ b/polymatrix/statemonad/abc.py @@ -0,0 +1,7 @@ +import abc + +from polymatrix.statemonad.mixins import StateMonadMixin + + +class StateMonad(StateMonadMixin, abc.ABC): + pass diff --git a/polymatrix/statemonad/impl.py b/polymatrix/statemonad/impl.py new file mode 100644 index 0000000..4bffb5d --- /dev/null +++ b/polymatrix/statemonad/impl.py @@ -0,0 +1,9 @@ +from typing import Callable +import dataclassabc + +from polymatrix.statemonad.abc import StateMonad + + +@dataclassabc.dataclassabc(frozen=True) +class StateMonadImpl(StateMonad): + apply_func: Callable diff --git a/polymatrix/statemonad/impl/__init__.py b/polymatrix/statemonad/impl/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polymatrix/statemonad/impl/statemonadimpl.py b/polymatrix/statemonad/impl/statemonadimpl.py deleted file mode 100644 index 6b9270a..0000000 --- a/polymatrix/statemonad/impl/statemonadimpl.py +++ /dev/null @@ -1,8 +0,0 @@ -import dataclassabc -from polymatrix.statemonad.statemonad import StateMonad - -from typing import Callable - -@dataclassabc.dataclassabc(frozen=True) -class StateMonadImpl(StateMonad): - apply_func: Callable diff --git a/polymatrix/statemonad/init.py b/polymatrix/statemonad/init.py new file mode 100644 index 0000000..7ef47cc --- /dev/null +++ b/polymatrix/statemonad/init.py @@ -0,0 +1,11 @@ +from typing import Callable + +from polymatrix.statemonad.impl import StateMonadImpl + + +def init_state_monad( + apply_func: Callable, +): + return StateMonadImpl( + apply_func=apply_func, +) diff --git a/polymatrix/statemonad/init/__init__.py b/polymatrix/statemonad/init/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polymatrix/statemonad/init/initstatemonad.py b/polymatrix/statemonad/init/initstatemonad.py deleted file mode 100644 index 7d269f3..0000000 --- a/polymatrix/statemonad/init/initstatemonad.py +++ /dev/null @@ -1,10 +0,0 @@ -from typing import Callable -from polymatrix.statemonad.impl.statemonadimpl import StateMonadImpl - - -def init_state_monad( - apply_func: Callable, -): - return StateMonadImpl( - apply_func=apply_func, -) diff --git a/polymatrix/statemonad/mixins.py b/polymatrix/statemonad/mixins.py new file mode 100644 index 0000000..1a13440 --- /dev/null +++ b/polymatrix/statemonad/mixins.py @@ -0,0 +1,69 @@ +import abc +import dataclasses +from typing import Callable, Tuple, TypeVar, Generic + + +class StateCacheMixin(abc.ABC): + @property + @abc.abstractmethod + def cache(self) -> dict: + ... + + +State = TypeVar('State', bound=StateCacheMixin) +U = TypeVar('U') +V = TypeVar('V') + + +class StateMonadMixin( + Generic[State, U], + abc.ABC, +): + @property + @abc.abstractmethod + def apply_func(self) -> Callable[[State], tuple[State, U]]: + ... + + def map(self, fn: Callable[[U], V]) -> 'StateMonadMixin[State, V]': + + def internal_map(state: State) -> Tuple[State, U]: + n_state, val = self.apply(state) + return n_state, fn(val) + + return dataclasses.replace(self, apply_func=internal_map) + + def flat_map(self, fn: Callable[[U], 'StateMonadMixin']) -> 'StateMonadMixin[State, V]': + + def internal_map(state: State) -> Tuple[State, V]: + n_state, val = self.apply(state) + return fn(val).apply(n_state) + + return dataclasses.replace(self, apply_func=internal_map) + + def zip(self, other: 'StateMonadMixin') -> 'StateMonadMixin': + def internal_map(state: State) -> Tuple[State, V]: + state, val1 = self.apply(state) + state, val2 = other.apply(state) + return state, (val1, val2) + + return dataclasses.replace(self, apply_func=internal_map) + + def cache(self) -> 'StateMonadMixin': + def internal_map(state: State) -> Tuple[State, V]: + if self in state.cache: + return state, state.cache[self] + + state, val = self.apply(state) + + state = dataclasses.replace( + state, + cache=state.cache | {self: val}, + ) + + return state, val + + return dataclasses.replace(self, apply_func=internal_map) + + def apply(self, state: State) -> Tuple[State, U]: + return self.apply_func(state) + diff --git a/polymatrix/statemonad/mixins/__init__.py b/polymatrix/statemonad/mixins/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/polymatrix/statemonad/mixins/statemixin.py b/polymatrix/statemonad/mixins/statemixin.py deleted file mode 100644 index 6e2855b..0000000 --- a/polymatrix/statemonad/mixins/statemixin.py +++ /dev/null @@ -1,8 +0,0 @@ -import abc - - -class StateCacheMixin(abc.ABC): - @property - @abc.abstractmethod - def cache(self) -> dict: - ... diff --git a/polymatrix/statemonad/mixins/statemonadmixin.py b/polymatrix/statemonad/mixins/statemonadmixin.py deleted file mode 100644 index c367708..0000000 --- a/polymatrix/statemonad/mixins/statemonadmixin.py +++ /dev/null @@ -1,63 +0,0 @@ -import abc -import dataclasses -from typing import Callable, Tuple, TypeVar, Generic -import typing - -from polymatrix.statemonad.mixins.statemixin import StateCacheMixin - -State = TypeVar('State', bound=StateCacheMixin) -U = TypeVar('U') -V = TypeVar('V') - - -class StateMonadMixin( - Generic[State, U], - abc.ABC, -): - @property - @abc.abstractmethod - def apply_func(self) -> typing.Callable[[State], tuple[State, U]]: - ... - - def map(self, fn: Callable[[U], V]) -> 'StateMonadMixin[State, V]': - - def internal_map(state: State) -> Tuple[State, U]: - n_state, val = self.apply(state) - return n_state, fn(val) - - return dataclasses.replace(self, apply_func=internal_map) - - def flat_map(self, fn: Callable[[U], 'StateMonadMixin']) -> 'StateMonadMixin[State, V]': - - def internal_map(state: State) -> Tuple[State, V]: - n_state, val = self.apply(state) - return fn(val).apply(n_state) - - return dataclasses.replace(self, apply_func=internal_map) - - def zip(self, other: 'StateMonadMixin') -> 'StateMonadMixin': - def internal_map(state: State) -> Tuple[State, V]: - state, val1 = self.apply(state) - state, val2 = other.apply(state) - return state, (val1, val2) - - return dataclasses.replace(self, apply_func=internal_map) - - def cache(self) -> 'StateMonadMixin': - def internal_map(state: State) -> Tuple[State, V]: - if self in state.cache: - return state, state.cache[self] - - state, val = self.apply(state) - - state = dataclasses.replace( - state, - cache=state.cache | {self: val}, - ) - - return state, val - - return dataclasses.replace(self, apply_func=internal_map) - - def apply(self, state: State) -> Tuple[State, U]: - return self.apply_func(state) diff --git a/polymatrix/statemonad/statemonad.py b/polymatrix/statemonad/statemonad.py deleted file mode 100644 index 49ab1fa..0000000 --- a/polymatrix/statemonad/statemonad.py +++ /dev/null @@ -1,4 +0,0 @@ -from polymatrix.statemonad.mixins.statemonadmixin import StateMonadMixin - -class StateMonad(StateMonadMixin): - pass -- cgit v1.2.1