We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
torch.Module.__getattr__ used to be hinted as returning Any, now it is more strictly typed as returning either another Module or a Tensor.
torch.Module.__getattr__
In some of our code we will thus need annotations that an attribute defined by register_buffer is a Tensor. some examples include:
src/mrpro/utils/slice_profiles.py:65: error: Unsupported operand types for ** (Module and "int") [operator] src/mrpro/utils/slice_profiles.py:106: error: Unsupported operand types for / ("Tensor" and Module) [operator] src/mrpro/utils/slice_profiles.py:107: error: Unsupported operand types for < ("int" and Module) [operator] src/mrpro/operators/LinearOperator.py:341: error: Unsupported operand types for @ ("Tensor" and Module) [operator] src/mrpro/operators/LinearOperator.py:341: error: Unsupported left operand type for @ (Module) [operator] src/mrpro/operators/LinearOperator.py:373: error: Unsupported left operand type for @ (Module) [operator] src/mrpro/operators/LinearOperator.py:376: error: Unsupported operand types for * ("Tensor" and Module) [operator] src/mrpro/operators/LinearOperator.py:376: error: Unsupported operand types for * ("complex" and Module) [operator] src/mrpro/operators/LinearOperator.py:396: error: Unsupported operand types for * ("Tensor" and Module) [operator] src/mrpro/operators/LinearOperator.py:396: error: Unsupported operand types for * ("complex" and Module) [operator] src/mrpro/operators/Functional.py:241: error: Unsupported operand types for * (Module and "Tensor") [operator] src/mrpro/operators/CartesianSamplingOp.py:125: error: Unsupported operand types for - ("int" and Module) [operator] src/mrpro/operators/functionals/L2NormSquared.py:41: error: Unsupported operand types for * (Module and "Tensor") [operator] src/mrpro/operators/functionals/L2NormSquared.py:41: error: Unsupported operand types for - ("Tensor" and Module) [operator] src/mrpro/operators/functionals/L2NormSquared.py:70: error: Unsupported operand types for * ("Tensor" and Module) [operator] src/mrpro/operators/functionals/L2NormSquared.py:102: error: Unsupported operand types for * ("Tensor" and Module) [operator] src/mrpro/operators/functionals/L2NormSquared.py:102: error: Unsupported operand types for * ("float" and Module) [operator] src/mrpro/operators/functionals/L1NormViewAsReal.py:74: error: Unsupported operand types for * (Module and "Tensor") [operator] src/mrpro/operators/functionals/L1Norm.py:38: error: Unsupported operand types for * (Module and "Tensor") [operator] src/mrpro/operators/functionals/L1Norm.py:65: error: Unsupported operand types for + ("Tensor" and Module) [operator] tests/operators/functionals/test_separablesum.py:17: error: Unsupported operand types for + ("Tensor" and Module) [operator] tests/operators/functionals/test_functionals.py:127: error: Unsupported operand types for + (Module and "Tensor") [operator] tests/operators/functionals/test_functionals.py:145: error: Unsupported operand types for * (Module and "Tensor") [operator] src/mrpro/operators/PCACompressionOp.py:60: error: Argument 1 to "tuple" has incompatible type "Size | Tensor | Module"; expected "Iterable[Any]" [arg-type] src/mrpro/operators/PCACompressionOp.py:82: error: Argument 1 to "tuple" has incompatible type "Size | Tensor | Module"; expected "Iterable[Any]" [arg-type] src/mrpro/operators/FiniteDifferenceOp.py:80: error: Argument 2 to "filter_separable" has incompatible type "tuple[Tensor | Module]"; expected "Sequence[Tensor]" [arg-type] src/mrpro/operators/FiniteDifferenceOp.py:112: error: Argument 1 to "flip" has incompatible type "Tensor | Module"; expected "Tensor" [arg-type] src/mrpro/operators/CartesianSamplingOp.py:125: error: Argument 1 to "unsqueeze_left" has incompatible type "Tensor | Module"; expected "Tensor" [arg-type] tests/data/test_movedatamixin.py:114: error: Item "Tensor" of "Tensor | Module" has no attribute "weight" [union-attr] tests/data/test_movedatamixin.py:207: error: Item "Tensor" of "Tensor | Module" has no attribute "weight" [union-attr] src/mrpro/operators/LinearOperator.py:396: error: Incompatible return value type (got "Tensor | complex", expected "LinearOperator") [return-value] src/mrpro/operators/LinearOperator.py:418: error: Incompatible return value type (got "Tensor | Module", expected "LinearOperator") [return-value]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
torch.Module.__getattr__
used to be hinted as returning Any, now it is more strictly typed as returning either another Module or a Tensor.In some of our code we will thus need annotations that an attribute defined by register_buffer is a Tensor.
some examples include:
The text was updated successfully, but these errors were encountered: