diff options
author | Nao Pross <np@0hm.ch> | 2024-03-07 16:16:37 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-03-07 16:16:37 +0100 |
commit | 216f46a44cdc833b5efc2574ece935c589dd0836 (patch) | |
tree | c732dc1dfebeebe2113c2b48e7064908b18c8bf0 | |
parent | Make new constructors Variable.from_powers and Variable.make_combinations (diff) | |
download | mdpoly-216f46a44cdc833b5efc2574ece935c589dd0836.tar.gz mdpoly-216f46a44cdc833b5efc2574ece935c589dd0836.zip |
Minor changes
-rw-r--r-- | mdpoly/__init__.py | 9 | ||||
-rw-r--r-- | 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 |