From aaf0925712c1d0ca57b8e2bb52103824b911bbf3 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Wed, 6 Mar 2024 12:08:23 +0100 Subject: Move algebra into abc.Expr since shape is already there, might as well simplify --- mdpoly/abc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 @@ -25,6 +32,10 @@ class Expr(ABC): @abstractmethod def right(self) -> Self | Leaf: ... + @property + @abstractmethod + def algebra(self) -> Algebra: ... + @property @abstractmethod def shape(self) -> Shape: -- cgit v1.2.1