move transformtoaug as a top level function.
Summary:
Pull Request resolved:
Move _TransformToAug as a top level function.
@@ -51,7 +51,10 @@ def _get_aug_input_args(aug, aug_input) -> List[Any]:
else:
names = []
for name, prm in prms:
- if prm.kind in (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD):
+ if prm.kind in (
+ inspect.Parameter.VAR_POSITIONAL,
+ inspect.Parameter.VAR_KEYWORD,
+ ):
raise TypeError(
f""" \
The default implementation of `{type(aug)}.__call__` does not allow \
@@ -213,16 +216,6 @@ class Augmentation:
__str__ = __repr__
-def _transform_to_aug(tfm_or_aug):
- """
- Wrap Transform into Augmentation.
- Private, used internally to implement augmentations.
- """
- assert isinstance(tfm_or_aug, (Transform, Augmentation)), tfm_or_aug
- if isinstance(tfm_or_aug, Augmentation):
- return tfm_or_aug
- else:
-
class _TransformToAug(Augmentation):
def __init__(self, tfm: Transform):
self.tfm = tfm
@@ -235,6 +228,16 @@ def _transform_to_aug(tfm_or_aug):
__str__ = __repr__
+
+def _transform_to_aug(tfm_or_aug):
+ """
+ Wrap Transform into Augmentation.
+ Private, used internally to implement augmentations.
+ """
+ assert isinstance(tfm_or_aug, (Transform, Augmentation)), tfm_or_aug
+ if isinstance(tfm_or_aug, Augmentation):
+ return tfm_or_aug
+ else:
return _TransformToAug(tfm_or_aug)
