From 216f46a44cdc833b5efc2574ece935c589dd0836 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 7 Mar 2024 16:16:37 +0100 Subject: Minor changes --- mdpoly/__init__.py | 9 +++++---- mdpoly/abc.py | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mdpoly/__init__.py b/mdpoly/__init__.py index 0c1576d..2c007d0 100644 --- a/mdpoly/__init__.py +++ b/mdpoly/__init__.py @@ -30,7 +30,7 @@ State = _State # ┗┻┛╹┗╸╹ ╹╹ ╹ ┗━╸╹┗╸┗━┛ # FIXME: move out of this file -class _FromHelpers: +class FromHelpers: @classmethod def from_names(cls, comma_separated_names: str, strip: bool =True) -> Iterable[Self]: """ Generate scalar variables from comma separated list of names """ @@ -39,15 +39,16 @@ class _FromHelpers: names = map(str.strip, names) yield from map(cls, names) -class Constant(_Const, _PolyRingExpr, _FromHelpers): + +class Constant(_Const, _PolyRingExpr, FromHelpers): """ Constant values """ -class Variable(_Var, _PolyRingExpr, _FromHelpers): +class Variable(_Var, _PolyRingExpr, FromHelpers): """ Polynomial Variable """ -class Parameter(_Param, _PolyRingExpr): +class Parameter(_Param, _PolyRingExpr, FromHelpers): """ Parameter that can be substituted """ diff --git a/mdpoly/abc.py b/mdpoly/abc.py index 8783262..d7578ec 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -84,7 +84,7 @@ class Expr(ABC): def __iter__(self) -> Iterable[Expr]: yield from self.children() - # --- Methods --- + # --- Methods for polynomial expression --- @abstractmethod def to_repr(self, repr_type: type, state: State) -> tuple[Repr, State]: @@ -95,6 +95,8 @@ class Expr(ABC): See also :py:class:`mdpoly.state.State`. """ + # --- Methods for tree data structure --- + def children(self) -> Sequence[Expr]: """ Iterate over the two nodes """ return self.left, self.right -- cgit v1.2.1