Skip to content

Commit 50a1c6e

Browse files
authored
Make transform return the same type as input (#1182)
1 parent b5a123f commit 50a1c6e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/torchio/transforms/transform.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Optional
1010
from typing import Sequence
1111
from typing import Tuple
12+
from typing import TypeVar
1213
from typing import Union
1314

1415
import numpy as np
@@ -49,6 +50,8 @@
4950
'Superior',
5051
)
5152

53+
InputType = TypeVar('InputType', bound=TypeTransformInput)
54+
5255

5356
class Transform(ABC):
5457
"""Abstract class for all TorchIO transforms.
@@ -127,8 +130,8 @@ def __init__(
127130

128131
def __call__(
129132
self,
130-
data: TypeTransformInput,
131-
) -> TypeTransformInput:
133+
data: InputType,
134+
) -> InputType:
132135
"""Transform data and return a result of the same type.
133136
134137
Args:

0 commit comments

Comments
 (0)