summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-05-12 15:29:51 +0200
committerNao Pross <np@0hm.ch>2024-05-12 15:29:51 +0200
commit89e4a509556525b64c699498c5e488a9109cf512 (patch)
tree406693e31882c14de79c277aa5b718ebe03d1a6e
parentCollapse StateMonad into single class (diff)
downloadpolymatrix-89e4a509556525b64c699498c5e488a9109cf512.tar.gz
polymatrix-89e4a509556525b64c699498c5e488a9109cf512.zip
Collapse polymatrix.variable module into a single file
Diffstat (limited to '')
-rw-r--r--polymatrix/expression/expression.py2
-rw-r--r--polymatrix/expression/mixins/fromsympyexprmixin.py2
-rw-r--r--polymatrix/expression/mixins/parametrizeexprmixin.py2
-rw-r--r--polymatrix/expression/mixins/variablemixin.py2
-rw-r--r--polymatrix/expressionstate.py2
-rw-r--r--polymatrix/variable.py23
-rw-r--r--polymatrix/variable/__init__.py0
-rw-r--r--polymatrix/variable/abc.py13
-rw-r--r--polymatrix/variable/impl.py8
-rw-r--r--polymatrix/variable/init.py5
10 files changed, 28 insertions, 31 deletions
diff --git a/polymatrix/expression/expression.py b/polymatrix/expression/expression.py
index 2e7cf11..94492ef 100644
--- a/polymatrix/expression/expression.py
+++ b/polymatrix/expression/expression.py
@@ -15,7 +15,7 @@ from polymatrix.expression.mixins.variablemixin import VariableMixin
from polymatrix.expressionstate import ExpressionState
from polymatrix.polymatrix.abc import PolyMatrix
from polymatrix.utils.getstacklines import get_stack_lines
-from polymatrix.variable.abc import Variable
+from polymatrix.variable import Variable
from polymatrix.expression.op import (
diff,
diff --git a/polymatrix/expression/mixins/fromsympyexprmixin.py b/polymatrix/expression/mixins/fromsympyexprmixin.py
index 6d5446a..ec28e09 100644
--- a/polymatrix/expression/mixins/fromsympyexprmixin.py
+++ b/polymatrix/expression/mixins/fromsympyexprmixin.py
@@ -10,7 +10,7 @@ from polymatrix.expressionstate import ExpressionState
from polymatrix.polymatrix.abc import PolyMatrix
from polymatrix.polymatrix.init import init_poly_matrix
from polymatrix.polymatrix.index import PolyMatrixDict, PolyDict, MonomialIndex, VariableIndex
-from polymatrix.variable.init import init_variable
+from polymatrix.variable import init_variable
class FromSympyExprMixin(ExpressionBaseMixin):
diff --git a/polymatrix/expression/mixins/parametrizeexprmixin.py b/polymatrix/expression/mixins/parametrizeexprmixin.py
index 5ffecf3..0676cea 100644
--- a/polymatrix/expression/mixins/parametrizeexprmixin.py
+++ b/polymatrix/expression/mixins/parametrizeexprmixin.py
@@ -8,7 +8,7 @@ from polymatrix.expressionstate import ExpressionState
from polymatrix.polymatrix.index import PolyMatrixDict, MatrixIndex, PolyDict, MonomialIndex, VariableIndex
from polymatrix.polymatrix.init import init_poly_matrix
from polymatrix.polymatrix.mixins import PolyMatrixMixin
-from polymatrix.variable.init import init_variable
+from polymatrix.variable import init_variable
class ParametrizeExprMixin(ExpressionBaseMixin):
diff --git a/polymatrix/expression/mixins/variablemixin.py b/polymatrix/expression/mixins/variablemixin.py
index fe8ad80..8bc8b94 100644
--- a/polymatrix/expression/mixins/variablemixin.py
+++ b/polymatrix/expression/mixins/variablemixin.py
@@ -8,7 +8,7 @@ from polymatrix.expressionstate import ExpressionState
from polymatrix.expression.mixins.expressionbasemixin import ExpressionBaseMixin
from polymatrix.polymatrix.init import init_poly_matrix
from polymatrix.polymatrix.index import PolyMatrixDict, PolyDict, MonomialIndex, VariableIndex
-from polymatrix.variable.abc import Variable
+from polymatrix.variable import Variable
class VariableMixin(ExpressionBaseMixin, Variable):
diff --git a/polymatrix/expressionstate.py b/polymatrix/expressionstate.py
index 7d0eb26..90cb4a9 100644
--- a/polymatrix/expressionstate.py
+++ b/polymatrix/expressionstate.py
@@ -6,7 +6,7 @@ from math import prod
from dataclassabc import dataclassabc
from dataclasses import replace
-from polymatrix.variable.abc import Variable
+from polymatrix.variable import Variable
from polymatrix.utils.deprecation import deprecated
from polymatrix.polymatrix.index import MonomialIndex, VariableIndex
diff --git a/polymatrix/variable.py b/polymatrix/variable.py
new file mode 100644
index 0000000..e320313
--- /dev/null
+++ b/polymatrix/variable.py
@@ -0,0 +1,23 @@
+from abc import ABC, abstractmethod
+from dataclassabc import dataclassabc
+
+class Variable(ABC):
+ @property
+ @abstractmethod
+ def name(self) -> str:
+ """ Name of the variable. """
+
+ @property
+ @abstractmethod
+ def shape(self) -> tuple[int, int]:
+ """ Shape of the variable. """
+
+# FIXME: there is a class with the same name in expression.impl
+@dataclassabc(frozen=True)
+class VariableImpl(Variable):
+ name: str
+ shape: tuple[int, int]
+
+
+def init_variable(name: str, shape: tuple[int, int]) -> Variable:
+ return VariableImpl(name, shape)
diff --git a/polymatrix/variable/__init__.py b/polymatrix/variable/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/polymatrix/variable/__init__.py
+++ /dev/null
diff --git a/polymatrix/variable/abc.py b/polymatrix/variable/abc.py
deleted file mode 100644
index 70ad8de..0000000
--- a/polymatrix/variable/abc.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from abc import ABC, abstractmethod
-
-class Variable(ABC):
- @property
- @abstractmethod
- def name(self) -> str:
- """ Name of the variable. """
-
- @property
- @abstractmethod
- def shape(self) -> tuple[int, int]:
- """ Shape of the variable. """
-
diff --git a/polymatrix/variable/impl.py b/polymatrix/variable/impl.py
deleted file mode 100644
index 47e2041..0000000
--- a/polymatrix/variable/impl.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from dataclassabc import dataclassabc
-
-from .abc import Variable
-
-@dataclassabc(frozen=True)
-class VariableImpl(Variable):
- name: str
- shape: tuple[int, int]
diff --git a/polymatrix/variable/init.py b/polymatrix/variable/init.py
deleted file mode 100644
index 5583c31..0000000
--- a/polymatrix/variable/init.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from .abc import Variable
-from .impl import VariableImpl
-
-def init_variable(name: str, shape: tuple[int, int]) -> Variable:
- return VariableImpl(name, shape)