From d0ad4e4b6046745ef64e70b671e85ae1d5ceee67 Mon Sep 17 00:00:00 2001 From: Brendt Wohlberg Date: Wed, 6 Dec 2023 11:45:15 -0700 Subject: [PATCH] Resolve type checking issues --- scico/linop/_stack.py | 10 +++++----- scico/operator/_stack.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scico/linop/_stack.py b/scico/linop/_stack.py index f1586ae24..074eaafaa 100644 --- a/scico/linop/_stack.py +++ b/scico/linop/_stack.py @@ -11,7 +11,7 @@ import operator from functools import partial -from typing import List, Optional, Union +from typing import Optional, Sequence, Union import scico.numpy as snp from scico.numpy import Array, BlockArray @@ -48,7 +48,7 @@ class VerticalStack(VStack, LinearOperator): def __init__( self, - ops: List[LinearOperator], + ops: Sequence[LinearOperator], collapse_output: Optional[bool] = True, jit: bool = True, **kwargs, @@ -66,7 +66,7 @@ def __init__( super().__init__(ops=ops, collapse_output=collapse_output, jit=jit, **kwargs) def _adj(self, y: Union[Array, BlockArray]) -> Array: # type: ignore - return sum([op.adj(y_block) for y_block, op in zip(y, self.ops)]) + return sum([op.adj(y_block) for y_block, op in zip(y, self.ops)]) # type: ignore @partial(_wrap_add_sub, op=operator.add) def __add__(self, other): @@ -126,7 +126,7 @@ class DiagonalStack(DStack, LinearOperator): def __init__( self, - ops: List[LinearOperator], + ops: Sequence[LinearOperator], collapse_input: Optional[bool] = True, collapse_output: Optional[bool] = True, jit: bool = True, @@ -151,7 +151,7 @@ def __init__( ) def _adj(self, y: Union[Array, BlockArray]) -> Union[Array, BlockArray]: # type: ignore - result = tuple(op.T @ y_n for op, y_n in zip(self.ops, y)) + result = tuple(op.T @ y_n for op, y_n in zip(self.ops, y)) # type: ignore if self.collapse_input: return snp.stack(result) return snp.blockarray(result) diff --git a/scico/operator/_stack.py b/scico/operator/_stack.py index fb4135efc..232b55d00 100644 --- a/scico/operator/_stack.py +++ b/scico/operator/_stack.py @@ -9,7 +9,7 @@ from __future__ import annotations -from typing import List, Optional, Sequence, Tuple, Union +from typing import Optional, Sequence, Tuple, Union import numpy as np @@ -78,7 +78,7 @@ class VerticalStack(Operator): def __init__( self, - ops: List[Operator], + ops: Sequence[Operator], collapse_output: Optional[bool] = True, jit: bool = True, **kwargs, @@ -116,7 +116,7 @@ def __init__( ) @staticmethod - def check_if_stackable(ops: List[Operator]): + def check_if_stackable(ops: Sequence[Operator]): """Check that input ops are suitable for stack creation.""" if not isinstance(ops, (list, tuple)): raise ValueError("Expected a list of Operator.") @@ -227,7 +227,7 @@ class DiagonalStack(Operator): def __init__( self, - ops: List[Operator], + ops: Sequence[Operator], collapse_input: Optional[bool] = True, collapse_output: Optional[bool] = True, jit: bool = True,