Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
6b020798
"src/vscode:/vscode.git/clone" did not exist on "8faa822ddc6e214498fc1a6d6e7a48ed31d2fb91"
Unverified
Commit
6b020798
authored
Aug 09, 2023
by
Philip Meier
Committed by
GitHub
Aug 09, 2023
Browse files
cleanup v2 tests (#7812)
parent
5d8d61ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
85 deletions
+25
-85
test/test_transforms_v2_refactored.py
test/test_transforms_v2_refactored.py
+25
-85
No files found.
test/test_transforms_v2_refactored.py
View file @
6b020798
...
@@ -173,15 +173,7 @@ def _check_dispatcher_scripted_smoke(dispatcher, input, *args, **kwargs):
...
@@ -173,15 +173,7 @@ def _check_dispatcher_scripted_smoke(dispatcher, input, *args, **kwargs):
dispatcher_scripted
(
input
.
as_subclass
(
torch
.
Tensor
),
*
args
,
**
kwargs
)
dispatcher_scripted
(
input
.
as_subclass
(
torch
.
Tensor
),
*
args
,
**
kwargs
)
def
check_dispatcher
(
def
check_dispatcher
(
dispatcher
,
input
,
*
args
,
check_scripted_smoke
=
True
,
**
kwargs
):
dispatcher
,
# TODO: remove this parameter
kernel
,
input
,
*
args
,
check_scripted_smoke
=
True
,
**
kwargs
,
):
unknown_input
=
object
()
unknown_input
=
object
()
with
pytest
.
raises
(
TypeError
,
match
=
re
.
escape
(
str
(
type
(
unknown_input
)))):
with
pytest
.
raises
(
TypeError
,
match
=
re
.
escape
(
str
(
type
(
unknown_input
)))):
dispatcher
(
unknown_input
,
*
args
,
**
kwargs
)
dispatcher
(
unknown_input
,
*
args
,
**
kwargs
)
...
@@ -516,20 +508,12 @@ class TestResize:
...
@@ -516,20 +508,12 @@ class TestResize:
@
pytest
.
mark
.
parametrize
(
"size"
,
OUTPUT_SIZES
)
@
pytest
.
mark
.
parametrize
(
"size"
,
OUTPUT_SIZES
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"make_input"
),
"make_input"
,
[
[
make_image_tensor
,
make_image_pil
,
make_image
,
make_bounding_box
,
make_segmentation_mask
,
make_video
],
(
F
.
resize_image_tensor
,
make_image_tensor
),
(
F
.
resize_image_pil
,
make_image_pil
),
(
F
.
resize_image_tensor
,
make_image
),
(
F
.
resize_bounding_boxes
,
make_bounding_box
),
(
F
.
resize_mask
,
make_segmentation_mask
),
(
F
.
resize_video
,
make_video
),
],
)
)
def
test_dispatcher
(
self
,
size
,
kernel
,
make_input
):
def
test_dispatcher
(
self
,
size
,
make_input
):
check_dispatcher
(
check_dispatcher
(
F
.
resize
,
F
.
resize
,
kernel
,
make_input
(
self
.
INPUT_SIZE
),
make_input
(
self
.
INPUT_SIZE
),
size
=
size
,
size
=
size
,
antialias
=
True
,
antialias
=
True
,
...
@@ -805,18 +789,11 @@ class TestHorizontalFlip:
...
@@ -805,18 +789,11 @@ class TestHorizontalFlip:
check_kernel
(
F
.
horizontal_flip_video
,
make_video
())
check_kernel
(
F
.
horizontal_flip_video
,
make_video
())
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"make_input"
),
"make_input"
,
[
[
make_image_tensor
,
make_image_pil
,
make_image
,
make_bounding_box
,
make_segmentation_mask
,
make_video
],
(
F
.
horizontal_flip_image_tensor
,
make_image_tensor
),
(
F
.
horizontal_flip_image_pil
,
make_image_pil
),
(
F
.
horizontal_flip_image_tensor
,
make_image
),
(
F
.
horizontal_flip_bounding_boxes
,
make_bounding_box
),
(
F
.
horizontal_flip_mask
,
make_segmentation_mask
),
(
F
.
horizontal_flip_video
,
make_video
),
],
)
)
def
test_dispatcher
(
self
,
kernel
,
make_input
):
def
test_dispatcher
(
self
,
make_input
):
check_dispatcher
(
F
.
horizontal_flip
,
kernel
,
make_input
())
check_dispatcher
(
F
.
horizontal_flip
,
make_input
())
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"input_type"
),
(
"kernel"
,
"input_type"
),
...
@@ -988,18 +965,11 @@ class TestAffine:
...
@@ -988,18 +965,11 @@ class TestAffine:
self
.
_check_kernel
(
F
.
affine_video
,
make_video
())
self
.
_check_kernel
(
F
.
affine_video
,
make_video
())
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"make_input"
),
"make_input"
,
[
[
make_image_tensor
,
make_image_pil
,
make_image
,
make_bounding_box
,
make_segmentation_mask
,
make_video
],
(
F
.
affine_image_tensor
,
make_image_tensor
),
(
F
.
affine_image_pil
,
make_image_pil
),
(
F
.
affine_image_tensor
,
make_image
),
(
F
.
affine_bounding_boxes
,
make_bounding_box
),
(
F
.
affine_mask
,
make_segmentation_mask
),
(
F
.
affine_video
,
make_video
),
],
)
)
def
test_dispatcher
(
self
,
kernel
,
make_input
):
def
test_dispatcher
(
self
,
make_input
):
check_dispatcher
(
F
.
affine
,
kernel
,
make_input
(),
**
self
.
_MINIMAL_AFFINE_KWARGS
)
check_dispatcher
(
F
.
affine
,
make_input
(),
**
self
.
_MINIMAL_AFFINE_KWARGS
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"input_type"
),
(
"kernel"
,
"input_type"
),
...
@@ -1284,18 +1254,11 @@ class TestVerticalFlip:
...
@@ -1284,18 +1254,11 @@ class TestVerticalFlip:
check_kernel
(
F
.
vertical_flip_video
,
make_video
())
check_kernel
(
F
.
vertical_flip_video
,
make_video
())
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"make_input"
),
"make_input"
,
[
[
make_image_tensor
,
make_image_pil
,
make_image
,
make_bounding_box
,
make_segmentation_mask
,
make_video
],
(
F
.
vertical_flip_image_tensor
,
make_image_tensor
),
(
F
.
vertical_flip_image_pil
,
make_image_pil
),
(
F
.
vertical_flip_image_tensor
,
make_image
),
(
F
.
vertical_flip_bounding_boxes
,
make_bounding_box
),
(
F
.
vertical_flip_mask
,
make_segmentation_mask
),
(
F
.
vertical_flip_video
,
make_video
),
],
)
)
def
test_dispatcher
(
self
,
kernel
,
make_input
):
def
test_dispatcher
(
self
,
make_input
):
check_dispatcher
(
F
.
vertical_flip
,
kernel
,
make_input
())
check_dispatcher
(
F
.
vertical_flip
,
make_input
())
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"input_type"
),
(
"kernel"
,
"input_type"
),
...
@@ -1441,18 +1404,11 @@ class TestRotate:
...
@@ -1441,18 +1404,11 @@ class TestRotate:
check_kernel
(
F
.
rotate_video
,
make_video
(),
**
self
.
_MINIMAL_AFFINE_KWARGS
)
check_kernel
(
F
.
rotate_video
,
make_video
(),
**
self
.
_MINIMAL_AFFINE_KWARGS
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"make_input"
),
"make_input"
,
[
[
make_image_tensor
,
make_image_pil
,
make_image
,
make_bounding_box
,
make_segmentation_mask
,
make_video
],
(
F
.
rotate_image_tensor
,
make_image_tensor
),
(
F
.
rotate_image_pil
,
make_image_pil
),
(
F
.
rotate_image_tensor
,
make_image
),
(
F
.
rotate_bounding_boxes
,
make_bounding_box
),
(
F
.
rotate_mask
,
make_segmentation_mask
),
(
F
.
rotate_video
,
make_video
),
],
)
)
def
test_dispatcher
(
self
,
kernel
,
make_input
):
def
test_dispatcher
(
self
,
make_input
):
check_dispatcher
(
F
.
rotate
,
kernel
,
make_input
(),
**
self
.
_MINIMAL_AFFINE_KWARGS
)
check_dispatcher
(
F
.
rotate
,
make_input
(),
**
self
.
_MINIMAL_AFFINE_KWARGS
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"input_type"
),
(
"kernel"
,
"input_type"
),
...
@@ -1711,22 +1667,14 @@ class TestToDtype:
...
@@ -1711,22 +1667,14 @@ class TestToDtype:
scale
=
scale
,
scale
=
scale
,
)
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
"make_input"
,
[
make_image_tensor
,
make_image
,
make_video
])
(
"kernel"
,
"make_input"
),
[
(
F
.
to_dtype_image_tensor
,
make_image_tensor
),
(
F
.
to_dtype_image_tensor
,
make_image
),
(
F
.
to_dtype_video
,
make_video
),
],
)
@
pytest
.
mark
.
parametrize
(
"input_dtype"
,
[
torch
.
float32
,
torch
.
float64
,
torch
.
uint8
])
@
pytest
.
mark
.
parametrize
(
"input_dtype"
,
[
torch
.
float32
,
torch
.
float64
,
torch
.
uint8
])
@
pytest
.
mark
.
parametrize
(
"output_dtype"
,
[
torch
.
float32
,
torch
.
float64
,
torch
.
uint8
])
@
pytest
.
mark
.
parametrize
(
"output_dtype"
,
[
torch
.
float32
,
torch
.
float64
,
torch
.
uint8
])
@
pytest
.
mark
.
parametrize
(
"device"
,
cpu_and_cuda
())
@
pytest
.
mark
.
parametrize
(
"device"
,
cpu_and_cuda
())
@
pytest
.
mark
.
parametrize
(
"scale"
,
(
True
,
False
))
@
pytest
.
mark
.
parametrize
(
"scale"
,
(
True
,
False
))
def
test_dispatcher
(
self
,
kernel
,
make_input
,
input_dtype
,
output_dtype
,
device
,
scale
):
def
test_dispatcher
(
self
,
make_input
,
input_dtype
,
output_dtype
,
device
,
scale
):
check_dispatcher
(
check_dispatcher
(
F
.
to_dtype
,
F
.
to_dtype
,
kernel
,
make_input
(
dtype
=
input_dtype
,
device
=
device
),
make_input
(
dtype
=
input_dtype
,
device
=
device
),
dtype
=
output_dtype
,
dtype
=
output_dtype
,
scale
=
scale
,
scale
=
scale
,
...
@@ -1890,17 +1838,9 @@ class TestAdjustBrightness:
...
@@ -1890,17 +1838,9 @@ class TestAdjustBrightness:
def
test_kernel
(
self
,
kernel
,
make_input
,
dtype
,
device
):
def
test_kernel
(
self
,
kernel
,
make_input
,
dtype
,
device
):
check_kernel
(
kernel
,
make_input
(
dtype
=
dtype
,
device
=
device
),
brightness_factor
=
self
.
_DEFAULT_BRIGHTNESS_FACTOR
)
check_kernel
(
kernel
,
make_input
(
dtype
=
dtype
,
device
=
device
),
brightness_factor
=
self
.
_DEFAULT_BRIGHTNESS_FACTOR
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
"make_input"
,
[
make_image_tensor
,
make_image_pil
,
make_image
,
make_video
])
(
"kernel"
,
"make_input"
),
def
test_dispatcher
(
self
,
make_input
):
[
check_dispatcher
(
F
.
adjust_brightness
,
make_input
(),
brightness_factor
=
self
.
_DEFAULT_BRIGHTNESS_FACTOR
)
(
F
.
adjust_brightness_image_tensor
,
make_image_tensor
),
(
F
.
adjust_brightness_image_pil
,
make_image_pil
),
(
F
.
adjust_brightness_image_tensor
,
make_image
),
(
F
.
adjust_brightness_video
,
make_video
),
],
)
def
test_dispatcher
(
self
,
kernel
,
make_input
):
check_dispatcher
(
F
.
adjust_brightness
,
kernel
,
make_input
(),
brightness_factor
=
self
.
_DEFAULT_BRIGHTNESS_FACTOR
)
@
pytest
.
mark
.
parametrize
(
@
pytest
.
mark
.
parametrize
(
(
"kernel"
,
"input_type"
),
(
"kernel"
,
"input_type"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment