From e32b3e8e3d8ca71dc460bfd0a5fd8238b1c0b410 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 18 Mar 2024 11:13:49 +0100 Subject: Fix imports --- mdpoly/__init__.py | 2 +- mdpoly/abc.py | 3 ++- mdpoly/expressions/matrix.py | 3 --- mdpoly/expressions/poly.py | 5 +++-- mdpoly/representations.py | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mdpoly/__init__.py b/mdpoly/__init__.py index 1ac17a5..c341cb1 100644 --- a/mdpoly/__init__.py +++ b/mdpoly/__init__.py @@ -105,7 +105,7 @@ TODO: data structure(s) that represent the polynomial # internal classes imported with underscore because # they should not be exposed to the end users -from .abc import (Shape as _Shape) +from .index import (Shape as _Shape) from .expressions.poly import (PolyConst as _PolyConst, PolyVar as _PolyVar, PolyParam as _PolyParam) from .expressions.matrix import (MatConst as _MatConst, MatVar as _MatVar, MatParam as _MatParam) diff --git a/mdpoly/abc.py b/mdpoly/abc.py index cd90f85..657adf7 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -11,10 +11,11 @@ from dataclassabc import dataclassabc from .constants import NUMERICS_EPS from .errors import AlgebraicError +from .index import Shape from .util import iszero if TYPE_CHECKING: - from .index import Number, Shape, MatrixIndex, PolyIndex + from .index import Number, MatrixIndex, PolyIndex from .state import State diff --git a/mdpoly/expressions/matrix.py b/mdpoly/expressions/matrix.py index 65f86c2..cd38383 100644 --- a/mdpoly/expressions/matrix.py +++ b/mdpoly/expressions/matrix.py @@ -9,8 +9,6 @@ from ..abc import Expr, Var, Const, Param, Algebra from ..index import MatrixIndex, PolyIndex, PolyVarIndex from ..errors import MissingParameters -from .. import operations - if TYPE_CHECKING: from ..abc import ReprT from ..index import Shape, Number @@ -124,7 +122,6 @@ class MatConst(Const, MatrixExpr): return self.name - T = TypeVar("T", bound=Var) @dataclassabc(frozen=True) diff --git a/mdpoly/expressions/poly.py b/mdpoly/expressions/poly.py index 3fe83ca..6e0308b 100644 --- a/mdpoly/expressions/poly.py +++ b/mdpoly/expressions/poly.py @@ -1,10 +1,11 @@ from __future__ import annotations from typing import TYPE_CHECKING -from typing import Type, Iterable +from typing import Type, Iterable, cast from functools import reduce from itertools import chain, combinations_with_replacement from dataclassabc import dataclassabc +from operator import mul as opmul from ..abc import Expr, Var, Const, Param, Algebra, ReprT from ..index import Shape, MatrixIndex, PolyIndex, PolyVarIndex, Number @@ -62,7 +63,7 @@ class PolyRingExpr(Expr): # Ignore typecheck because dataclassabc has no typing stub vars_and_const = chain(variables, (PolyConst(1),)) # type: ignore[call-arg] for comb in combinations_with_replacement(vars_and_const, max_degree): - yield cast(PolyRingExpr, reduce(operator.mul, comb)) + yield cast(PolyRingExpr, reduce(opmul, comb)) # --- Operator Overloading --- diff --git a/mdpoly/representations.py b/mdpoly/representations.py index 32c75d7..1efe286 100644 --- a/mdpoly/representations.py +++ b/mdpoly/representations.py @@ -4,10 +4,10 @@ from typing import TYPE_CHECKING from typing import Iterable import numpy as np +from .abc import Repr + if TYPE_CHECKING: import numpy.typing as npt - - from .abc import Repr from .index import Number, Shape, MatrixIndex, PolyIndex -- cgit v1.2.1