Skip to content

Commit

Permalink
Make the DecompResult type compatible with python3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkraemer committed Aug 29, 2024
1 parent 3dd9075 commit 8403d71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 9 additions & 1 deletion matfree/backend/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

# fmt: off
from collections.abc import Callable # noqa: F401
from typing import Any, Generic, Iterable, Sequence, Tuple, TypeVar # noqa: F401, UP035
from typing import ( # noqa: F401, UP035
Any,
Generic,
Iterable,
Sequence,
Tuple,
TypeVar,
Union,
)

from jax import Array # noqa: F401

Expand Down
14 changes: 11 additions & 3 deletions matfree/decomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
"""

from matfree.backend import containers, control_flow, func, linalg, np, tree_util
from matfree.backend.typing import Array, Callable
from matfree.backend.typing import Array, Callable, Union


class _DecompResult(containers.NamedTuple):
Q_tall: Array | tuple[Array, ...]
J_small: Array | tuple[Array, ...]
# If an algorithm returns a single Q, place it here.
# If it returns multiple Qs, stack them
# into a tuple and place them here.
Q_tall: Union[Array, tuple[Array, ...]]

# If an algorithm returns a materialized matrix,
# place it here. If it returns a sparse representation
# (e.g. two vectors representing diagonals), place it here
J_small: Union[Array, tuple[Array, ...]]

residual: Array
init_length_inv: Array

Expand Down

0 comments on commit 8403d71

Please sign in to comment.