diff options
author | Nao Pross <np@0hm.ch> | 2024-03-06 12:08:23 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-06 12:08:23 +0100 |
commit | aaf0925712c1d0ca57b8e2bb52103824b911bbf3 (patch) | |
tree | 1433fc4afad51983afa8723818746daff88a3ff8 | |
parent | Rename mdpoly.types to mdpoly.index as it only contains index types (diff) | |
download | mdpoly-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.py | 13 |
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* |