π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
docs(augmentation): document RandomCutMixV2 data_keys and pin Args blocks (#4506)
Taraka Abhiram78cd06c35bd4
diff --git a/changelog.d/4506.fixed.md b/changelog.d/4506.fixed.mdnew file mode 100644index 000000000..dcb3bdd78--- /dev/null+++ b/changelog.d/4506.fixed.md@@ -0,0 +1 @@+`RandomCutMixV2` now documents its `data_keys` constructor argument.diff --git a/kornia/augmentation/_2d/mix/cutmix.py b/kornia/augmentation/_2d/mix/cutmix.pyindex 219553c54..378269d55 100644--- a/kornia/augmentation/_2d/mix/cutmix.py+++ b/kornia/augmentation/_2d/mix/cutmix.py@@ -57,6 +57,7 @@ class RandomCutMixV2(MixAugmentationBaseV2):This flag will not maintain permutation order.keepdim: whether to keep the output shape the same as input (True) or broadcast itto the batch form (False).+ data_keys: list of keys to apply the mix augmentation to.use_correct_lambda: if True, compute lambda according to the CutMix paper(`lam = 1 - area_ratio`). Defaults to False (`lam = area_ratio`) for backward compatibility,but will raise a deprecation warning when False.diff --git a/tests/augmentation/test_args_docstrings.py b/tests/augmentation/test_args_docstrings.pyindex 84d9a8210..045333fe5 100644--- a/tests/augmentation/test_args_docstrings.py+++ b/tests/augmentation/test_args_docstrings.py@@ -25,15 +25,28 @@ import kornia.augmentation as Kdef _documented_args(cls):doc = inspect.getdoc(cls) or ""- block = re.search(r"Args:\n(.*?)\n\s*(?:Shape|Returns|Examples?|\.\. note::|Note)", doc, re.S)+ block = re.search(r"Args:\n(.*?)\n\s*(?:Shape|Returns?|Examples?|Inputs|Convention|\.\. note::|Note)", doc, re.S)assert block, f"{cls.__name__} has no Args block"return [match.group(1) for match in re.finditer(r"^\s{4}(\w+):", block.group(1), re.M)][email protected]("cls", [K.ColorJitter, K.ColorJiggle, K.RandomBrightness, K.RandomGaussianBlur])+ "cls",+ [+ K.ColorJitter,+ K.ColorJiggle,+ K.Denormalize,+ K.RandomBrightness,+ K.RandomCutMixV2,+ K.RandomGaussianBlur,+ K.RandomThinPlateSpline,+ ],+)def test_args_block_matches_the_constructor(cls):# kornia#4437: three classes documented a `silence_instantiation_warning` argument that does not# exist, and ColorJitter did not document its real `order` argument.+ # kornia#4496: RandomCutMixV2 documented nonexistent `height`/`width` and omitted `data_keys`;+ # Denormalize and RandomThinPlateSpline had the same drift and were fixed before this pin.signature = list(inspect.signature(cls.__init__).parameters)[1:]assert sorted(_documented_args(cls)) == sorted(signature)