From 3b2300641ae2e8ac8f8c8a3b5b3363fa204d6417 Mon Sep 17 00:00:00 2001 From: John Reese Date: Sun, 15 May 2022 12:53:03 -0700 Subject: [PATCH] apply import merging for fbcode (11 of 11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Applies new import merging and sorting from µsort v1.0. When merging imports, µsort will make a best-effort to move associated comments to match merged elements, but there are known limitations due to the diynamic nature of Python and developer tooling. These changes should not produce any dangerous runtime changes, but may require touch-ups to satisfy linters and other tooling. Note that µsort uses case-insensitive, lexicographical sorting, which results in a different ordering compared to isort. This provides a more consistent sorting order, matching the case-insensitive order used when sorting import statements by module name, and ensures that "frog", "FROG", and "Frog" always sort next to each other. For details on µsort's sorting and merging semantics, see the user guide: https://usort.readthedocs.io/en/stable/guide.html#sorting Reviewed By: lisroach Differential Revision: D36402260 fbshipit-source-id: 7cb52f09b740ccc580e61e6d1787d27381a8ce00 --- pytorch3d/implicitron/dataset/types.py | 4 ++-- pytorch3d/implicitron/models/renderer/ray_sampler.py | 2 +- pytorch3d/implicitron/models/renderer/raymarcher.py | 2 +- pytorch3d/ops/points_normals.py | 2 +- pytorch3d/ops/points_to_volumes.py | 2 +- pytorch3d/renderer/cameras.py | 2 +- pytorch3d/renderer/mesh/textures.py | 4 ++-- tests/implicitron/test_evaluation.py | 4 +--- tests/test_texturing.py | 6 +++--- 9 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pytorch3d/implicitron/dataset/types.py b/pytorch3d/implicitron/dataset/types.py index c610642e..d1dd0a48 100644 --- a/pytorch3d/implicitron/dataset/types.py +++ b/pytorch3d/implicitron/dataset/types.py @@ -8,8 +8,8 @@ import dataclasses import gzip import json -from dataclasses import MISSING, Field, dataclass -from typing import IO, Any, Optional, Tuple, Type, TypeVar, Union, cast +from dataclasses import dataclass, Field, MISSING +from typing import Any, cast, IO, Optional, Tuple, Type, TypeVar, Union import numpy as np from pytorch3d.common.datatypes import get_args, get_origin diff --git a/pytorch3d/implicitron/models/renderer/ray_sampler.py b/pytorch3d/implicitron/models/renderer/ray_sampler.py index ef381a2f..89dc6d54 100644 --- a/pytorch3d/implicitron/models/renderer/ray_sampler.py +++ b/pytorch3d/implicitron/models/renderer/ray_sampler.py @@ -9,7 +9,7 @@ from typing import Optional, Tuple import torch from pytorch3d.implicitron.tools import camera_utils -from pytorch3d.implicitron.tools.config import ReplaceableBase, registry +from pytorch3d.implicitron.tools.config import registry, ReplaceableBase from pytorch3d.renderer import NDCMultinomialRaysampler, RayBundle from pytorch3d.renderer.cameras import CamerasBase diff --git a/pytorch3d/implicitron/models/renderer/raymarcher.py b/pytorch3d/implicitron/models/renderer/raymarcher.py index 81495bda..b9cd2980 100644 --- a/pytorch3d/implicitron/models/renderer/raymarcher.py +++ b/pytorch3d/implicitron/models/renderer/raymarcher.py @@ -8,7 +8,7 @@ from typing import Any, Callable, Dict, Tuple import torch from pytorch3d.implicitron.models.renderer.base import RendererOutput -from pytorch3d.implicitron.tools.config import ReplaceableBase, registry +from pytorch3d.implicitron.tools.config import registry, ReplaceableBase from pytorch3d.renderer.implicit.raymarching import _check_raymarcher_inputs diff --git a/pytorch3d/ops/points_normals.py b/pytorch3d/ops/points_normals.py index edd0293e..2515020c 100644 --- a/pytorch3d/ops/points_normals.py +++ b/pytorch3d/ops/points_normals.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from typing import TYPE_CHECKING, Tuple, Union +from typing import Tuple, TYPE_CHECKING, Union import torch from pytorch3d.common.compat import eigh diff --git a/pytorch3d/ops/points_to_volumes.py b/pytorch3d/ops/points_to_volumes.py index e7a854e1..5cba9fe1 100644 --- a/pytorch3d/ops/points_to_volumes.py +++ b/pytorch3d/ops/points_to_volumes.py @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -from typing import TYPE_CHECKING, Optional, Tuple +from typing import Optional, Tuple, TYPE_CHECKING import torch from pytorch3d import _C diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index dbff8a6e..002c21ec 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -14,7 +14,7 @@ import torch.nn.functional as F from pytorch3d.common.datatypes import Device from pytorch3d.transforms import Rotate, Transform3d, Translate -from .utils import TensorProperties, convert_to_tensors_and_broadcast +from .utils import convert_to_tensors_and_broadcast, TensorProperties # Default values for rotation and translation matrices. diff --git a/pytorch3d/renderer/mesh/textures.py b/pytorch3d/renderer/mesh/textures.py index 4bf442e6..f4960c87 100644 --- a/pytorch3d/renderer/mesh/textures.py +++ b/pytorch3d/renderer/mesh/textures.py @@ -6,7 +6,7 @@ import itertools import warnings -from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union +from typing import Dict, List, Optional, Tuple, TYPE_CHECKING, Union import torch import torch.nn.functional as F @@ -14,7 +14,7 @@ from pytorch3d.ops import interpolate_face_attributes from pytorch3d.structures.utils import list_to_packed, list_to_padded, padded_to_list from torch.nn.functional import interpolate -from .utils import PackedRectangle, Rectangle, pack_unique_rectangles +from .utils import pack_unique_rectangles, PackedRectangle, Rectangle # This file contains classes and helper functions for texturing. diff --git a/tests/implicitron/test_evaluation.py b/tests/implicitron/test_evaluation.py index 52c4773a..78e8a16f 100644 --- a/tests/implicitron/test_evaluation.py +++ b/tests/implicitron/test_evaluation.py @@ -18,9 +18,7 @@ from pytorch3d.implicitron.dataset.implicitron_dataset import ( FrameData, ImplicitronDataset, ) -from pytorch3d.implicitron.evaluation.evaluate_new_view_synthesis import ( - eval_batch, -) +from pytorch3d.implicitron.evaluation.evaluate_new_view_synthesis import eval_batch from pytorch3d.implicitron.models.base_model import ImplicitronModelBase from pytorch3d.implicitron.models.generic_model import GenericModel # noqa from pytorch3d.implicitron.models.model_dbir import ModelDBIR # noqa diff --git a/tests/test_texturing.py b/tests/test_texturing.py index a4e8cf15..67a8f0c8 100644 --- a/tests/test_texturing.py +++ b/tests/test_texturing.py @@ -12,17 +12,17 @@ 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, TexturesAtlas, TexturesUV, TexturesVertex, - _list_to_padded_wrapper, ) from pytorch3d.renderer.mesh.utils import ( - Rectangle, pack_rectangles, pack_unique_rectangles, + Rectangle, ) -from pytorch3d.structures import Meshes, list_to_packed, packed_to_list +from pytorch3d.structures import list_to_packed, Meshes, packed_to_list from test_meshes import init_mesh