aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-06 18:51:13 +0100
committerNao Pross <np@0hm.ch>2024-03-06 18:51:13 +0100
commit1574714f67d480bbdce3657fb1bba387c463db80 (patch)
treeeea2d9070a8f0d94462998babd23fbd8cc85a229
parentFix missing case for PolyIndex.differentiate (diff)
downloadmdpoly-1574714f67d480bbdce3657fb1bba387c463db80.tar.gz
mdpoly-1574714f67d480bbdce3657fb1bba387c463db80.zip
Fix out of date docstrings
Diffstat (limited to '')
-rw-r--r--mdpoly/algebra.py24
-rw-r--r--mdpoly/errors.py2
2 files changed, 13 insertions, 13 deletions
diff --git a/mdpoly/algebra.py b/mdpoly/algebra.py
index 117ad51..1efbabf 100644
--- a/mdpoly/algebra.py
+++ b/mdpoly/algebra.py
@@ -7,7 +7,7 @@ from .errors import AlgebraicError, InvalidShape
from .state import State
from .index import Shape, MatrixIndex, PolyIndex, Number
-from typing import cast, Protocol, Self, Sequence
+from typing import cast
from functools import reduce
from itertools import product
from abc import abstractmethod
@@ -74,7 +74,7 @@ class Reducible(Expr):
"""
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
- """ See :py:meth:`mdpoly.representations.HasRepr.to_repr` """
+ """ See :py:meth:`mdpoly.abc.Expr.to_repr`. """
return self.reduce().to_repr(repr_type, state)
@abstractmethod
@@ -160,7 +160,7 @@ class PolyAdd(BinaryOp, PolyRingExpr):
""" Addition operator between scalar polynomials. """
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
- """ See :py:meth:`mdpoly.HasRepr.to_repr`. """
+ """ See :py:meth:`mdpoly.abc.Expr.to_repr`. """
# Make a new empty representation
r = repr_type()
@@ -184,7 +184,7 @@ class PolySub(BinaryOp, PolyRingExpr, Reducible):
""" Subtraction operator between scalar polynomials. """
def reduce(self) -> Expr:
- """ See :py:meth:`mdpoly.algebra.ReducibleExpr.reduce`. """
+ """ See :py:meth:`mdpoly.algebra.Reducible.reduce`. """
return self.left + (-1 * self.right)
def __repr__(self) -> str:
@@ -195,7 +195,7 @@ class PolyMul(BinaryOp, PolyRingExpr):
""" Multiplication operator between scalar polynomials. """
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
- """ See :py:meth:`mdpoly.representations.HasRepr.to_repr`. """
+ """ See :py:meth:`mdpoly.abc.Expr.to_repr`. """
r = repr_type()
lrepr, state = self.left.to_repr(repr_type, state)
@@ -223,7 +223,7 @@ class PolyMul(BinaryOp, PolyRingExpr):
class PolyExp(BinaryOp, PolyRingExpr, Reducible):
""" Generic exponentiation (no type check). """
- @property
+ @property # type: ignore[override]
def right(self) -> Const: # type: ignore[override]
if not isinstance(super().right, Const):
raise AlgebraicError(f"Cannot raise {self.left} to {self.right} because"
@@ -238,10 +238,10 @@ class PolyExp(BinaryOp, PolyRingExpr, Reducible):
BinaryOp.right.fset(self, right) # type: ignore
def reduce(self) -> Expr:
- """ See :py:meth:`mdpoly.algebra.ReducibleExpr.reduce`. """
+ """ See :py:meth:`mdpoly.algebra.Reducible.reduce`. """
var = self.left
if not isinstance(self.right.value, int):
- raise NotImplementedError
+ raise NotImplementedError("Cannot raise to non-integer powers (yet).")
ntimes = self.right.value - 1
return reduce(operator.mul, (var for _ in range(ntimes)), var)
@@ -263,9 +263,9 @@ class PolyPartialDiff(UnaryOp, PolyRingExpr):
return self.inner.shape
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
- """ See :py:meth:`mdpoly.representations.HasRepr.to_repr`. """
+ """ See :py:meth:`mdpoly.abc.Expr.to_repr`. """
r = repr_type()
- lrepr, state = self.left.to_repr(repr_type, state)
+ lrepr, state = self.inner.to_repr(repr_type, state)
entry = MatrixIndex.scalar()
wrt = state.index(self.wrt)
@@ -366,7 +366,7 @@ class MatAdd(BinaryOp, PolyRingExpr):
""" Addition operator between matrices. """
def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]:
- """ See :py:meth:`mdpoly.representations.HasRepr.to_repr`. """
+ """ See :py:meth:`mdpoly.abc.Expr.to_repr`. """
# Make a new empty representation
r = repr_type()
@@ -390,7 +390,7 @@ class MatSub(BinaryOp, PolyRingExpr, Reducible):
""" Subtraction operator between matrices. """
def reduce(self) -> Expr:
- """ See :py:meth:`mdpoly.algebra.ReducibleExpr.reduce`. """
+ """ See :py:meth:`mdpoly.algebra.Reducible.reduce`. """
return self.left + (-1 * self.right)
def __repr__(self) -> str:
diff --git a/mdpoly/errors.py b/mdpoly/errors.py
index 152d6df..85432b8 100644
--- a/mdpoly/errors.py
+++ b/mdpoly/errors.py
@@ -1,7 +1,7 @@
class AlgebraicError(Exception):
""" This is raised whenever an invalid mathematical operation is performed.
- See also :py:mod:`mdpoly.algebra` and :py:class:`mdpoly.algebra.AlgebraicStructure`
+ See also :py:mod:`mdpoly.algebra`.
"""
class InvalidShape(Exception):