Skip to content

Commit

Permalink
Followup D33970393 (auto typing)
Browse files Browse the repository at this point in the history
Summary: D33970393 (e9fb6c2) ran an inference to add some typing. Remove some where it was a bit too confident. (Also fix some pyre errors in plotly_vis caused by new mismatch.)

Reviewed By: patricklabatut

Differential Revision: D34004689

fbshipit-source-id: 430182b0ff0b91be542a3120da6d6b1d2b247c59
  • Loading branch information
bottler authored and facebook-github-bot committed Feb 9, 2022
1 parent e9fb6c2 commit 47c0997
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 30 deletions.
3 changes: 1 addition & 2 deletions pytorch3d/ops/points_normals.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def estimate_pointcloud_local_coord_frames(
return curvatures, local_coord_frames


def _disambiguate_vector_directions(pcl, knns, vecs: float) -> float:
def _disambiguate_vector_directions(pcl, knns, vecs):
"""
Disambiguates normal directions according to [1].
Expand All @@ -180,7 +180,6 @@ def _disambiguate_vector_directions(pcl, knns, vecs: float) -> float:
# each element of the neighborhood
df = knns - pcl[:, :, None]
# projection of the difference on the principal direction
# pyre-fixme[16]: `float` has no attribute `__getitem__`.
proj = (vecs[:, :, None] * df).sum(3)
# check how many projections are positive
n_pos = (proj > 0).type_as(knns).sum(2, keepdim=True)
Expand Down
4 changes: 1 addition & 3 deletions pytorch3d/ops/subdivide_meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def create_verts_index(verts_per_mesh, edges_per_mesh, device=None):
return verts_idx


def create_faces_index(faces_per_mesh: int, device=None):
def create_faces_index(faces_per_mesh, device=None):
"""
Helper function to group the faces indices for each mesh. New faces are
stacked at the end of the original faces tensor, so in order to have
Expand All @@ -417,9 +417,7 @@ def create_faces_index(faces_per_mesh: int, device=None):
"""
# e.g. faces_per_mesh = [2, 5, 3]

# pyre-fixme[16]: `int` has no attribute `sum`.
F = faces_per_mesh.sum() # e.g. 10
# pyre-fixme[16]: `int` has no attribute `cumsum`.
faces_per_mesh_cumsum = faces_per_mesh.cumsum(dim=0) # (N,) e.g. (2, 7, 10)

switch1_idx = faces_per_mesh_cumsum.clone()
Expand Down
30 changes: 15 additions & 15 deletions pytorch3d/renderer/cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ def __getitem__(


def OpenGLPerspectiveCameras(
znear: float = 1.0,
zfar: float = 100.0,
aspect_ratio: float = 1.0,
fov: float = 60.0,
znear=1.0,
zfar=100.0,
aspect_ratio=1.0,
fov=60.0,
degrees: bool = True,
R: torch.Tensor = _R,
T: torch.Tensor = _T,
Expand Down Expand Up @@ -709,12 +709,12 @@ def in_ndc(self):


def OpenGLOrthographicCameras(
znear: float = 1.0,
zfar: float = 100.0,
top: float = 1.0,
bottom: float = -1.0,
left: float = -1.0,
right: float = 1.0,
znear=1.0,
zfar=100.0,
top=1.0,
bottom=-1.0,
left=-1.0,
right=1.0,
scale_xyz=((1.0, 1.0, 1.0),), # (1, 3)
R: torch.Tensor = _R,
T: torch.Tensor = _T,
Expand Down Expand Up @@ -956,7 +956,7 @@ def in_ndc(self):


def SfMPerspectiveCameras(
focal_length: float = 1.0,
focal_length=1.0,
principal_point=((0.0, 0.0),),
R: torch.Tensor = _R,
T: torch.Tensor = _T,
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def in_ndc(self):


def SfMOrthographicCameras(
focal_length: float = 1.0,
focal_length=1.0,
principal_point=((0.0, 0.0),),
R: torch.Tensor = _R,
T: torch.Tensor = _T,
Expand Down Expand Up @@ -1645,9 +1645,9 @@ def look_at_rotation(


def look_at_view_transform(
dist: float = 1.0,
elev: float = 0.0,
azim: float = 0.0,
dist=1.0,
elev=0.0,
azim=0.0,
degrees: bool = True,
eye: Optional[Sequence] = None,
at=((0, 0, 0),), # (1, 3)
Expand Down
12 changes: 3 additions & 9 deletions pytorch3d/vis/plotly_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ def plot_scene(

camera = {
"up": {
"x": 0,
"y": 1,
"z": 0,
"x": 0.0,
"y": 1.0,
"z": 0.0,
} # set the up vector to match PyTorch3D world coordinates conventions
}
viewpoints_eye_at_up_world = None
Expand Down Expand Up @@ -358,14 +358,8 @@ def plot_scene(
up_y = _scale_camera_to_bounds(up_y, y_range, False)
up_z = _scale_camera_to_bounds(up_z, z_range, False)

# pyre-fixme[6]: For 2nd param expected `Dict[str, int]` but got
# `Dict[str, float]`.
camera["eye"] = {"x": eye_x, "y": eye_y, "z": eye_z}
# pyre-fixme[6]: For 2nd param expected `Dict[str, int]` but got
# `Dict[str, float]`.
camera["center"] = {"x": at_x, "y": at_y, "z": at_z}
# pyre-fixme[6]: For 2nd param expected `Dict[str, int]` but got
# `Dict[str, float]`.
camera["up"] = {"x": up_x, "y": up_y, "z": up_z}

current_layout.update(
Expand Down
2 changes: 1 addition & 1 deletion pytorch3d/vis/texture_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def texturesuv_image_PIL(
*,
texture_index: int = 0,
radius: float = 1,
color: str = "red",
color="red",
subsample: Optional[int] = 10000,
): # pragma: no cover
"""
Expand Down

0 comments on commit 47c0997

Please sign in to comment.