From 34f648ede0e52a38dfc378ad38b191ee7f1d2855 Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Wed, 25 May 2022 06:16:03 -0700 Subject: [PATCH] move targets Summary: Move testing targets from pytorch3d/tests/TARGETS to pytorch3d/TARGETS. Reviewed By: shapovalov Differential Revision: D36186940 fbshipit-source-id: a4c52c4d99351f885e2b0bf870532d530324039b --- dev/linter.sh | 4 ++-- dev/test_list.py | 2 +- tests/benchmarks/bm_acos_linear_extrapolation.py | 2 +- tests/benchmarks/bm_ball_query.py | 2 +- tests/benchmarks/bm_blending.py | 2 +- tests/benchmarks/bm_cameras_alignment.py | 2 +- tests/benchmarks/bm_chamfer.py | 2 +- tests/benchmarks/bm_cubify.py | 2 +- tests/benchmarks/bm_face_areas_normals.py | 2 +- tests/benchmarks/bm_graph_conv.py | 2 +- tests/benchmarks/bm_iou_box3d.py | 2 +- tests/benchmarks/bm_knn.py | 2 +- tests/benchmarks/bm_marching_cubes.py | 2 +- tests/benchmarks/bm_mesh_edge_loss.py | 2 +- tests/benchmarks/bm_mesh_io.py | 4 ++-- tests/benchmarks/bm_mesh_laplacian_smoothing.py | 2 +- tests/benchmarks/bm_mesh_normal_consistency.py | 2 +- tests/benchmarks/bm_meshes.py | 2 +- tests/benchmarks/bm_packed_to_padded.py | 2 +- tests/benchmarks/bm_perspective_n_points.py | 2 +- tests/benchmarks/bm_point_mesh_distance.py | 2 +- tests/benchmarks/bm_pointclouds.py | 2 +- tests/benchmarks/bm_points_alignment.py | 2 +- tests/benchmarks/bm_points_normals.py | 2 +- tests/benchmarks/bm_points_to_volumes.py | 2 +- tests/benchmarks/bm_rasterize_meshes.py | 2 +- tests/benchmarks/bm_raymarching.py | 2 +- tests/benchmarks/bm_raysampling.py | 2 +- tests/benchmarks/bm_render_implicit.py | 2 +- tests/benchmarks/bm_render_volumes.py | 2 +- tests/benchmarks/bm_sample_farthest_points.py | 2 +- tests/benchmarks/bm_sample_pdf.py | 2 +- tests/benchmarks/bm_sample_points_from_meshes.py | 2 +- tests/benchmarks/bm_se3.py | 2 +- tests/benchmarks/bm_so3.py | 2 +- tests/benchmarks/bm_subdivide_meshes.py | 2 +- tests/benchmarks/bm_symeig3x3.py | 2 +- tests/benchmarks/bm_vert_align.py | 2 +- tests/common_testing.py | 2 +- tests/implicitron/test_build.py | 7 +------ tests/implicitron/test_circle_fitting.py | 8 +------- tests/implicitron/test_config_use.py | 11 ++--------- tests/implicitron/test_data_source.py | 7 +------ tests/implicitron/test_dataset_visualize.py | 10 ++-------- tests/implicitron/test_eval_cameras.py | 8 +------- tests/implicitron/test_eval_demo.py | 11 ++--------- tests/implicitron/test_forward_pass.py | 11 ++--------- tests/implicitron/test_ray_point_refiner.py | 8 +------- tests/implicitron/test_srn.py | 8 +------- tests/pulsar/test_channels.py | 7 +------ tests/pulsar/test_depth.py | 7 +------ tests/pulsar/test_hands.py | 7 +------ tests/test_acos_linear_extrapolation.py | 3 ++- tests/test_ball_query.py | 3 ++- tests/test_blending.py | 3 ++- tests/test_build.py | 2 +- tests/test_camera_conversions.py | 3 ++- tests/test_camera_pixels.py | 3 ++- tests/test_camera_utils.py | 3 ++- tests/test_cameras.py | 3 ++- tests/test_cameras_alignment.py | 5 +++-- tests/test_chamfer.py | 3 ++- tests/test_common_linear_with_repeat.py | 3 ++- tests/test_common_testing.py | 3 ++- tests/test_common_workaround.py | 3 ++- tests/test_compositing.py | 3 ++- tests/test_cubify.py | 3 ++- tests/test_face_areas_normals.py | 3 ++- tests/test_graph_conv.py | 3 ++- tests/test_harmonic_embedding.py | 3 ++- tests/test_interpolate_face_attributes.py | 3 ++- tests/test_io_gltf.py | 3 ++- tests/test_io_obj.py | 13 +++++++------ tests/test_io_off.py | 3 ++- tests/test_io_ply.py | 3 ++- tests/test_iou_box3d.py | 3 ++- tests/test_knn.py | 3 ++- tests/test_laplacian_matrices.py | 3 ++- tests/test_lighting.py | 3 ++- tests/test_marching_cubes.py | 3 ++- tests/test_materials.py | 3 ++- tests/test_mesh_edge_loss.py | 5 +++-- tests/test_mesh_filtering.py | 3 ++- tests/test_meshes.py | 3 ++- tests/test_ops_utils.py | 3 ++- tests/test_packed_to_padded.py | 3 ++- tests/test_perspective_n_points.py | 3 ++- tests/test_point_mesh_distance.py | 3 ++- tests/test_pointclouds.py | 3 ++- tests/test_points_alignment.py | 3 ++- tests/test_points_normals.py | 3 ++- tests/test_points_to_volumes.py | 3 ++- tests/test_r2n2.py | 3 ++- tests/test_rasterize_meshes.py | 3 ++- tests/test_rasterize_points.py | 3 ++- tests/test_rasterize_rectangle_images.py | 13 +++++++------ tests/test_rasterizer.py | 3 ++- tests/test_raymarching.py | 3 ++- tests/test_raysampling.py | 5 +++-- tests/test_render_implicit.py | 5 +++-- tests/test_render_meshes.py | 13 +++++++------ tests/test_render_meshes_clipped.py | 3 ++- tests/test_render_multigpu.py | 3 ++- tests/test_render_points.py | 13 +++++++------ tests/test_render_volumes.py | 5 +++-- tests/test_rendering_utils.py | 3 ++- tests/test_rotation_conversions.py | 3 ++- tests/test_sample_farthest_points.py | 13 +++++++------ tests/test_sample_pdf.py | 3 ++- tests/test_sample_points_from_meshes.py | 13 +++++++------ tests/test_se3.py | 3 ++- tests/test_shader.py | 3 ++- tests/test_shapenet_core.py | 3 ++- tests/test_so3.py | 3 ++- tests/test_struct_utils.py | 3 ++- tests/test_subdivide_meshes.py | 3 ++- tests/test_symeig3x3.py | 3 ++- tests/test_texturing.py | 5 +++-- tests/test_transforms.py | 3 ++- tests/test_vert_align.py | 3 ++- tests/test_volumes.py | 3 ++- 121 files changed, 231 insertions(+), 239 deletions(-) diff --git a/dev/linter.sh b/dev/linter.sh index ae0892ba..43c64084 100755 --- a/dev/linter.sh +++ b/dev/linter.sh @@ -10,7 +10,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR=$(dirname "${DIR}") -if [[ -f "${DIR}/tests/TARGETS" ]] +if [[ -f "${DIR}/TARGETS" ]] then pyfmt "${DIR}" else @@ -30,7 +30,7 @@ clangformat=$(command -v clang-format-8 || echo clang-format) find "${DIR}" -regex ".*\.\(cpp\|c\|cc\|cu\|cuh\|cxx\|h\|hh\|hpp\|hxx\|tcc\|mm\|m\)" -print0 | xargs -0 "${clangformat}" -i # Run arc and pyre internally only. -if [[ -f "${DIR}/tests/TARGETS" ]] +if [[ -f "${DIR}/TARGETS" ]] then (cd "${DIR}"; command -v arc > /dev/null && arc lint) || true diff --git a/dev/test_list.py b/dev/test_list.py index 88a01724..65d95f22 100644 --- a/dev/test_list.py +++ b/dev/test_list.py @@ -51,7 +51,7 @@ def tests_from_file(path: Path, base: str) -> List[str]: def main() -> None: files = get_test_files() - test_root = Path(__file__).parent.parent / "tests" + test_root = Path(__file__).parent.parent all_tests = [] for f in files: file_base = str(f.relative_to(test_root))[:-3].replace("/", ".") diff --git a/tests/benchmarks/bm_acos_linear_extrapolation.py b/tests/benchmarks/bm_acos_linear_extrapolation.py index f8910054..4cfd3fa1 100644 --- a/tests/benchmarks/bm_acos_linear_extrapolation.py +++ b/tests/benchmarks/bm_acos_linear_extrapolation.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from fvcore.common.benchmark import benchmark -from test_acos_linear_extrapolation import TestAcosLinearExtrapolation +from tests.test_acos_linear_extrapolation import TestAcosLinearExtrapolation def bm_acos_linear_extrapolation() -> None: diff --git a/tests/benchmarks/bm_ball_query.py b/tests/benchmarks/bm_ball_query.py index f9f0885f..73aefd0a 100644 --- a/tests/benchmarks/bm_ball_query.py +++ b/tests/benchmarks/bm_ball_query.py @@ -7,7 +7,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_ball_query import TestBallQuery +from tests.test_ball_query import TestBallQuery def bm_ball_query() -> None: diff --git a/tests/benchmarks/bm_blending.py b/tests/benchmarks/bm_blending.py index 7b5349c2..6a404233 100644 --- a/tests/benchmarks/bm_blending.py +++ b/tests/benchmarks/bm_blending.py @@ -8,7 +8,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_blending import TestBlending +from tests.test_blending import TestBlending def bm_blending() -> None: diff --git a/tests/benchmarks/bm_cameras_alignment.py b/tests/benchmarks/bm_cameras_alignment.py index b2215cc6..22dd1570 100644 --- a/tests/benchmarks/bm_cameras_alignment.py +++ b/tests/benchmarks/bm_cameras_alignment.py @@ -7,7 +7,7 @@ import itertools from fvcore.common.benchmark import benchmark -from test_cameras_alignment import TestCamerasAlignment +from tests.test_cameras_alignment import TestCamerasAlignment def bm_cameras_alignment() -> None: diff --git a/tests/benchmarks/bm_chamfer.py b/tests/benchmarks/bm_chamfer.py index be0fe72b..81944c47 100644 --- a/tests/benchmarks/bm_chamfer.py +++ b/tests/benchmarks/bm_chamfer.py @@ -8,7 +8,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_chamfer import TestChamfer +from tests.test_chamfer import TestChamfer def bm_chamfer() -> None: diff --git a/tests/benchmarks/bm_cubify.py b/tests/benchmarks/bm_cubify.py index 50df86fe..37b18a5f 100644 --- a/tests/benchmarks/bm_cubify.py +++ b/tests/benchmarks/bm_cubify.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from fvcore.common.benchmark import benchmark -from test_cubify import TestCubify +from tests.test_cubify import TestCubify def bm_cubify() -> None: diff --git a/tests/benchmarks/bm_face_areas_normals.py b/tests/benchmarks/bm_face_areas_normals.py index 5ed94740..970a4de3 100644 --- a/tests/benchmarks/bm_face_areas_normals.py +++ b/tests/benchmarks/bm_face_areas_normals.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_face_areas_normals import TestFaceAreasNormals +from tests.test_face_areas_normals import TestFaceAreasNormals def bm_face_areas_normals() -> None: diff --git a/tests/benchmarks/bm_graph_conv.py b/tests/benchmarks/bm_graph_conv.py index df93ef71..4276f23d 100644 --- a/tests/benchmarks/bm_graph_conv.py +++ b/tests/benchmarks/bm_graph_conv.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_graph_conv import TestGraphConv +from tests.test_graph_conv import TestGraphConv def bm_graph_conv() -> None: diff --git a/tests/benchmarks/bm_iou_box3d.py b/tests/benchmarks/bm_iou_box3d.py index 20b74a0a..152e36ea 100644 --- a/tests/benchmarks/bm_iou_box3d.py +++ b/tests/benchmarks/bm_iou_box3d.py @@ -7,7 +7,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_iou_box3d import TestIoU3D +from tests.test_iou_box3d import TestIoU3D def bm_iou_box3d() -> None: diff --git a/tests/benchmarks/bm_knn.py b/tests/benchmarks/bm_knn.py index 33f3c0ea..f6ffa5e8 100644 --- a/tests/benchmarks/bm_knn.py +++ b/tests/benchmarks/bm_knn.py @@ -7,7 +7,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_knn import TestKNN +from tests.test_knn import TestKNN def bm_knn() -> None: diff --git a/tests/benchmarks/bm_marching_cubes.py b/tests/benchmarks/bm_marching_cubes.py index ca57538c..1ee7bc4d 100644 --- a/tests/benchmarks/bm_marching_cubes.py +++ b/tests/benchmarks/bm_marching_cubes.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from fvcore.common.benchmark import benchmark -from test_marching_cubes import TestMarchingCubes +from tests.test_marching_cubes import TestMarchingCubes def bm_marching_cubes() -> None: diff --git a/tests/benchmarks/bm_mesh_edge_loss.py b/tests/benchmarks/bm_mesh_edge_loss.py index 0142a626..3cf14b17 100644 --- a/tests/benchmarks/bm_mesh_edge_loss.py +++ b/tests/benchmarks/bm_mesh_edge_loss.py @@ -8,7 +8,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_mesh_edge_loss import TestMeshEdgeLoss +from tests.test_mesh_edge_loss import TestMeshEdgeLoss def bm_mesh_edge_loss() -> None: diff --git a/tests/benchmarks/bm_mesh_io.py b/tests/benchmarks/bm_mesh_io.py index 68a90cb7..37155fae 100644 --- a/tests/benchmarks/bm_mesh_io.py +++ b/tests/benchmarks/bm_mesh_io.py @@ -7,8 +7,8 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_io_obj import TestMeshObjIO -from test_io_ply import TestMeshPlyIO +from tests.test_io_obj import TestMeshObjIO +from tests.test_io_ply import TestMeshPlyIO def bm_save_load() -> None: diff --git a/tests/benchmarks/bm_mesh_laplacian_smoothing.py b/tests/benchmarks/bm_mesh_laplacian_smoothing.py index d9cfeb59..440aafba 100644 --- a/tests/benchmarks/bm_mesh_laplacian_smoothing.py +++ b/tests/benchmarks/bm_mesh_laplacian_smoothing.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_mesh_laplacian_smoothing import TestLaplacianSmoothing +from tests.test_mesh_laplacian_smoothing import TestLaplacianSmoothing def bm_mesh_laplacian_smoothing() -> None: diff --git a/tests/benchmarks/bm_mesh_normal_consistency.py b/tests/benchmarks/bm_mesh_normal_consistency.py index 626e056d..11d1be46 100644 --- a/tests/benchmarks/bm_mesh_normal_consistency.py +++ b/tests/benchmarks/bm_mesh_normal_consistency.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_mesh_normal_consistency import TestMeshNormalConsistency +from tests.test_mesh_normal_consistency import TestMeshNormalConsistency def bm_mesh_normal_consistency() -> None: diff --git a/tests/benchmarks/bm_meshes.py b/tests/benchmarks/bm_meshes.py index 503ee25b..1d0b63f2 100644 --- a/tests/benchmarks/bm_meshes.py +++ b/tests/benchmarks/bm_meshes.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_meshes import TestMeshes +from tests.test_meshes import TestMeshes def bm_compute_packed_padded_meshes() -> None: diff --git a/tests/benchmarks/bm_packed_to_padded.py b/tests/benchmarks/bm_packed_to_padded.py index 96086e8a..e61f36da 100644 --- a/tests/benchmarks/bm_packed_to_padded.py +++ b/tests/benchmarks/bm_packed_to_padded.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_packed_to_padded import TestPackedToPadded +from tests.test_packed_to_padded import TestPackedToPadded def bm_packed_to_padded() -> None: diff --git a/tests/benchmarks/bm_perspective_n_points.py b/tests/benchmarks/bm_perspective_n_points.py index ea57c096..672e530a 100644 --- a/tests/benchmarks/bm_perspective_n_points.py +++ b/tests/benchmarks/bm_perspective_n_points.py @@ -7,7 +7,7 @@ import itertools from fvcore.common.benchmark import benchmark -from test_perspective_n_points import TestPerspectiveNPoints +from tests.test_perspective_n_points import TestPerspectiveNPoints def bm_perspective_n_points() -> None: diff --git a/tests/benchmarks/bm_point_mesh_distance.py b/tests/benchmarks/bm_point_mesh_distance.py index fae5bf8f..bc1da128 100644 --- a/tests/benchmarks/bm_point_mesh_distance.py +++ b/tests/benchmarks/bm_point_mesh_distance.py @@ -8,7 +8,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_point_mesh_distance import TestPointMeshDistance +from tests.test_point_mesh_distance import TestPointMeshDistance def bm_point_mesh_distance() -> None: diff --git a/tests/benchmarks/bm_pointclouds.py b/tests/benchmarks/bm_pointclouds.py index 2c7de77c..4868e6bf 100644 --- a/tests/benchmarks/bm_pointclouds.py +++ b/tests/benchmarks/bm_pointclouds.py @@ -8,7 +8,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_pointclouds import TestPointclouds +from tests.test_pointclouds import TestPointclouds def bm_compute_packed_padded_pointclouds() -> None: diff --git a/tests/benchmarks/bm_points_alignment.py b/tests/benchmarks/bm_points_alignment.py index d7dec0f3..842773fb 100644 --- a/tests/benchmarks/bm_points_alignment.py +++ b/tests/benchmarks/bm_points_alignment.py @@ -8,7 +8,7 @@ from copy import deepcopy from itertools import product from fvcore.common.benchmark import benchmark -from test_points_alignment import TestCorrespondingPointsAlignment, TestICP +from tests.test_points_alignment import TestCorrespondingPointsAlignment, TestICP def bm_iterative_closest_point() -> None: diff --git a/tests/benchmarks/bm_points_normals.py b/tests/benchmarks/bm_points_normals.py index 487e71e5..efdf9950 100644 --- a/tests/benchmarks/bm_points_normals.py +++ b/tests/benchmarks/bm_points_normals.py @@ -9,7 +9,7 @@ import itertools import torch from fvcore.common.benchmark import benchmark from pytorch3d.ops import estimate_pointcloud_normals -from test_points_normals import TestPCLNormals +from tests.test_points_normals import TestPCLNormals def to_bm(num_points, use_symeig_workaround): diff --git a/tests/benchmarks/bm_points_to_volumes.py b/tests/benchmarks/bm_points_to_volumes.py index 9277b850..7a79b195 100644 --- a/tests/benchmarks/bm_points_to_volumes.py +++ b/tests/benchmarks/bm_points_to_volumes.py @@ -7,7 +7,7 @@ import itertools from fvcore.common.benchmark import benchmark -from test_points_to_volumes import TestPointsToVolumes +from tests.test_points_to_volumes import TestPointsToVolumes def bm_points_to_volumes() -> None: diff --git a/tests/benchmarks/bm_rasterize_meshes.py b/tests/benchmarks/bm_rasterize_meshes.py index 1c08d148..da981711 100644 --- a/tests/benchmarks/bm_rasterize_meshes.py +++ b/tests/benchmarks/bm_rasterize_meshes.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_rasterize_meshes import TestRasterizeMeshes +from tests.test_rasterize_meshes import TestRasterizeMeshes # ico levels: diff --git a/tests/benchmarks/bm_raymarching.py b/tests/benchmarks/bm_raymarching.py index c65d906e..b37f6127 100644 --- a/tests/benchmarks/bm_raymarching.py +++ b/tests/benchmarks/bm_raymarching.py @@ -8,7 +8,7 @@ import itertools from fvcore.common.benchmark import benchmark from pytorch3d.renderer import AbsorptionOnlyRaymarcher, EmissionAbsorptionRaymarcher -from test_raymarching import TestRaymarching +from tests.test_raymarching import TestRaymarching def bm_raymarching() -> None: diff --git a/tests/benchmarks/bm_raysampling.py b/tests/benchmarks/bm_raysampling.py index 99df8150..09b0f128 100644 --- a/tests/benchmarks/bm_raysampling.py +++ b/tests/benchmarks/bm_raysampling.py @@ -16,7 +16,7 @@ from pytorch3d.renderer import ( OrthographicCameras, PerspectiveCameras, ) -from test_raysampling import TestRaysampling +from tests.test_raysampling import TestRaysampling def bm_raysampling() -> None: diff --git a/tests/benchmarks/bm_render_implicit.py b/tests/benchmarks/bm_render_implicit.py index d0d0c454..af38047a 100644 --- a/tests/benchmarks/bm_render_implicit.py +++ b/tests/benchmarks/bm_render_implicit.py @@ -8,7 +8,7 @@ import itertools from fvcore.common.benchmark import benchmark from pytorch3d.renderer import AbsorptionOnlyRaymarcher, EmissionAbsorptionRaymarcher -from test_render_implicit import TestRenderImplicit +from tests.test_render_implicit import TestRenderImplicit def bm_render_volumes() -> None: diff --git a/tests/benchmarks/bm_render_volumes.py b/tests/benchmarks/bm_render_volumes.py index 78e0c53a..abe76d93 100644 --- a/tests/benchmarks/bm_render_volumes.py +++ b/tests/benchmarks/bm_render_volumes.py @@ -8,7 +8,7 @@ import itertools from fvcore.common.benchmark import benchmark from pytorch3d.renderer import AbsorptionOnlyRaymarcher, EmissionAbsorptionRaymarcher -from test_render_volumes import TestRenderVolumes +from tests.test_render_volumes import TestRenderVolumes def bm_render_volumes() -> None: diff --git a/tests/benchmarks/bm_sample_farthest_points.py b/tests/benchmarks/bm_sample_farthest_points.py index 5109a72c..1bf355ce 100644 --- a/tests/benchmarks/bm_sample_farthest_points.py +++ b/tests/benchmarks/bm_sample_farthest_points.py @@ -7,7 +7,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_sample_farthest_points import TestFPS +from tests.test_sample_farthest_points import TestFPS def bm_fps() -> None: diff --git a/tests/benchmarks/bm_sample_pdf.py b/tests/benchmarks/bm_sample_pdf.py index 22ad538a..0f94df8f 100644 --- a/tests/benchmarks/bm_sample_pdf.py +++ b/tests/benchmarks/bm_sample_pdf.py @@ -7,7 +7,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_sample_pdf import TestSamplePDF +from tests.test_sample_pdf import TestSamplePDF def bm_sample_pdf() -> None: diff --git a/tests/benchmarks/bm_sample_points_from_meshes.py b/tests/benchmarks/bm_sample_points_from_meshes.py index 7413b9da..480e7eb9 100644 --- a/tests/benchmarks/bm_sample_points_from_meshes.py +++ b/tests/benchmarks/bm_sample_points_from_meshes.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_sample_points_from_meshes import TestSamplePoints +from tests.test_sample_points_from_meshes import TestSamplePoints def bm_sample_points() -> None: diff --git a/tests/benchmarks/bm_se3.py b/tests/benchmarks/bm_se3.py index 8730bd81..62ac8967 100644 --- a/tests/benchmarks/bm_se3.py +++ b/tests/benchmarks/bm_se3.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from fvcore.common.benchmark import benchmark -from test_se3 import TestSE3 +from tests.test_se3 import TestSE3 def bm_se3() -> None: diff --git a/tests/benchmarks/bm_so3.py b/tests/benchmarks/bm_so3.py index da912b4c..851e9fc4 100644 --- a/tests/benchmarks/bm_so3.py +++ b/tests/benchmarks/bm_so3.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. from fvcore.common.benchmark import benchmark -from test_so3 import TestSO3 +from tests.test_so3 import TestSO3 def bm_so3() -> None: diff --git a/tests/benchmarks/bm_subdivide_meshes.py b/tests/benchmarks/bm_subdivide_meshes.py index 798842ea..79a4a30a 100644 --- a/tests/benchmarks/bm_subdivide_meshes.py +++ b/tests/benchmarks/bm_subdivide_meshes.py @@ -8,7 +8,7 @@ from itertools import product from fvcore.common.benchmark import benchmark -from test_subdivide_meshes import TestSubdivideMeshes +from tests.test_subdivide_meshes import TestSubdivideMeshes def bm_subdivide() -> None: diff --git a/tests/benchmarks/bm_symeig3x3.py b/tests/benchmarks/bm_symeig3x3.py index fe984034..c0e4dc63 100644 --- a/tests/benchmarks/bm_symeig3x3.py +++ b/tests/benchmarks/bm_symeig3x3.py @@ -12,7 +12,7 @@ import torch from common_testing import get_random_cuda_device from fvcore.common.benchmark import benchmark from pytorch3d.common.workaround import symeig3x3 -from test_symeig3x3 import TestSymEig3x3 +from tests.test_symeig3x3 import TestSymEig3x3 torch.set_num_threads(1) diff --git a/tests/benchmarks/bm_vert_align.py b/tests/benchmarks/bm_vert_align.py index e2f5bf1d..6670029e 100644 --- a/tests/benchmarks/bm_vert_align.py +++ b/tests/benchmarks/bm_vert_align.py @@ -9,7 +9,7 @@ from itertools import product import torch from fvcore.common.benchmark import benchmark -from test_vert_align import TestVertAlign +from tests.test_vert_align import TestVertAlign def bm_vert_align() -> None: diff --git a/tests/common_testing.py b/tests/common_testing.py index a83c8c22..cce23ea1 100644 --- a/tests/common_testing.py +++ b/tests/common_testing.py @@ -38,7 +38,7 @@ def get_pytorch3d_dir() -> Path: Meta internal systems need a special case here. """ if os.environ.get("INSIDE_RE_WORKER") is not None: - return Path(__file__).resolve().parent + return Path(__file__).resolve().parent.parent elif os.environ.get("CONDA_BUILD_STATE", "") == "TEST": return Path(os.environ["SRC_DIR"]) else: diff --git a/tests/implicitron/test_build.py b/tests/implicitron/test_build.py index cadab3d8..f554c0f4 100644 --- a/tests/implicitron/test_build.py +++ b/tests/implicitron/test_build.py @@ -5,16 +5,11 @@ # LICENSE file in the root directory of this source tree. import importlib -import os import sys import unittest import unittest.mock - -if os.environ.get("FB_TEST", False): - from common_testing import get_pytorch3d_dir -else: - from tests.common_testing import get_pytorch3d_dir +from tests.common_testing import get_pytorch3d_dir # This file groups together tests which look at the code without running it. diff --git a/tests/implicitron/test_circle_fitting.py b/tests/implicitron/test_circle_fitting.py index 5177f2f3..91bce7eb 100644 --- a/tests/implicitron/test_circle_fitting.py +++ b/tests/implicitron/test_circle_fitting.py @@ -4,7 +4,6 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os import unittest from math import pi @@ -15,12 +14,7 @@ from pytorch3d.implicitron.tools.circle_fitting import ( fit_circle_in_3d, ) from pytorch3d.transforms import random_rotation - - -if os.environ.get("FB_TEST", False): - from common_testing import TestCaseMixin -else: - from tests.common_testing import TestCaseMixin +from tests.common_testing import TestCaseMixin class TestCircleFitting(TestCaseMixin, unittest.TestCase): diff --git a/tests/implicitron/test_config_use.py b/tests/implicitron/test_config_use.py index a5b87ba5..bef76651 100644 --- a/tests/implicitron/test_config_use.py +++ b/tests/implicitron/test_config_use.py @@ -4,7 +4,6 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os import unittest from omegaconf import OmegaConf @@ -30,15 +29,9 @@ from pytorch3d.implicitron.tools.config import ( get_default_args, remove_unused_components, ) +from tests.common_testing import get_tests_dir - -if os.environ.get("FB_TEST", False): - from common_testing import get_tests_dir - - from .common_resources import provide_resnet34 -else: - from common_resources import provide_resnet34 - from tests.common_testing import get_tests_dir +from .common_resources import provide_resnet34 DATA_DIR = get_tests_dir() / "implicitron/data" DEBUG: bool = False diff --git a/tests/implicitron/test_data_source.py b/tests/implicitron/test_data_source.py index 845aa858..bf41f693 100644 --- a/tests/implicitron/test_data_source.py +++ b/tests/implicitron/test_data_source.py @@ -4,17 +4,12 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os import unittest from omegaconf import OmegaConf from pytorch3d.implicitron.dataset.data_source import ImplicitronDataSource from pytorch3d.implicitron.tools.config import get_default_args - -if os.environ.get("FB_TEST", False): - from common_testing import get_tests_dir -else: - from tests.common_testing import get_tests_dir +from tests.common_testing import get_tests_dir DATA_DIR = get_tests_dir() / "implicitron/data" DEBUG: bool = False diff --git a/tests/implicitron/test_dataset_visualize.py b/tests/implicitron/test_dataset_visualize.py index 73c048ef..380e14ce 100644 --- a/tests/implicitron/test_dataset_visualize.py +++ b/tests/implicitron/test_dataset_visualize.py @@ -21,15 +21,9 @@ from pytorch3d.vis.plotly_vis import plot_scene if os.environ.get("INSIDE_RE_WORKER") is None: from visdom import Visdom -if os.environ.get("FB_TEST", False): - from .common_resources import get_skateboard_data -else: - from common_resources import get_skateboard_data +from tests.common_testing import interactive_testing_requested -if os.environ.get("FB_TEST", False): - from common_testing import interactive_testing_requested -else: - from tests.common_testing import interactive_testing_requested +from .common_resources import get_skateboard_data class TestDatasetVisualize(unittest.TestCase): diff --git a/tests/implicitron/test_eval_cameras.py b/tests/implicitron/test_eval_cameras.py index e4e014b3..5ec79525 100644 --- a/tests/implicitron/test_eval_cameras.py +++ b/tests/implicitron/test_eval_cameras.py @@ -4,7 +4,6 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os import unittest import torch @@ -13,12 +12,7 @@ from pytorch3d.implicitron.tools.eval_video_trajectory import ( ) from pytorch3d.renderer.cameras import look_at_view_transform, PerspectiveCameras from pytorch3d.transforms import axis_angle_to_matrix - - -if os.environ.get("FB_TEST", False): - from common_testing import TestCaseMixin -else: - from tests.common_testing import TestCaseMixin +from tests.common_testing import TestCaseMixin class TestEvalCameras(TestCaseMixin, unittest.TestCase): diff --git a/tests/implicitron/test_eval_demo.py b/tests/implicitron/test_eval_demo.py index 46e2efd2..390398a2 100644 --- a/tests/implicitron/test_eval_demo.py +++ b/tests/implicitron/test_eval_demo.py @@ -9,16 +9,9 @@ import unittest from pytorch3d.implicitron import eval_demo +from tests.common_testing import interactive_testing_requested -if os.environ.get("FB_TEST", False): - from .common_resources import CO3D_MANIFOLD_PATH, get_path_manager -else: - from common_resources import CO3D_MANIFOLD_PATH, get_path_manager - -if os.environ.get("FB_TEST", False): - from common_testing import interactive_testing_requested -else: - from tests.common_testing import interactive_testing_requested +from .common_resources import CO3D_MANIFOLD_PATH, get_path_manager """ This test runs a single sequence eval_demo, useful for debugging datasets. diff --git a/tests/implicitron/test_forward_pass.py b/tests/implicitron/test_forward_pass.py index 52d5016e..285186ff 100644 --- a/tests/implicitron/test_forward_pass.py +++ b/tests/implicitron/test_forward_pass.py @@ -13,16 +13,9 @@ from pytorch3d.implicitron.models.generic_model import GenericModel from pytorch3d.implicitron.models.renderer.base import EvaluationMode from pytorch3d.implicitron.tools.config import expand_args_fields, get_default_args from pytorch3d.renderer.cameras import look_at_view_transform, PerspectiveCameras +from tests.common_testing import get_pytorch3d_dir -if os.environ.get("FB_TEST", False): - from .common_resources import provide_resnet34 -else: - from common_resources import provide_resnet34 - -if os.environ.get("FB_TEST", False): - from common_testing import get_pytorch3d_dir -else: - from tests.common_testing import get_pytorch3d_dir +from .common_resources import provide_resnet34 IMPLICITRON_CONFIGS_DIR = ( get_pytorch3d_dir() / "projects" / "implicitron_trainer" / "configs" diff --git a/tests/implicitron/test_ray_point_refiner.py b/tests/implicitron/test_ray_point_refiner.py index cc16197e..fb512c24 100644 --- a/tests/implicitron/test_ray_point_refiner.py +++ b/tests/implicitron/test_ray_point_refiner.py @@ -4,18 +4,12 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os import unittest import torch from pytorch3d.implicitron.models.renderer.ray_point_refiner import RayPointRefiner from pytorch3d.renderer import RayBundle - - -if os.environ.get("FB_TEST", False): - from common_testing import TestCaseMixin -else: - from tests.common_testing import TestCaseMixin +from tests.common_testing import TestCaseMixin class TestRayPointRefiner(TestCaseMixin, unittest.TestCase): diff --git a/tests/implicitron/test_srn.py b/tests/implicitron/test_srn.py index 062d549c..cff633fd 100644 --- a/tests/implicitron/test_srn.py +++ b/tests/implicitron/test_srn.py @@ -4,7 +4,6 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -import os import unittest import torch @@ -16,12 +15,7 @@ from pytorch3d.implicitron.models.implicit_function.scene_representation_network from pytorch3d.implicitron.models.renderer.base import ImplicitFunctionWrapper from pytorch3d.implicitron.tools.config import get_default_args from pytorch3d.renderer import RayBundle - - -if os.environ.get("FB_TEST", False): - from common_testing import TestCaseMixin -else: - from tests.common_testing import TestCaseMixin +from tests.common_testing import TestCaseMixin _BATCH_SIZE: int = 3 _N_RAYS: int = 100 diff --git a/tests/pulsar/test_channels.py b/tests/pulsar/test_channels.py index d4133761..adbf4e56 100644 --- a/tests/pulsar/test_channels.py +++ b/tests/pulsar/test_channels.py @@ -12,12 +12,7 @@ from os import path import torch - -# fmt: off -# Make the mixin available. -sys.path.insert(0, path.join(path.dirname(__file__), "..")) -from common_testing import TestCaseMixin # isort:skip # noqa: E402 -# fmt: on +from ..common_testing import TestCaseMixin sys.path.insert(0, path.join(path.dirname(__file__), "..", "..")) diff --git a/tests/pulsar/test_depth.py b/tests/pulsar/test_depth.py index 6d9384cc..023571ac 100644 --- a/tests/pulsar/test_depth.py +++ b/tests/pulsar/test_depth.py @@ -15,12 +15,7 @@ import imageio import numpy as np import torch - -# fmt: off -# Make the mixin available. -sys.path.insert(0, path.join(path.dirname(__file__), "..")) -from common_testing import TestCaseMixin # isort:skip # noqa: E402 -# fmt: on +from ..common_testing import TestCaseMixin # Making sure you can run this, even if pulsar hasn't been installed yet. sys.path.insert(0, path.join(path.dirname(__file__), "..", "..")) diff --git a/tests/pulsar/test_hands.py b/tests/pulsar/test_hands.py index 1256d946..128b2285 100644 --- a/tests/pulsar/test_hands.py +++ b/tests/pulsar/test_hands.py @@ -12,12 +12,7 @@ from os import path import torch - -# fmt: off -# Make the mixin available. -sys.path.insert(0, path.join(path.dirname(__file__), "..")) -from common_testing import TestCaseMixin # isort:skip # noqa: E402 -# fmt: on +from ..common_testing import TestCaseMixin # Making sure you can run this, even if pulsar hasn't been installed yet. diff --git a/tests/test_acos_linear_extrapolation.py b/tests/test_acos_linear_extrapolation.py index 4be85bfd..1cadf723 100644 --- a/tests/test_acos_linear_extrapolation.py +++ b/tests/test_acos_linear_extrapolation.py @@ -9,10 +9,11 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.common.compat import lstsq from pytorch3d.transforms import acos_linear_extrapolation +from .common_testing import TestCaseMixin + class TestAcosLinearExtrapolation(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_ball_query.py b/tests/test_ball_query.py index 0f58a191..9210cbeb 100644 --- a/tests/test_ball_query.py +++ b/tests/test_ball_query.py @@ -8,12 +8,13 @@ import unittest from itertools import product import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import sample_points_from_meshes from pytorch3d.ops.ball_query import ball_query from pytorch3d.ops.knn import _KNN from pytorch3d.utils import ico_sphere +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestBallQuery(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_blending.py b/tests/test_blending.py index 13c494fd..7f73ae9d 100644 --- a/tests/test_blending.py +++ b/tests/test_blending.py @@ -7,7 +7,6 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.blending import ( BlendParams, hard_rgb_blend, @@ -18,6 +17,8 @@ from pytorch3d.renderer.cameras import FoVPerspectiveCameras from pytorch3d.renderer.mesh.rasterizer import Fragments from pytorch3d.renderer.splatter_blend import SplatterBlender +from .common_testing import TestCaseMixin + def sigmoid_blend_naive_loop(colors, fragments, blend_params): """ diff --git a/tests/test_build.py b/tests/test_build.py index a466549f..e1d222eb 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -12,7 +12,7 @@ import unittest import unittest.mock from collections import Counter -from common_testing import get_pytorch3d_dir +from .common_testing import get_pytorch3d_dir # This file groups together tests which look at the code without running it. diff --git a/tests/test_camera_conversions.py b/tests/test_camera_conversions.py index 15017a25..b9b208ac 100644 --- a/tests/test_camera_conversions.py +++ b/tests/test_camera_conversions.py @@ -10,7 +10,6 @@ import unittest import numpy as np import torch -from common_testing import get_tests_dir, TestCaseMixin from pytorch3d.ops import eyes from pytorch3d.renderer.points.pulsar import Renderer as PulsarRenderer from pytorch3d.transforms import so3_exp_map, so3_log_map @@ -20,6 +19,8 @@ from pytorch3d.utils import ( pulsar_from_opencv_projection, ) +from .common_testing import get_tests_dir, TestCaseMixin + DATA_DIR = get_tests_dir() / "data" diff --git a/tests/test_camera_pixels.py b/tests/test_camera_pixels.py index 082246b6..3f7e428d 100644 --- a/tests/test_camera_pixels.py +++ b/tests/test_camera_pixels.py @@ -7,7 +7,6 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.renderer import ( MeshRasterizer, NDCMultinomialRaysampler, @@ -19,6 +18,8 @@ from pytorch3d.renderer import ( ) from pytorch3d.structures import Meshes, Pointclouds +from .common_testing import TestCaseMixin + """ PyTorch3D renderers operate in an align_corners=False manner. diff --git a/tests/test_camera_utils.py b/tests/test_camera_utils.py index 32d87c2a..d8cdcfab 100644 --- a/tests/test_camera_utils.py +++ b/tests/test_camera_utils.py @@ -8,7 +8,6 @@ import unittest from math import radians import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.camera_utils import camera_to_eye_at_up, rotate_on_spot from pytorch3d.renderer.cameras import ( get_world_to_view_transform, @@ -18,6 +17,8 @@ from pytorch3d.renderer.cameras import ( from pytorch3d.transforms import axis_angle_to_matrix from torch.nn.functional import normalize +from .common_testing import TestCaseMixin + def _batched_dotprod(x: torch.Tensor, y: torch.Tensor): """ diff --git a/tests/test_cameras.py b/tests/test_cameras.py index d3da872f..80a77df2 100644 --- a/tests/test_cameras.py +++ b/tests/test_cameras.py @@ -36,7 +36,6 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.camera_utils import join_cameras_as_batch from pytorch3d.renderer.cameras import ( camera_position_from_spherical_angles, @@ -57,6 +56,8 @@ from pytorch3d.transforms import Transform3d from pytorch3d.transforms.rotation_conversions import random_rotations from pytorch3d.transforms.so3 import so3_exp_map +from .common_testing import TestCaseMixin + # Naive function adapted from SoftRasterizer for test purposes. def perspective_project_naive(points, fov=60.0): diff --git a/tests/test_cameras_alignment.py b/tests/test_cameras_alignment.py index 3d4fd767..34810648 100644 --- a/tests/test_cameras_alignment.py +++ b/tests/test_cameras_alignment.py @@ -8,7 +8,6 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.ops import corresponding_cameras_alignment from pytorch3d.renderer.cameras import ( OpenGLOrthographicCameras, @@ -18,7 +17,9 @@ from pytorch3d.renderer.cameras import ( ) from pytorch3d.transforms.rotation_conversions import random_rotations from pytorch3d.transforms.so3 import so3_exp_map, so3_relative_angle -from test_cameras import init_random_cameras + +from .common_testing import TestCaseMixin +from .test_cameras import init_random_cameras class TestCamerasAlignment(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_chamfer.py b/tests/test_chamfer.py index 55efe36e..8113d199 100644 --- a/tests/test_chamfer.py +++ b/tests/test_chamfer.py @@ -10,10 +10,11 @@ from collections import namedtuple import numpy as np import torch import torch.nn.functional as F -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.loss import chamfer_distance from pytorch3d.structures.pointclouds import Pointclouds +from .common_testing import get_random_cuda_device, TestCaseMixin + # Output of init_pointclouds points_normals = namedtuple( diff --git a/tests/test_common_linear_with_repeat.py b/tests/test_common_linear_with_repeat.py index dc8ec07e..2b7cb63f 100644 --- a/tests/test_common_linear_with_repeat.py +++ b/tests/test_common_linear_with_repeat.py @@ -7,9 +7,10 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.common.linear_with_repeat import LinearWithRepeat +from .common_testing import TestCaseMixin + class TestLinearWithRepeat(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_common_testing.py b/tests/test_common_testing.py index 9bd02d8d..e57f4c5c 100644 --- a/tests/test_common_testing.py +++ b/tests/test_common_testing.py @@ -8,7 +8,8 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin + +from .common_testing import TestCaseMixin class TestOpsUtils(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_common_workaround.py b/tests/test_common_workaround.py index 793e7c81..1f8e3d5d 100644 --- a/tests/test_common_workaround.py +++ b/tests/test_common_workaround.py @@ -9,9 +9,10 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.common.workaround import _safe_det_3x3 +from .common_testing import TestCaseMixin + class TestSafeDet3x3(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_compositing.py b/tests/test_compositing.py index 1d474da2..5101ad1e 100644 --- a/tests/test_compositing.py +++ b/tests/test_compositing.py @@ -7,13 +7,14 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.renderer.compositing import ( alpha_composite, norm_weighted_sum, weighted_sum, ) +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestAccumulatePoints(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_cubify.py b/tests/test_cubify.py index 02e81b47..1c82919b 100644 --- a/tests/test_cubify.py +++ b/tests/test_cubify.py @@ -7,9 +7,10 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.ops import cubify +from .common_testing import TestCaseMixin + class TestCubify(TestCaseMixin, unittest.TestCase): def test_allempty(self): diff --git a/tests/test_face_areas_normals.py b/tests/test_face_areas_normals.py index 0b3b0fdc..1efe263d 100644 --- a/tests/test_face_areas_normals.py +++ b/tests/test_face_areas_normals.py @@ -8,10 +8,11 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import mesh_face_areas_normals from pytorch3d.structures.meshes import Meshes +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestFaceAreasNormals(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_graph_conv.py b/tests/test_graph_conv.py index c4c16d60..94856ebd 100644 --- a/tests/test_graph_conv.py +++ b/tests/test_graph_conv.py @@ -8,12 +8,13 @@ import unittest import torch import torch.nn as nn -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.ops.graph_conv import gather_scatter, gather_scatter_python, GraphConv from pytorch3d.structures.meshes import Meshes from pytorch3d.utils import ico_sphere +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestGraphConv(TestCaseMixin, unittest.TestCase): def test_undirected(self): diff --git a/tests/test_harmonic_embedding.py b/tests/test_harmonic_embedding.py index 91a6336d..b2b35ba4 100644 --- a/tests/test_harmonic_embedding.py +++ b/tests/test_harmonic_embedding.py @@ -7,9 +7,10 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.implicit import HarmonicEmbedding +from .common_testing import TestCaseMixin + class TestHarmonicEmbedding(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_interpolate_face_attributes.py b/tests/test_interpolate_face_attributes.py index dc67e9a1..8db7f292 100644 --- a/tests/test_interpolate_face_attributes.py +++ b/tests/test_interpolate_face_attributes.py @@ -7,7 +7,6 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops.interp_face_attrs import ( interpolate_face_attributes, interpolate_face_attributes_python, @@ -16,6 +15,8 @@ from pytorch3d.renderer.mesh import TexturesVertex from pytorch3d.renderer.mesh.rasterizer import Fragments from pytorch3d.structures import Meshes +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestInterpolateFaceAttributes(TestCaseMixin, unittest.TestCase): def _test_interp_face_attrs(self, interp_fun, device): diff --git a/tests/test_io_gltf.py b/tests/test_io_gltf.py index d1fa34a0..709c24dd 100644 --- a/tests/test_io_gltf.py +++ b/tests/test_io_gltf.py @@ -9,7 +9,6 @@ from math import radians import numpy as np import torch -from common_testing import get_pytorch3d_dir, get_tests_dir, TestCaseMixin from PIL import Image from pytorch3d.io import IO from pytorch3d.io.experimental_gltf_io import MeshGlbFormat @@ -32,6 +31,8 @@ from pytorch3d.structures import Meshes from pytorch3d.transforms import axis_angle_to_matrix from pytorch3d.vis.texture_vis import texturesuv_image_PIL +from .common_testing import get_pytorch3d_dir, get_tests_dir, TestCaseMixin + DATA_DIR = get_tests_dir() / "data" TUTORIAL_DATA_DIR = get_pytorch3d_dir() / "docs/tutorials/data" diff --git a/tests/test_io_obj.py b/tests/test_io_obj.py index c47a58ad..d4b9a045 100644 --- a/tests/test_io_obj.py +++ b/tests/test_io_obj.py @@ -13,12 +13,6 @@ from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory import torch -from common_testing import ( - get_pytorch3d_dir, - get_tests_dir, - load_rgb_image, - TestCaseMixin, -) from iopath.common.file_io import PathManager from pytorch3d.io import IO, load_obj, load_objs_as_meshes, save_obj from pytorch3d.io.mtl_io import ( @@ -30,6 +24,13 @@ from pytorch3d.renderer import TexturesAtlas, TexturesUV, TexturesVertex from pytorch3d.structures import join_meshes_as_batch, Meshes from pytorch3d.utils import torus +from .common_testing import ( + get_pytorch3d_dir, + get_tests_dir, + load_rgb_image, + TestCaseMixin, +) + DATA_DIR = get_tests_dir() / "data" TUTORIAL_DATA_DIR = get_pytorch3d_dir() / "docs/tutorials/data" diff --git a/tests/test_io_off.py b/tests/test_io_off.py index f96623c7..6a5dc669 100644 --- a/tests/test_io_off.py +++ b/tests/test_io_off.py @@ -8,11 +8,12 @@ import unittest from tempfile import NamedTemporaryFile import torch -from common_testing import TestCaseMixin from pytorch3d.io import IO from pytorch3d.renderer import TexturesAtlas, TexturesVertex from pytorch3d.utils import ico_sphere +from .common_testing import TestCaseMixin + CUBE_FACES = [ [0, 1, 2], diff --git a/tests/test_io_ply.py b/tests/test_io_ply.py index 98394a34..4f32fea6 100644 --- a/tests/test_io_ply.py +++ b/tests/test_io_ply.py @@ -13,7 +13,6 @@ from tempfile import NamedTemporaryFile, TemporaryFile import numpy as np import pytorch3d.io.ply_io import torch -from common_testing import TestCaseMixin from iopath.common.file_io import PathManager from pytorch3d.io import IO from pytorch3d.io.ply_io import load_ply, save_ply @@ -21,6 +20,8 @@ from pytorch3d.renderer.mesh import TexturesVertex from pytorch3d.structures import Meshes, Pointclouds from pytorch3d.utils import torus +from .common_testing import TestCaseMixin + global_path_manager = PathManager() diff --git a/tests/test_iou_box3d.py b/tests/test_iou_box3d.py index bd25d3cd..a1f72780 100644 --- a/tests/test_iou_box3d.py +++ b/tests/test_iou_box3d.py @@ -11,11 +11,12 @@ from typing import List, Tuple, Union import torch import torch.nn.functional as F -from common_testing import get_random_cuda_device, get_tests_dir, TestCaseMixin from pytorch3d.io import save_obj from pytorch3d.ops.iou_box3d import _box_planes, _box_triangles, box3d_overlap from pytorch3d.transforms.rotation_conversions import random_rotation +from .common_testing import get_random_cuda_device, get_tests_dir, TestCaseMixin + OBJECTRON_TO_PYTORCH3D_FACE_IDX = [0, 4, 6, 2, 1, 5, 7, 3] DATA_DIR = get_tests_dir() / "data" diff --git a/tests/test_knn.py b/tests/test_knn.py index d3c56681..bb77911e 100644 --- a/tests/test_knn.py +++ b/tests/test_knn.py @@ -8,9 +8,10 @@ import unittest from itertools import product import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops.knn import _KNN, knn_gather, knn_points +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestKNN(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_laplacian_matrices.py b/tests/test_laplacian_matrices.py index 088efdf1..f04c6dfe 100644 --- a/tests/test_laplacian_matrices.py +++ b/tests/test_laplacian_matrices.py @@ -7,10 +7,11 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import cot_laplacian, laplacian, norm_laplacian from pytorch3d.structures.meshes import Meshes +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestLaplacianMatrices(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_lighting.py b/tests/test_lighting.py index baf245ee..d886e825 100644 --- a/tests/test_lighting.py +++ b/tests/test_lighting.py @@ -8,10 +8,11 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.lighting import AmbientLights, DirectionalLights, PointLights from pytorch3d.transforms import RotateAxisAngle +from .common_testing import TestCaseMixin + class TestLights(TestCaseMixin, unittest.TestCase): def test_init_lights(self): diff --git a/tests/test_marching_cubes.py b/tests/test_marching_cubes.py index 2b8370f4..fd63c6ab 100644 --- a/tests/test_marching_cubes.py +++ b/tests/test_marching_cubes.py @@ -9,9 +9,10 @@ import pickle import unittest import torch -from common_testing import get_tests_dir, TestCaseMixin from pytorch3d.ops.marching_cubes import marching_cubes_naive +from .common_testing import get_tests_dir, TestCaseMixin + USE_SCIKIT = False DATA_DIR = get_tests_dir() / "data" diff --git a/tests/test_materials.py b/tests/test_materials.py index 7a2e2117..4a37fbeb 100644 --- a/tests/test_materials.py +++ b/tests/test_materials.py @@ -7,9 +7,10 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.materials import Materials +from .common_testing import TestCaseMixin + class TestMaterials(TestCaseMixin, unittest.TestCase): def test_init(self): diff --git a/tests/test_mesh_edge_loss.py b/tests/test_mesh_edge_loss.py index 32491358..c18cad3b 100644 --- a/tests/test_mesh_edge_loss.py +++ b/tests/test_mesh_edge_loss.py @@ -7,10 +7,11 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.loss import mesh_edge_loss from pytorch3d.structures import Meshes -from test_sample_points_from_meshes import init_meshes + +from .common_testing import TestCaseMixin +from .test_sample_points_from_meshes import init_meshes class TestMeshEdgeLoss(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_mesh_filtering.py b/tests/test_mesh_filtering.py index 285d89e5..897a5f8a 100644 --- a/tests/test_mesh_filtering.py +++ b/tests/test_mesh_filtering.py @@ -8,11 +8,12 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import taubin_smoothing from pytorch3d.structures import Meshes from pytorch3d.utils import ico_sphere +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestTaubinSmoothing(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_meshes.py b/tests/test_meshes.py index b8b80ba7..7718c187 100644 --- a/tests/test_meshes.py +++ b/tests/test_meshes.py @@ -10,9 +10,10 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.structures.meshes import Meshes +from .common_testing import TestCaseMixin + def init_mesh( num_meshes: int = 10, diff --git a/tests/test_ops_utils.py b/tests/test_ops_utils.py index b1c283d1..81de07f5 100644 --- a/tests/test_ops_utils.py +++ b/tests/test_ops_utils.py @@ -8,9 +8,10 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.ops import utils as oputil +from .common_testing import TestCaseMixin + class TestOpsUtils(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_packed_to_padded.py b/tests/test_packed_to_padded.py index 6114366e..31104efd 100644 --- a/tests/test_packed_to_padded.py +++ b/tests/test_packed_to_padded.py @@ -7,10 +7,11 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.ops import packed_to_padded, padded_to_packed from pytorch3d.structures.meshes import Meshes +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestPackedToPadded(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_perspective_n_points.py b/tests/test_perspective_n_points.py index 29d74120..845d7fc4 100644 --- a/tests/test_perspective_n_points.py +++ b/tests/test_perspective_n_points.py @@ -7,10 +7,11 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.ops import perspective_n_points from pytorch3d.transforms import rotation_conversions +from .common_testing import TestCaseMixin + def reproj_error(x_world, y, R, T, weight=None): # applies the affine transform, projects, and computes the reprojection error diff --git a/tests/test_point_mesh_distance.py b/tests/test_point_mesh_distance.py index cf26c159..2bf86804 100644 --- a/tests/test_point_mesh_distance.py +++ b/tests/test_point_mesh_distance.py @@ -8,11 +8,12 @@ import unittest import numpy as np import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.loss import point_mesh_edge_distance, point_mesh_face_distance from pytorch3d.structures import Meshes, packed_to_list, Pointclouds +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestPointMeshDistance(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_pointclouds.py b/tests/test_pointclouds.py index b2780681..e8dc3d12 100644 --- a/tests/test_pointclouds.py +++ b/tests/test_pointclouds.py @@ -10,10 +10,11 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.structures import utils as struct_utils from pytorch3d.structures.pointclouds import join_pointclouds_as_batch, Pointclouds +from .common_testing import TestCaseMixin + class TestPointclouds(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_points_alignment.py b/tests/test_points_alignment.py index 25c43be8..39b07a2a 100644 --- a/tests/test_points_alignment.py +++ b/tests/test_points_alignment.py @@ -8,11 +8,12 @@ import unittest import numpy as np import torch -from common_testing import get_tests_dir, TestCaseMixin from pytorch3d.ops import points_alignment from pytorch3d.structures.pointclouds import Pointclouds from pytorch3d.transforms import rotation_conversions +from .common_testing import get_tests_dir, TestCaseMixin + def _apply_pcl_transformation(X, R, T, s=None): """ diff --git a/tests/test_points_normals.py b/tests/test_points_normals.py index feb88af7..6c4ab1c8 100644 --- a/tests/test_points_normals.py +++ b/tests/test_points_normals.py @@ -8,13 +8,14 @@ import unittest from typing import Tuple, Union import torch -from common_testing import TestCaseMixin from pytorch3d.ops import ( estimate_pointcloud_local_coord_frames, estimate_pointcloud_normals, ) from pytorch3d.structures.pointclouds import Pointclouds +from .common_testing import TestCaseMixin + DEBUG = False diff --git a/tests/test_points_to_volumes.py b/tests/test_points_to_volumes.py index c7e47f51..0c3d9b1a 100644 --- a/tests/test_points_to_volumes.py +++ b/tests/test_points_to_volumes.py @@ -11,7 +11,6 @@ from typing import Tuple import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.ops import ( add_pointclouds_to_volumes, add_points_features_to_volume_densities_features, @@ -23,6 +22,8 @@ from pytorch3d.structures.pointclouds import Pointclouds from pytorch3d.structures.volumes import Volumes from pytorch3d.transforms.so3 import so3_exp_map +from .common_testing import TestCaseMixin + DEBUG = False if DEBUG: diff --git a/tests/test_r2n2.py b/tests/test_r2n2.py index 5b1308d1..25966631 100644 --- a/tests/test_r2n2.py +++ b/tests/test_r2n2.py @@ -13,7 +13,6 @@ import unittest import numpy as np import torch -from common_testing import get_tests_dir, load_rgb_image, TestCaseMixin from PIL import Image from pytorch3d.datasets import ( BlenderCamera, @@ -32,6 +31,8 @@ from pytorch3d.transforms import Transform3d from pytorch3d.transforms.so3 import so3_exp_map from torch.utils.data import DataLoader +from .common_testing import get_tests_dir, load_rgb_image, TestCaseMixin + # Set these paths in order to run the tests. R2N2_PATH = None diff --git a/tests/test_rasterize_meshes.py b/tests/test_rasterize_meshes.py index ba5da11d..2e858961 100644 --- a/tests/test_rasterize_meshes.py +++ b/tests/test_rasterize_meshes.py @@ -8,7 +8,6 @@ import functools import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.renderer import FoVPerspectiveCameras, look_at_view_transform from pytorch3d.renderer.mesh import MeshRasterizer, RasterizationSettings @@ -23,6 +22,8 @@ from pytorch3d.renderer.mesh.utils import ( from pytorch3d.structures import Meshes from pytorch3d.utils import ico_sphere +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase): def test_simple_python(self): diff --git a/tests/test_rasterize_points.py b/tests/test_rasterize_points.py index 09d4632e..664dac9e 100644 --- a/tests/test_rasterize_points.py +++ b/tests/test_rasterize_points.py @@ -9,7 +9,6 @@ import unittest import numpy as np import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d import _C from pytorch3d.renderer.points.rasterize_points import ( _format_radius, @@ -18,6 +17,8 @@ from pytorch3d.renderer.points.rasterize_points import ( ) from pytorch3d.structures.pointclouds import Pointclouds +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestRasterizePoints(TestCaseMixin, unittest.TestCase): def test_python_simple_cpu(self): diff --git a/tests/test_rasterize_rectangle_images.py b/tests/test_rasterize_rectangle_images.py index c67ae865..0d24719c 100644 --- a/tests/test_rasterize_rectangle_images.py +++ b/tests/test_rasterize_rectangle_images.py @@ -9,12 +9,6 @@ from itertools import product import numpy as np import torch -from common_testing import ( - get_pytorch3d_dir, - get_tests_dir, - load_rgb_image, - TestCaseMixin, -) from PIL import Image from pytorch3d.io import load_obj from pytorch3d.renderer.cameras import FoVPerspectiveCameras, look_at_view_transform @@ -48,6 +42,13 @@ from pytorch3d.structures import Meshes, Pointclouds from pytorch3d.transforms.transform3d import Transform3d from pytorch3d.utils import torus +from .common_testing import ( + get_pytorch3d_dir, + get_tests_dir, + load_rgb_image, + TestCaseMixin, +) + DEBUG = False DATA_DIR = get_tests_dir() / "data" diff --git a/tests/test_rasterizer.py b/tests/test_rasterizer.py index a1f99365..1a9077d6 100644 --- a/tests/test_rasterizer.py +++ b/tests/test_rasterizer.py @@ -9,7 +9,6 @@ import unittest import numpy as np import torch -from common_testing import get_tests_dir from PIL import Image from pytorch3d.renderer.cameras import FoVPerspectiveCameras, look_at_view_transform from pytorch3d.renderer.mesh.rasterizer import MeshRasterizer, RasterizationSettings @@ -20,6 +19,8 @@ from pytorch3d.renderer.points.rasterizer import ( from pytorch3d.structures import Pointclouds from pytorch3d.utils.ico_sphere import ico_sphere +from .common_testing import get_tests_dir + DATA_DIR = get_tests_dir() / "data" DEBUG = False # Set DEBUG to true to save outputs from the tests. diff --git a/tests/test_raymarching.py b/tests/test_raymarching.py index d788de6a..152b52fc 100644 --- a/tests/test_raymarching.py +++ b/tests/test_raymarching.py @@ -7,9 +7,10 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.renderer import AbsorptionOnlyRaymarcher, EmissionAbsorptionRaymarcher +from .common_testing import TestCaseMixin + class TestRaymarching(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_raysampling.py b/tests/test_raysampling.py index da43439e..a731aa8d 100644 --- a/tests/test_raysampling.py +++ b/tests/test_raysampling.py @@ -8,7 +8,6 @@ import unittest from typing import Callable import torch -from common_testing import TestCaseMixin from pytorch3d.common.compat import meshgrid_ij from pytorch3d.ops import eyes from pytorch3d.renderer import ( @@ -32,7 +31,9 @@ from pytorch3d.renderer.implicit.utils import ( ray_bundle_variables_to_ray_points, ) from pytorch3d.transforms import Rotate -from test_cameras import init_random_cameras + +from .common_testing import TestCaseMixin +from .test_cameras import init_random_cameras class TestNDCRaysamplerConvention(TestCaseMixin, unittest.TestCase): diff --git a/tests/test_render_implicit.py b/tests/test_render_implicit.py index 1c9bb302..cc797b7f 100644 --- a/tests/test_render_implicit.py +++ b/tests/test_render_implicit.py @@ -8,7 +8,6 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.renderer import ( BlendParams, EmissionAbsorptionRaymarcher, @@ -28,7 +27,9 @@ from pytorch3d.renderer import ( ) from pytorch3d.structures import Meshes from pytorch3d.utils import ico_sphere -from test_render_volumes import init_cameras + +from .common_testing import TestCaseMixin +from .test_render_volumes import init_cameras DEBUG = False diff --git a/tests/test_render_meshes.py b/tests/test_render_meshes.py index fdca0fdb..b47a78f2 100644 --- a/tests/test_render_meshes.py +++ b/tests/test_render_meshes.py @@ -14,12 +14,6 @@ from collections import namedtuple import numpy as np import torch -from common_testing import ( - get_pytorch3d_dir, - get_tests_dir, - load_rgb_image, - TestCaseMixin, -) from PIL import Image from pytorch3d.io import load_obj from pytorch3d.renderer.cameras import ( @@ -52,6 +46,13 @@ from pytorch3d.structures.meshes import ( from pytorch3d.utils.ico_sphere import ico_sphere from pytorch3d.utils.torus import torus +from .common_testing import ( + get_pytorch3d_dir, + get_tests_dir, + load_rgb_image, + TestCaseMixin, +) + # If DEBUG=True, save out images generated in the tests for debugging. # All saved images have prefix DEBUG_ diff --git a/tests/test_render_meshes_clipped.py b/tests/test_render_meshes_clipped.py index 68954ac5..153d10bd 100644 --- a/tests/test_render_meshes_clipped.py +++ b/tests/test_render_meshes_clipped.py @@ -17,7 +17,6 @@ import unittest import imageio import numpy as np import torch -from common_testing import get_tests_dir, load_rgb_image, TestCaseMixin from pytorch3d.io import save_obj from pytorch3d.renderer.cameras import ( FoVPerspectiveCameras, @@ -39,6 +38,8 @@ from pytorch3d.renderer.mesh.textures import TexturesVertex from pytorch3d.structures.meshes import Meshes from pytorch3d.utils import torus +from .common_testing import get_tests_dir, load_rgb_image, TestCaseMixin + # If DEBUG=True, save out images generated in the tests for debugging. # All saved images have prefix DEBUG_ diff --git a/tests/test_render_multigpu.py b/tests/test_render_multigpu.py index 161101c8..cc7a8b5a 100644 --- a/tests/test_render_multigpu.py +++ b/tests/test_render_multigpu.py @@ -8,7 +8,6 @@ import unittest import torch import torch.nn as nn -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.renderer import ( AlphaCompositor, BlendParams, @@ -28,6 +27,8 @@ from pytorch3d.renderer.cameras import FoVPerspectiveCameras, look_at_view_trans from pytorch3d.structures import Meshes, Pointclouds from pytorch3d.utils.ico_sphere import ico_sphere +from .common_testing import get_random_cuda_device, TestCaseMixin + # Set the number of GPUS you want to test with NUM_GPUS = 3 diff --git a/tests/test_render_points.py b/tests/test_render_points.py index 7278b7c9..28d05177 100644 --- a/tests/test_render_points.py +++ b/tests/test_render_points.py @@ -14,12 +14,6 @@ from os import path import numpy as np import torch -from common_testing import ( - get_pytorch3d_dir, - get_tests_dir, - load_rgb_image, - TestCaseMixin, -) from PIL import Image from pytorch3d.renderer.cameras import ( FoVOrthographicCameras, @@ -40,6 +34,13 @@ from pytorch3d.renderer.points import ( from pytorch3d.structures.pointclouds import Pointclouds from pytorch3d.utils.ico_sphere import ico_sphere +from .common_testing import ( + get_pytorch3d_dir, + get_tests_dir, + load_rgb_image, + TestCaseMixin, +) + # If DEBUG=True, save out images generated in the tests for debugging. # All saved images have prefix DEBUG_ diff --git a/tests/test_render_volumes.py b/tests/test_render_volumes.py index 76b015b8..d1cf4760 100644 --- a/tests/test_render_volumes.py +++ b/tests/test_render_volumes.py @@ -9,7 +9,6 @@ from typing import Optional, Tuple import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.ops import knn_points from pytorch3d.renderer import ( AbsorptionOnlyRaymarcher, @@ -28,7 +27,9 @@ from pytorch3d.renderer import ( ) from pytorch3d.renderer.implicit.utils import _validate_ray_bundle_variables from pytorch3d.structures import Pointclouds, Volumes -from test_points_to_volumes import init_uniform_y_rotations + +from .common_testing import TestCaseMixin +from .test_points_to_volumes import init_uniform_y_rotations DEBUG = False diff --git a/tests/test_rendering_utils.py b/tests/test_rendering_utils.py index a62fc891..fca51d9e 100644 --- a/tests/test_rendering_utils.py +++ b/tests/test_rendering_utils.py @@ -9,7 +9,6 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.common.compat import meshgrid_ij from pytorch3d.ops import eyes from pytorch3d.renderer import ( @@ -26,6 +25,8 @@ from pytorch3d.renderer.utils import ( ) from pytorch3d.structures import Pointclouds +from .common_testing import TestCaseMixin + # Example class for testing class TensorPropertiesTestClass(TensorProperties): diff --git a/tests/test_rotation_conversions.py b/tests/test_rotation_conversions.py index 57454893..7090d3ca 100644 --- a/tests/test_rotation_conversions.py +++ b/tests/test_rotation_conversions.py @@ -13,7 +13,6 @@ from typing import Optional, Union import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.transforms.rotation_conversions import ( axis_angle_to_matrix, axis_angle_to_quaternion, @@ -32,6 +31,8 @@ from pytorch3d.transforms.rotation_conversions import ( rotation_6d_to_matrix, ) +from .common_testing import TestCaseMixin + class TestRandomRotation(unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_sample_farthest_points.py b/tests/test_sample_farthest_points.py index 75ec389c..a0c48628 100644 --- a/tests/test_sample_farthest_points.py +++ b/tests/test_sample_farthest_points.py @@ -8,12 +8,6 @@ import unittest import numpy as np import torch -from common_testing import ( - get_pytorch3d_dir, - get_random_cuda_device, - get_tests_dir, - TestCaseMixin, -) from pytorch3d.io import load_obj from pytorch3d.ops.sample_farthest_points import ( sample_farthest_points, @@ -21,6 +15,13 @@ from pytorch3d.ops.sample_farthest_points import ( ) from pytorch3d.ops.utils import masked_gather +from .common_testing import ( + get_pytorch3d_dir, + get_random_cuda_device, + get_tests_dir, + TestCaseMixin, +) + DATA_DIR = get_tests_dir() / "data" TUTORIAL_DATA_DIR = get_pytorch3d_dir() / "docs/tutorials/data" diff --git a/tests/test_sample_pdf.py b/tests/test_sample_pdf.py index 044758a5..4c904cad 100644 --- a/tests/test_sample_pdf.py +++ b/tests/test_sample_pdf.py @@ -8,9 +8,10 @@ import unittest from itertools import product import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.implicit.sample_pdf import sample_pdf, sample_pdf_python +from .common_testing import TestCaseMixin + class TestSamplePDF(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_sample_points_from_meshes.py b/tests/test_sample_points_from_meshes.py index 4268a488..afe4a3a1 100644 --- a/tests/test_sample_points_from_meshes.py +++ b/tests/test_sample_points_from_meshes.py @@ -9,12 +9,6 @@ import unittest import numpy as np import torch -from common_testing import ( - get_pytorch3d_dir, - get_random_cuda_device, - get_tests_dir, - TestCaseMixin, -) from PIL import Image from pytorch3d.io import load_objs_as_meshes from pytorch3d.ops import sample_points_from_meshes @@ -30,6 +24,13 @@ from pytorch3d.renderer.points import ( from pytorch3d.structures import Meshes, Pointclouds from pytorch3d.utils.ico_sphere import ico_sphere +from .common_testing import ( + get_pytorch3d_dir, + get_random_cuda_device, + get_tests_dir, + TestCaseMixin, +) + # If DEBUG=True, save out images generated in the tests for debugging. # All saved images have prefix DEBUG_ diff --git a/tests/test_se3.py b/tests/test_se3.py index a22ea1c7..27c2f1a8 100644 --- a/tests/test_se3.py +++ b/tests/test_se3.py @@ -9,12 +9,13 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.common.compat import qr from pytorch3d.transforms.rotation_conversions import random_rotations from pytorch3d.transforms.se3 import se3_exp_map, se3_log_map from pytorch3d.transforms.so3 import so3_exp_map, so3_log_map, so3_rotation_angle +from .common_testing import TestCaseMixin + class TestSE3(TestCaseMixin, unittest.TestCase): precomputed_log_transform = torch.tensor( diff --git a/tests/test_shader.py b/tests/test_shader.py index 5512f6e2..4b9654d3 100644 --- a/tests/test_shader.py +++ b/tests/test_shader.py @@ -7,7 +7,6 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.renderer.cameras import look_at_view_transform, PerspectiveCameras from pytorch3d.renderer.mesh.rasterizer import Fragments from pytorch3d.renderer.mesh.shader import ( @@ -18,6 +17,8 @@ from pytorch3d.renderer.mesh.shader import ( ) from pytorch3d.structures.meshes import Meshes +from .common_testing import TestCaseMixin + class TestShader(TestCaseMixin, unittest.TestCase): def test_to(self): diff --git a/tests/test_shapenet_core.py b/tests/test_shapenet_core.py index bc658266..63f1c855 100644 --- a/tests/test_shapenet_core.py +++ b/tests/test_shapenet_core.py @@ -12,7 +12,6 @@ import unittest import numpy as np import torch -from common_testing import get_tests_dir, load_rgb_image, TestCaseMixin from PIL import Image from pytorch3d.datasets import collate_batched_meshes, ShapeNetCore from pytorch3d.renderer import ( @@ -23,6 +22,8 @@ from pytorch3d.renderer import ( ) from torch.utils.data import DataLoader +from .common_testing import get_tests_dir, load_rgb_image, TestCaseMixin + # Set the SHAPENET_PATH to the local path to the dataset SHAPENET_PATH = None diff --git a/tests/test_so3.py b/tests/test_so3.py index 5c30ab14..fa02d6dd 100644 --- a/tests/test_so3.py +++ b/tests/test_so3.py @@ -11,7 +11,6 @@ from distutils.version import LooseVersion import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.common.compat import qr from pytorch3d.transforms.so3 import ( hat, @@ -21,6 +20,8 @@ from pytorch3d.transforms.so3 import ( so3_rotation_angle, ) +from .common_testing import TestCaseMixin + class TestSO3(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_struct_utils.py b/tests/test_struct_utils.py index 58ad8d9d..17df2bee 100644 --- a/tests/test_struct_utils.py +++ b/tests/test_struct_utils.py @@ -8,9 +8,10 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.structures import utils as struct_utils +from .common_testing import TestCaseMixin + class TestStructUtils(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_subdivide_meshes.py b/tests/test_subdivide_meshes.py index 77b80a45..aebef50a 100644 --- a/tests/test_subdivide_meshes.py +++ b/tests/test_subdivide_meshes.py @@ -8,11 +8,12 @@ import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.ops.subdivide_meshes import SubdivideMeshes from pytorch3d.structures.meshes import Meshes from pytorch3d.utils.ico_sphere import ico_sphere +from .common_testing import TestCaseMixin + class TestSubdivideMeshes(TestCaseMixin, unittest.TestCase): def simple_subdivide(self, with_init=False): diff --git a/tests/test_symeig3x3.py b/tests/test_symeig3x3.py index f8f5e445..29a2f955 100644 --- a/tests/test_symeig3x3.py +++ b/tests/test_symeig3x3.py @@ -8,10 +8,11 @@ import unittest import torch -from common_testing import get_random_cuda_device, TestCaseMixin from pytorch3d.common.workaround import symeig3x3 from pytorch3d.transforms.rotation_conversions import random_rotations +from .common_testing import get_random_cuda_device, TestCaseMixin + class TestSymEig3x3(TestCaseMixin, unittest.TestCase): TEST_BATCH_SIZE = 1024 diff --git a/tests/test_texturing.py b/tests/test_texturing.py index 67a8f0c8..d76d15de 100644 --- a/tests/test_texturing.py +++ b/tests/test_texturing.py @@ -9,7 +9,6 @@ import unittest import torch import torch.nn.functional as F -from common_testing import TestCaseMixin from pytorch3d.renderer.mesh.rasterizer import Fragments from pytorch3d.renderer.mesh.textures import ( _list_to_padded_wrapper, @@ -23,7 +22,9 @@ from pytorch3d.renderer.mesh.utils import ( Rectangle, ) from pytorch3d.structures import list_to_packed, Meshes, packed_to_list -from test_meshes import init_mesh + +from .common_testing import TestCaseMixin +from .test_meshes import init_mesh def tryindex(self, index, tex, meshes, source): diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 37a8d0df..a10d12a3 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -9,7 +9,6 @@ import math import unittest import torch -from common_testing import TestCaseMixin from pytorch3d.transforms import random_rotations from pytorch3d.transforms.so3 import so3_exp_map from pytorch3d.transforms.transform3d import ( @@ -20,6 +19,8 @@ from pytorch3d.transforms.transform3d import ( Translate, ) +from .common_testing import TestCaseMixin + class TestTransform(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_vert_align.py b/tests/test_vert_align.py index 286299b4..c264521c 100644 --- a/tests/test_vert_align.py +++ b/tests/test_vert_align.py @@ -9,11 +9,12 @@ import unittest import torch import torch.nn.functional as F -from common_testing import TestCaseMixin from pytorch3d.ops.vert_align import vert_align from pytorch3d.structures.meshes import Meshes from pytorch3d.structures.pointclouds import Pointclouds +from .common_testing import TestCaseMixin + class TestVertAlign(TestCaseMixin, unittest.TestCase): @staticmethod diff --git a/tests/test_volumes.py b/tests/test_volumes.py index a9c2b181..9384d0a5 100644 --- a/tests/test_volumes.py +++ b/tests/test_volumes.py @@ -11,10 +11,11 @@ import unittest import numpy as np import torch -from common_testing import TestCaseMixin from pytorch3d.structures.volumes import Volumes from pytorch3d.transforms import Scale +from .common_testing import TestCaseMixin + class TestVolumes(TestCaseMixin, unittest.TestCase): def setUp(self) -> None: