diff options
71 files changed, 151 insertions, 148 deletions
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/polymatriximpl.py b/polymatrix/polymatrix/impl.py index cfca663..f44dc9c 100644 --- a/polymatrix/polymatrix/impl/polymatriximpl.py +++ b/polymatrix/polymatrix/impl.py @@ -1,5 +1,6 @@ import dataclassabc -from polymatrix.polymatrix.polymatrix import PolyMatrix + +from polymatrix.polymatrix.abc import PolyMatrix @dataclassabc.dataclassabc(frozen=True) diff --git a/polymatrix/polymatrix/impl/__init__.py b/polymatrix/polymatrix/impl/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/polymatrix/polymatrix/impl/__init__.py +++ /dev/null diff --git a/polymatrix/polymatrix/init/initpolymatrix.py b/polymatrix/polymatrix/init.py index 412adfb..7f0b60f 100644 --- a/polymatrix/polymatrix/init/initpolymatrix.py +++ b/polymatrix/polymatrix/init.py @@ -1,4 +1,4 @@ -from polymatrix.polymatrix.impl.polymatriximpl import PolyMatrixImpl +from polymatrix.polymatrix.impl import PolyMatrixImpl def init_poly_matrix( diff --git a/polymatrix/polymatrix/init/__init__.py b/polymatrix/polymatrix/init/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/polymatrix/polymatrix/init/__init__.py +++ /dev/null diff --git a/polymatrix/polymatrix/mixins/polymatrixmixin.py b/polymatrix/polymatrix/mixins.py index e67a6fa..a097615 100644 --- a/polymatrix/polymatrix/mixins/polymatrixmixin.py +++ b/polymatrix/polymatrix/mixins.py @@ -20,3 +20,18 @@ class PolyMatrixMixin(abc.ABC): @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 --- a/polymatrix/polymatrix/mixins/__init__.py +++ /dev/null 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/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/statemonadimpl.py b/polymatrix/statemonad/impl.py index 6b9270a..4bffb5d 100644 --- a/polymatrix/statemonad/impl/statemonadimpl.py +++ b/polymatrix/statemonad/impl.py @@ -1,7 +1,8 @@ +from typing import Callable import dataclassabc -from polymatrix.statemonad.statemonad import StateMonad -from typing import Callable +from polymatrix.statemonad.abc import StateMonad + @dataclassabc.dataclassabc(frozen=True) class StateMonadImpl(StateMonad): diff --git a/polymatrix/statemonad/impl/__init__.py b/polymatrix/statemonad/impl/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/polymatrix/statemonad/impl/__init__.py +++ /dev/null diff --git a/polymatrix/statemonad/init/initstatemonad.py b/polymatrix/statemonad/init.py index 7d269f3..7ef47cc 100644 --- a/polymatrix/statemonad/init/initstatemonad.py +++ b/polymatrix/statemonad/init.py @@ -1,5 +1,6 @@ from typing import Callable -from polymatrix.statemonad.impl.statemonadimpl import StateMonadImpl + +from polymatrix.statemonad.impl import StateMonadImpl def init_state_monad( diff --git a/polymatrix/statemonad/init/__init__.py b/polymatrix/statemonad/init/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/polymatrix/statemonad/init/__init__.py +++ /dev/null diff --git a/polymatrix/statemonad/mixins/statemonadmixin.py b/polymatrix/statemonad/mixins.py index c367708..1a13440 100644 --- a/polymatrix/statemonad/mixins/statemonadmixin.py +++ b/polymatrix/statemonad/mixins.py @@ -1,9 +1,14 @@ import abc import dataclasses from typing import Callable, Tuple, TypeVar, Generic -import typing -from polymatrix.statemonad.mixins.statemixin import StateCacheMixin + +class StateCacheMixin(abc.ABC): + @property + @abc.abstractmethod + def cache(self) -> dict: + ... + State = TypeVar('State', bound=StateCacheMixin) U = TypeVar('U') @@ -16,7 +21,7 @@ class StateMonadMixin( ): @property @abc.abstractmethod - def apply_func(self) -> typing.Callable[[State], tuple[State, U]]: + def apply_func(self) -> Callable[[State], tuple[State, U]]: ... def map(self, fn: Callable[[U], V]) -> 'StateMonadMixin[State, V]': @@ -61,3 +66,4 @@ class StateMonadMixin( 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 --- a/polymatrix/statemonad/mixins/__init__.py +++ /dev/null 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/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 |