aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2024-03-06 12:08:23 +0100
committerNao Pross <np@0hm.ch>2024-03-06 12:08:23 +0100
commitaaf0925712c1d0ca57b8e2bb52103824b911bbf3 (patch)
tree1433fc4afad51983afa8723818746daff88a3ff8
parentRename mdpoly.types to mdpoly.index as it only contains index types (diff)
downloadmdpoly-aaf0925712c1d0ca57b8e2bb52103824b911bbf3.tar.gz
mdpoly-aaf0925712c1d0ca57b8e2bb52103824b911bbf3.zip
Move algebra into abc.Expr
since shape is already there, might as well simplify
Diffstat (limited to '')
-rw-r--r--mdpoly/abc.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/mdpoly/abc.py b/mdpoly/abc.py
index 0a2e783..6637db5 100644
--- a/mdpoly/abc.py
+++ b/mdpoly/abc.py
@@ -4,10 +4,17 @@ from .index import Number, Shape, MatrixIndex, PolyIndex
from .constants import NUMERICS_EPS
from .util import iszero
-from typing import Self, Iterable, Sequence, Protocol
+from typing import Self, Iterable, Sequence
+from enum import Enum, auto
from abc import ABC, abstractmethod
+class Algebra(Enum):
+ """ Types of algebras. """
+ poly_ring = auto()
+ matrix_ring = auto()
+
+
class Leaf(ABC):
""" Leaf of the binary tree. """
name: str
@@ -27,6 +34,10 @@ class Expr(ABC):
@property
@abstractmethod
+ def algebra(self) -> Algebra: ...
+
+ @property
+ @abstractmethod
def shape(self) -> Shape:
""" Computes the shape of the expression. This method is also used to
check if the operation described by *Expr* can be perfomed with *left*