Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vfdev-5 committed Aug 30, 2023
1 parent 74f4a64 commit ca8be8a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions torchvision/transforms/v2/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@
from torchvision.transforms.v2.functional._utils import _FillType, _FillTypeJIT


def _setup_number_or_seq(
arg: Union[int, float, Sequence[Union[int, float]]], name: str, req_size: int = 2
) -> Sequence[float]:
def _setup_number_or_seq(arg: Union[int, float, Sequence[Union[int, float]]], name: str) -> Sequence[float]:
if not isinstance(arg, (int, float, Sequence)):
raise TypeError(f"{name} should be a number or a sequence of numbers. Got {type(arg)}")
if isinstance(arg, Sequence) and len(arg) not in (1, req_size):
raise ValueError(f"If {name} is a sequence its length should be 1 or {req_size}. Got {len(arg)}")
raise ValueError(f"If {name} is a sequence its length should be 1 or 2. Got {len(arg)}")
if isinstance(arg, Sequence):
for element in arg:
if not isinstance(element, (int, float)):
raise ValueError(f"{name} should be a sequence of numbers. Got {type(element)}")

if isinstance(arg, (int, float)):
arg = [float(arg), float(arg)]
if isinstance(arg, (list, tuple)):
if isinstance(arg, Sequence):
if len(arg) == 1:
arg = [float(arg[0]), float(arg[0])]
else:
Expand Down

0 comments on commit ca8be8a

Please sign in to comment.