mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 05:40:34 +08:00
formatting changes from black 22.3.0
Summary: Applies the black-fbsource codemod with the new build of pyfmt. paintitblack Reviewed By: lisroach Differential Revision: D36324783 fbshipit-source-id: 280c09e88257e5e569ab729691165d8dedd767bc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c21ba144e7
commit
bef959c755
@@ -15,7 +15,7 @@ def bm_render_volumes() -> None:
|
||||
case_grid = {
|
||||
"batch_size": [1, 5],
|
||||
"raymarcher_type": [EmissionAbsorptionRaymarcher, AbsorptionOnlyRaymarcher],
|
||||
"n_rays_per_image": [64 ** 2, 256 ** 2],
|
||||
"n_rays_per_image": [64**2, 256**2],
|
||||
"n_pts_per_ray": [16, 128],
|
||||
}
|
||||
test_cases = itertools.product(*case_grid.values())
|
||||
|
||||
@@ -17,7 +17,7 @@ def bm_render_volumes() -> None:
|
||||
"batch_size": [1, 5],
|
||||
"shape": ["sphere", "cube"],
|
||||
"raymarcher_type": [EmissionAbsorptionRaymarcher, AbsorptionOnlyRaymarcher],
|
||||
"n_rays_per_image": [64 ** 2, 256 ** 2],
|
||||
"n_rays_per_image": [64**2, 256**2],
|
||||
"n_pts_per_ray": [16, 128],
|
||||
}
|
||||
test_cases = itertools.product(*case_grid.values())
|
||||
|
||||
@@ -124,7 +124,7 @@ class TestEvaluation(unittest.TestCase):
|
||||
)
|
||||
self.assertGreater(
|
||||
float(mse_depth_unmasked.sum()),
|
||||
float(diff ** 2),
|
||||
float(diff**2),
|
||||
)
|
||||
self.assertGreater(
|
||||
float(abs_depth_unmasked.sum()),
|
||||
@@ -143,7 +143,7 @@ class TestEvaluation(unittest.TestCase):
|
||||
)
|
||||
if _mask_gt is not None:
|
||||
expected_err_abs = diff
|
||||
expected_err_mse = diff ** 2
|
||||
expected_err_mse = diff**2
|
||||
else:
|
||||
err_mask = (gt > 0.0).float() * mask
|
||||
if crop > 0:
|
||||
@@ -195,7 +195,7 @@ class TestEvaluation(unittest.TestCase):
|
||||
)
|
||||
self.assertAlmostEqual(float(psnr), float(psnr_cv2), delta=1e-4)
|
||||
# check that all PSNRs are bigger than the minimum possible PSNR
|
||||
max_mse = max_diff ** 2
|
||||
max_mse = max_diff**2
|
||||
min_psnr = 10 * math.log10(1.0 / max_mse)
|
||||
for _im1, _im2 in zip(im1, im2):
|
||||
_psnr = calc_psnr(_im1, _im2)
|
||||
|
||||
@@ -66,7 +66,7 @@ class TestAcosLinearExtrapolation(TestCaseMixin, unittest.TestCase):
|
||||
# fit a line: slope * x + bias = y
|
||||
x_1 = torch.stack([x, torch.ones_like(x)], dim=-1)
|
||||
slope, bias = lstsq(x_1, y[:, None]).view(-1)[:2]
|
||||
desired_slope = (-1.0) / torch.sqrt(1.0 - bound_t ** 2)
|
||||
desired_slope = (-1.0) / torch.sqrt(1.0 - bound_t**2)
|
||||
# test that the desired slope is the same as the fitted one
|
||||
self.assertClose(desired_slope.view(1), slope.view(1), atol=1e-2)
|
||||
# test that the autograd's slope is the same as the desired one
|
||||
|
||||
@@ -412,7 +412,7 @@ class TestSpecularLighting(TestCaseMixin, unittest.TestCase):
|
||||
camera_position=camera_position[None, :],
|
||||
shininess=torch.tensor(10),
|
||||
)
|
||||
self.assertClose(output_light, expected_output ** 10)
|
||||
self.assertClose(output_light, expected_output**10)
|
||||
|
||||
def test_specular_batched(self):
|
||||
batch_size = 10
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
||||
torch.manual_seed(231)
|
||||
device = torch.device("cpu")
|
||||
image_size = 32
|
||||
blur_radius = 0.1 ** 2
|
||||
blur_radius = 0.1**2
|
||||
faces_per_pixel = 3
|
||||
|
||||
for d in ["cpu", get_random_cuda_device()]:
|
||||
@@ -167,7 +167,7 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
torch.manual_seed(231)
|
||||
image_size = 64
|
||||
radius = 0.1 ** 2
|
||||
radius = 0.1**2
|
||||
faces_per_pixel = 3
|
||||
device = torch.device("cpu")
|
||||
meshes_cpu = ico_sphere(0, device)
|
||||
@@ -224,7 +224,7 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
||||
# Make sure that the backward pass runs for all pathways
|
||||
image_size = 64 # test is too slow for very large images.
|
||||
N = 1
|
||||
radius = 0.1 ** 2
|
||||
radius = 0.1**2
|
||||
faces_per_pixel = 3
|
||||
|
||||
grad_zbuf = torch.randn(N, image_size, image_size, faces_per_pixel)
|
||||
@@ -997,7 +997,7 @@ class TestRasterizeMeshes(TestCaseMixin, unittest.TestCase):
|
||||
ordering of faces.
|
||||
"""
|
||||
image_size = 10
|
||||
blur_radius = 0.12 ** 2
|
||||
blur_radius = 0.12**2
|
||||
faces_per_pixel = 1
|
||||
|
||||
# fmt: off
|
||||
|
||||
@@ -60,13 +60,13 @@ def spherical_volumetric_function(
|
||||
|
||||
# the squared distance of each ray point to the centroid of the sphere
|
||||
surface_dist = (
|
||||
(surface_vectors ** 2)
|
||||
(surface_vectors**2)
|
||||
.sum(-1, keepdim=True)
|
||||
.view(*rays_points_world.shape[:-1], 1)
|
||||
)
|
||||
|
||||
# set all ray densities within the sphere_diameter distance from the centroid to 1
|
||||
rays_densities = torch.sigmoid(-100.0 * (surface_dist - sphere_diameter ** 2))
|
||||
rays_densities = torch.sigmoid(-100.0 * (surface_dist - sphere_diameter**2))
|
||||
|
||||
# ray colors are proportional to the normalized surface_vectors
|
||||
rays_features = (
|
||||
|
||||
@@ -128,7 +128,7 @@ class TestSamplePoints(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
# Sphere: points should have radius 1.
|
||||
x, y, z = samples[1, :].unbind(1)
|
||||
radius = torch.sqrt(x ** 2 + y ** 2 + z ** 2)
|
||||
radius = torch.sqrt(x**2 + y**2 + z**2)
|
||||
|
||||
self.assertClose(radius, torch.ones(num_samples))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user