diff --git a/test/test_transforms_v2_consistency.py b/test/test_transforms_v2_consistency.py index 125d7ec7a3f..43f17c9b15a 100644 --- a/test/test_transforms_v2_consistency.py +++ b/test/test_transforms_v2_consistency.py @@ -540,9 +540,12 @@ def test_signature_consistency(config): f"not. Please add a default value." ) - legacy_kinds = {name: param.kind for name, param in legacy_params.items()} - prototype_kinds = {name: prototype_params[name].kind for name in legacy_kinds.keys()} - assert prototype_kinds == legacy_kinds + legacy_signature = list(legacy_params.keys()) + # Since we made sure that we don't have any extra parameters without default above, we clamp the prototype signature + # to the same number of parameters as the legacy one + prototype_signature = list(prototype_params.keys())[: len(legacy_signature)] + + assert prototype_signature == legacy_signature def check_call_consistency( diff --git a/torchvision/transforms/v2/_container.py b/torchvision/transforms/v2/_container.py index 66da9c187c0..08282962ffd 100644 --- a/torchvision/transforms/v2/_container.py +++ b/torchvision/transforms/v2/_container.py @@ -124,8 +124,8 @@ class RandomChoice(Transform): def __init__( self, transforms: Sequence[Callable], - probabilities: Optional[List[float]] = None, p: Optional[List[float]] = None, + probabilities: Optional[List[float]] = None, ) -> None: if not isinstance(transforms, Sequence): raise TypeError("Argument transforms should be a sequence of callables") diff --git a/torchvision/transforms/v2/_geometry.py b/torchvision/transforms/v2/_geometry.py index af8ca4b6471..4d7a5fca384 100644 --- a/torchvision/transforms/v2/_geometry.py +++ b/torchvision/transforms/v2/_geometry.py @@ -575,8 +575,8 @@ def __init__( degrees: Union[numbers.Number, Sequence], interpolation: Union[InterpolationMode, int] = InterpolationMode.NEAREST, expand: bool = False, - fill: Union[datapoints._FillType, Dict[Type, datapoints._FillType]] = 0, center: Optional[List[float]] = None, + fill: Union[datapoints._FillType, Dict[Type, datapoints._FillType]] = 0, ) -> None: super().__init__() self.degrees = _setup_angle(degrees, name="degrees", req_sizes=(2,)) @@ -903,9 +903,9 @@ class RandomPerspective(_RandomApplyTransform): def __init__( self, distortion_scale: float = 0.5, - fill: Union[datapoints._FillType, Dict[Type, datapoints._FillType]] = 0, - interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR, p: float = 0.5, + interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR, + fill: Union[datapoints._FillType, Dict[Type, datapoints._FillType]] = 0, ) -> None: super().__init__(p=p) @@ -966,8 +966,8 @@ def __init__( self, alpha: Union[float, Sequence[float]] = 50.0, sigma: Union[float, Sequence[float]] = 5.0, - fill: Union[datapoints._FillType, Dict[Type, datapoints._FillType]] = 0, interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR, + fill: Union[datapoints._FillType, Dict[Type, datapoints._FillType]] = 0, ) -> None: super().__init__() self.alpha = _setup_float_or_seq(alpha, "alpha", 2)