From 03f441e7ca98bff9dbadb2a72702560456c36092 Mon Sep 17 00:00:00 2001 From: Georgia Gkioxari Date: Sat, 21 Mar 2020 17:55:21 -0700 Subject: [PATCH] run lint Summary: Run `/dev/linter.sh` to fix linting Reviewed By: nikhilaravi Differential Revision: D20584037 fbshipit-source-id: 69e45b33d22e3d54b6d37c3c35580bb3e9dc50a5 --- pytorch3d/renderer/cameras.py | 11 +++++++---- tests/test_cameras.py | 2 +- tests/test_compositing.py | 2 +- tests/test_sample_points_from_meshes.py | 13 +++++++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index 94ae48d3..31d421f5 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -2,7 +2,7 @@ import math import numpy as np -from typing import Tuple, Optional, Sequence +from typing import Optional, Sequence, Tuple import torch import torch.nn.functional as F @@ -1039,15 +1039,18 @@ def look_at_view_transform( if eye is not None: broadcasted_args = convert_to_tensors_and_broadcast( - eye, at, up, device=device) + eye, at, up, device=device + ) eye, at, up = broadcasted_args C = eye else: broadcasted_args = convert_to_tensors_and_broadcast( - dist, elev, azim, at, up, device=device) + dist, elev, azim, at, up, device=device + ) dist, elev, azim, at, up = broadcasted_args C = camera_position_from_spherical_angles( - dist, elev, azim, degrees=degrees, device=device) + dist, elev, azim, degrees=degrees, device=device + ) R = look_at_rotation(C, at, up, device=device) T = -torch.bmm(R.transpose(1, 2), C[:, :, None])[:, :, 0] diff --git a/tests/test_cameras.py b/tests/test_cameras.py index f23ca6b2..f5ba0221 100644 --- a/tests/test_cameras.py +++ b/tests/test_cameras.py @@ -121,7 +121,7 @@ class TestCameraHelpers(unittest.TestCase): dist = math.sqrt(2) elev = math.pi / 4 azim = 0.0 - eye = ((0.0, 1.0, 1.0), ) + eye = ((0.0, 1.0, 1.0),) # using passed values for dist, elev, azim R, t = look_at_view_transform(dist, elev, azim, degrees=False) # using other values for dist, elev, azim - eye overrides diff --git a/tests/test_compositing.py b/tests/test_compositing.py index a0d1a444..7f4a5753 100644 --- a/tests/test_compositing.py +++ b/tests/test_compositing.py @@ -188,7 +188,7 @@ class TestAccumulatePoints(unittest.TestCase): ): res1 = fn1(*args1) res2 = fn2(*args2) - + self.assertTrue(torch.allclose(res1.cpu(), res2.cpu(), atol=1e-6)) if not compare_grads: diff --git a/tests/test_sample_points_from_meshes.py b/tests/test_sample_points_from_meshes.py index 7225de5b..3d4d6a32 100644 --- a/tests/test_sample_points_from_meshes.py +++ b/tests/test_sample_points_from_meshes.py @@ -291,7 +291,7 @@ class TestSamplePoints(unittest.TestCase): if sampled_weights.min() <= 0: return False return True - + def test_verts_nan(self): num_verts = 30 num_faces = 50 @@ -300,14 +300,19 @@ class TestSamplePoints(unittest.TestCase): verts = torch.rand( (num_verts, 3), dtype=torch.float32, device=device ) - # randomly assign an invalid type + # randomly assign an invalid type verts[torch.randperm(num_verts)[:10]] = float(invalid) faces = torch.randint( - num_verts, size=(num_faces, 3), dtype=torch.int64, device=device + num_verts, + size=(num_faces, 3), + dtype=torch.int64, + device=device, ) meshes = Meshes(verts=[verts], faces=[faces]) - with self.assertRaisesRegex(ValueError, "Meshes contain nan or inf."): + with self.assertRaisesRegex( + ValueError, "Meshes contain nan or inf." + ): sample_points_from_meshes( meshes, num_samples=100, return_normals=True )