aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-18 11:49:05 +0100
committerNao Pross <np@0hm.ch>2024-03-18 11:49:14 +0100
commitff17a047857d888cad9e8f65178c162b56aeb908 (patch)
tree12ca6262d0117725108e2ab46b241dcca4131109
parentFix Leaf.left (diff)
downloadmdpoly-ff17a047857d888cad9e8f65178c162b56aeb908.tar.gz
mdpoly-ff17a047857d888cad9e8f65178c162b56aeb908.zip
Rename PolyRingExpr to just PolyExpr
Diffstat (limited to '')
-rw-r--r--mdpoly/__init__.py2
-rw-r--r--mdpoly/expressions/poly.py20
-rw-r--r--mdpoly/operations/add.py6
-rw-r--r--mdpoly/operations/derivative.py6
-rw-r--r--mdpoly/operations/exp.py4
-rw-r--r--mdpoly/operations/mul.py4
6 files changed, 21 insertions, 21 deletions
diff --git a/mdpoly/__init__.py b/mdpoly/__init__.py
index c341cb1..8334d87 100644
--- a/mdpoly/__init__.py
+++ b/mdpoly/__init__.py
@@ -61,7 +61,7 @@ Expression
Within the code, we will often call something like :math:`x^2 + 1` and
*expression* (for example :py:class:`mdpoly.abc.Expr` or
-:py:class:`mdpoly.expressions.poly.PolyRingExpr`) instead of polynomial.
+:py:class:`mdpoly.expressions.poly.PolyExpr`) instead of polynomial.
Expressions are more general and can include any mathematical operation. Of
course in the end and expression should result in a polynomial.
diff --git a/mdpoly/expressions/poly.py b/mdpoly/expressions/poly.py
index 6e0308b..623e89e 100644
--- a/mdpoly/expressions/poly.py
+++ b/mdpoly/expressions/poly.py
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
from ..state import State
-class PolyRingExpr(Expr):
+class PolyExpr(Expr):
r""" Expression with the algebraic behaviour of a polynomial ring.
This is the algebra of :math:`\mathbb{R}[x_1, \ldots, x_n]`. Note that the
@@ -42,7 +42,7 @@ class PolyRingExpr(Expr):
# --- Helper methods for construction ---
@classmethod
- def from_powers(cls, variable: PolyRingExpr, exponents: Iterable[int]) -> PolyRingExpr:
+ def from_powers(cls, variable: PolyExpr, exponents: Iterable[int]) -> PolyExpr:
""" Given a variable, say :math:`x`, and a list of exponents ``[0, 3, 5]``
returns a polynomial :math:`x^5 + x^3 + 1`.
"""
@@ -54,7 +54,7 @@ class PolyRingExpr(Expr):
@classmethod
- def make_combinations(cls, variables: Iterable[PolyVar], max_degree: int) -> Iterable[PolyRingExpr]:
+ def make_combinations(cls, variables: Iterable[PolyVar], max_degree: int) -> Iterable[PolyExpr]:
""" Make combinations of terms.
For example given :math:`x, y` and *max_degree* of 2 generates
@@ -63,7 +63,7 @@ class PolyRingExpr(Expr):
# Ignore typecheck because dataclassabc has no typing stub
vars_and_const = chain(variables, (PolyConst(1),)) # type: ignore[call-arg]
for comb in combinations_with_replacement(vars_and_const, max_degree):
- yield cast(PolyRingExpr, reduce(opmul, comb))
+ yield cast(PolyExpr, reduce(opmul, comb))
# --- Operator Overloading ---
@@ -131,10 +131,10 @@ class PolyRingExpr(Expr):
@dataclassabc(frozen=True)
-class PolyVar(Var, PolyRingExpr):
+class PolyVar(Var, PolyExpr):
""" Variable TODO: desc """
name: str # overloads Leaf.name
- shape: Shape = Shape.scalar() # ovearloads PolyRingExpr.shape
+ shape: Shape = Shape.scalar() # ovearloads PolyExpr.shape
def to_repr(self, repr_type: Type[ReprT], state: State) -> tuple[ReprT, State]:
r = repr_type(self.shape)
@@ -144,11 +144,11 @@ class PolyVar(Var, PolyRingExpr):
@dataclassabc(frozen=True)
-class PolyConst(Const, PolyRingExpr):
+class PolyConst(Const, PolyExpr):
""" Constant TODO: desc """
value: Number # overloads Const.value
name: str = "" # overloads Leaf.name
- shape: Shape = Shape.scalar() # ovearloads PolyRingExpr.shape
+ shape: Shape = Shape.scalar() # ovearloads PolyExpr.shape
def to_repr(self, repr_type: Type[ReprT], state: State) -> tuple[ReprT, State]:
r = repr_type(self.shape)
@@ -157,10 +157,10 @@ class PolyConst(Const, PolyRingExpr):
@dataclassabc(frozen=True)
-class PolyParam(Param, PolyRingExpr):
+class PolyParam(Param, PolyExpr):
""" Polynomial parameter TODO: desc """
name: str # overloads Leaf.name
- shape: Shape = Shape.scalar() # overloads PolyRingExpr.shape
+ shape: Shape = Shape.scalar() # overloads PolyExpr.shape
def to_repr(self, repr_type: Type[ReprT], state: State) -> tuple[ReprT, State]:
if self not in state.parameters:
diff --git a/mdpoly/operations/add.py b/mdpoly/operations/add.py
index bf0c5a0..b0174ef 100644
--- a/mdpoly/operations/add.py
+++ b/mdpoly/operations/add.py
@@ -9,7 +9,7 @@ from ..errors import AlgebraicError
from ..expressions import BinaryOp, Reducible
from ..expressions.matrix import MatrixExpr
-from ..expressions.poly import PolyRingExpr
+from ..expressions.poly import PolyExpr
if TYPE_CHECKING:
from ..abc import ReprT
@@ -72,10 +72,10 @@ class MatSub(BinaryOp, MatrixExpr, Reducible):
@dataclassabc(eq=False)
-class PolyAdd(MatAdd, PolyRingExpr):
+class PolyAdd(MatAdd, PolyExpr):
...
@dataclassabc(eq=False)
-class PolySub(MatSub, PolyRingExpr):
+class PolySub(MatSub, PolyExpr):
...
diff --git a/mdpoly/operations/derivative.py b/mdpoly/operations/derivative.py
index 6e02b0e..9a74941 100644
--- a/mdpoly/operations/derivative.py
+++ b/mdpoly/operations/derivative.py
@@ -9,7 +9,7 @@ from ..errors import AlgebraicError
from ..index import Shape, MatrixIndex, PolyIndex
from ..expressions import UnaryOp
-from ..expressions.poly import PolyRingExpr, PolyVar
+from ..expressions.poly import PolyExpr, PolyVar
if TYPE_CHECKING:
from ..abc import ReprT
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
@dataclassabc(eq=False)
-class PolyPartialDiff(UnaryOp, PolyRingExpr):
+class PolyPartialDiff(UnaryOp, PolyExpr):
""" Partial differentiation of scalar polynomials. """
wrt: PolyVar
@@ -50,7 +50,7 @@ class PolyPartialDiff(UnaryOp, PolyRingExpr):
def __str__(self) -> str:
return f"(∂_{self.wrt} {self.inner})"
- def replace(self, old: PolyRingExpr, new: PolyRingExpr) -> Self:
+ def replace(self, old: PolyExpr, new: PolyExpr) -> Self:
""" Overloads :py:meth:`mdpoly.abc.Expr.replace` """
if self.wrt == old:
if not isinstance(new, PolyVar):
diff --git a/mdpoly/operations/exp.py b/mdpoly/operations/exp.py
index fbc67f5..177fd22 100644
--- a/mdpoly/operations/exp.py
+++ b/mdpoly/operations/exp.py
@@ -11,7 +11,7 @@ from ..errors import AlgebraicError
from ..expressions import BinaryOp, Reducible
from ..expressions.matrix import MatrixExpr
-from ..expression.poly import PolyRingExpr
+from ..expression.poly import PolyExpr
# TODO: implement matrix exponential, use caley-hamilton thm magic
@@ -22,7 +22,7 @@ class MatExp(BinaryOp, MatrixExpr, Reducible):
@dataclass(eq=False)
-class PolyExp(BinaryOp, PolyRingExpr, Reducible):
+class PolyExp(BinaryOp, PolyExpr, Reducible):
""" Exponentiation operator between scalar polynomials. """
@property # type: ignore[override]
diff --git a/mdpoly/operations/mul.py b/mdpoly/operations/mul.py
index a2a3cc4..2a8f749 100644
--- a/mdpoly/operations/mul.py
+++ b/mdpoly/operations/mul.py
@@ -12,7 +12,7 @@ from ..index import MatrixIndex, PolyIndex
from ..expressions import BinaryOp, Reducible
from ..expressions.matrix import MatrixExpr
-from ..expression.poly import PolyRingExpr
+from ..expression.poly import PolyExpr
if TYPE_CHECKING:
from ..abc import ReprT
@@ -157,7 +157,7 @@ class MatDotProd(BinaryOp, MatrixExpr, Reducible):
@dataclass(eq=False)
-class PolyMul(BinaryOp, PolyRingExpr):
+class PolyMul(BinaryOp, PolyExpr):
""" Multiplication operator between scalar polynomials. """
def to_repr(self, repr_type: Type[ReprT], state: State) -> tuple[ReprT, State]: