diff options
Diffstat (limited to '')
-rw-r--r-- | mdpoly/abc.py | 2 | ||||
-rw-r--r-- | mdpoly/algebra.py | 2 | ||||
-rw-r--r-- | mdpoly/index.py (renamed from mdpoly/types.py) | 5 | ||||
-rw-r--r-- | mdpoly/leaves.py | 2 | ||||
-rw-r--r-- | mdpoly/representations.py | 2 | ||||
-rw-r--r-- | mdpoly/state.py | 4 | ||||
-rw-r--r-- | mdpoly/util.py | 6 |
7 files changed, 12 insertions, 11 deletions
diff --git a/mdpoly/abc.py b/mdpoly/abc.py index 811910b..0a2e783 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -1,6 +1,6 @@ """ Abstract Base Classes of MDPoly """ -from .types import Number, Shape, MatrixIndex, PolyIndex +from .index import Number, Shape, MatrixIndex, PolyIndex from .constants import NUMERICS_EPS from .util import iszero diff --git a/mdpoly/algebra.py b/mdpoly/algebra.py index abd15d5..a07c4d6 100644 --- a/mdpoly/algebra.py +++ b/mdpoly/algebra.py @@ -4,7 +4,7 @@ from .abc import Leaf, Expr, Repr from .leaves import Nothing, Const, Param, Var from .errors import AlgebraicError, InvalidShape from .state import State -from .types import Shape, MatrixIndex, PolyIndex +from .index import Shape, MatrixIndex, PolyIndex from .representations import HasRepr from typing import Protocol, Self, Any, runtime_checkable diff --git a/mdpoly/types.py b/mdpoly/index.py index 9e4ecb7..2837a46 100644 --- a/mdpoly/types.py +++ b/mdpoly/index.py @@ -13,11 +13,6 @@ if TYPE_CHECKING: Number = int | float -def filtertype(t: type, seq: Iterable): - """ Filter based on type. """ - yield from filter(lambda x: isinstance(x, t), seq) - - class Shape(NamedTuple): """ Describes the shape of a mathematical object. """ rows: int diff --git a/mdpoly/leaves.py b/mdpoly/leaves.py index dbfd332..af43435 100644 --- a/mdpoly/leaves.py +++ b/mdpoly/leaves.py @@ -1,5 +1,5 @@ from .abc import Leaf, Repr -from .types import Number, Shape, MatrixIndex, PolyVarIndex, PolyIndex +from .index import Number, Shape, MatrixIndex, PolyVarIndex, PolyIndex from .state import State from .errors import MissingParameters from .representations import HasRepr diff --git a/mdpoly/representations.py b/mdpoly/representations.py index b7943ad..b541c3e 100644 --- a/mdpoly/representations.py +++ b/mdpoly/representations.py @@ -1,5 +1,5 @@ from .abc import Repr -from .types import Number, Shape, MatrixIndex, PolyIndex +from .index import Number, Shape, MatrixIndex, PolyIndex from .state import State from typing import Protocol, Iterable diff --git a/mdpoly/state.py b/mdpoly/state.py index 70fca24..e0a6bc5 100644 --- a/mdpoly/state.py +++ b/mdpoly/state.py @@ -2,10 +2,10 @@ from __future__ import annotations from typing import TYPE_CHECKING from dataclasses import dataclass, field -from .types import PolyVarIndex +from .index import PolyVarIndex if TYPE_CHECKING: - from .types import Number + from .index import Number from .leaves import Var, Param, Const diff --git a/mdpoly/util.py b/mdpoly/util.py index 937e7d4..c7f3b51 100644 --- a/mdpoly/util.py +++ b/mdpoly/util.py @@ -1,6 +1,7 @@ from .constants import NUMERICS_EPS from itertools import tee, filterfalse +from typing import Iterable def partition(pred, iterable): """Partition entries into false entries and true entries. @@ -30,3 +31,8 @@ def iszero(x: float, eps: float =NUMERICS_EPS) -> bool: ``eps`` or the default value at :py:data:`mdpoly.constants.NUMERICS_EPS`. """ return isclose(x, 0.) + + +def filtertype(t: type, seq: Iterable): + """ Filter based on type. """ + yield from filter(lambda x: isinstance(x, t), seq) |