mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-01-16 19:30:34 +08:00
Address black + isort fbsource linter warnings
Summary: Address black + isort fbsource linter warnings from D20558374 (previous diff) Reviewed By: nikhilaravi Differential Revision: D20558373 fbshipit-source-id: d3607de4a01fb24c0d5269634563a7914bddf1c8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb512ffde3
commit
d57daa6f85
@@ -3,8 +3,8 @@
|
||||
|
||||
import math
|
||||
import unittest
|
||||
import torch
|
||||
|
||||
import torch
|
||||
from pytorch3d.transforms.so3 import so3_exponential_map
|
||||
from pytorch3d.transforms.transform3d import (
|
||||
Rotate,
|
||||
@@ -18,9 +18,7 @@ from pytorch3d.transforms.transform3d import (
|
||||
class TestTransform(unittest.TestCase):
|
||||
def test_to(self):
|
||||
tr = Translate(torch.FloatTensor([[1.0, 2.0, 3.0]]))
|
||||
R = torch.FloatTensor(
|
||||
[[0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]]
|
||||
)
|
||||
R = torch.FloatTensor([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]])
|
||||
R = Rotate(R)
|
||||
t = Transform3d().compose(R, tr)
|
||||
for _ in range(3):
|
||||
@@ -36,9 +34,7 @@ class TestTransform(unittest.TestCase):
|
||||
the same as composition of clones of translation and rotation.
|
||||
"""
|
||||
tr = Translate(torch.FloatTensor([[1.0, 2.0, 3.0]]))
|
||||
R = torch.FloatTensor(
|
||||
[[0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]]
|
||||
)
|
||||
R = torch.FloatTensor([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]])
|
||||
R = Rotate(R)
|
||||
|
||||
# check that the _matrix property of clones of
|
||||
@@ -63,9 +59,9 @@ class TestTransform(unittest.TestCase):
|
||||
|
||||
def test_translate(self):
|
||||
t = Transform3d().translate(1, 2, 3)
|
||||
points = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.5, 0.5, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
points = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.5, 0.5, 0.0]]).view(
|
||||
1, 3, 3
|
||||
)
|
||||
normals = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
@@ -82,9 +78,9 @@ class TestTransform(unittest.TestCase):
|
||||
|
||||
def test_scale(self):
|
||||
t = Transform3d().scale(2.0).scale(0.5, 0.25, 1.0)
|
||||
points = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.5, 0.5, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
points = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.5, 0.5, 0.0]]).view(
|
||||
1, 3, 3
|
||||
)
|
||||
normals = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
@@ -101,9 +97,9 @@ class TestTransform(unittest.TestCase):
|
||||
|
||||
def test_scale_translate(self):
|
||||
t = Transform3d().scale(2, 1, 3).translate(1, 2, 3)
|
||||
points = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.5, 0.5, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
points = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.5, 0.5, 0.0]]).view(
|
||||
1, 3, 3
|
||||
)
|
||||
normals = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
@@ -120,9 +116,9 @@ class TestTransform(unittest.TestCase):
|
||||
|
||||
def test_rotate_axis_angle(self):
|
||||
t = Transform3d().rotate_axis_angle(90.0, axis="Z")
|
||||
points = torch.tensor(
|
||||
[[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 1.0]]
|
||||
).view(1, 3, 3)
|
||||
points = torch.tensor([[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 1.0]]).view(
|
||||
1, 3, 3
|
||||
)
|
||||
normals = torch.tensor(
|
||||
[[1.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 0.0, 0.0]]
|
||||
).view(1, 3, 3)
|
||||
@@ -194,9 +190,7 @@ class TestTransform(unittest.TestCase):
|
||||
t_ = Rotate(
|
||||
so3_exponential_map(
|
||||
torch.randn(
|
||||
(batch_size, 3),
|
||||
dtype=torch.float32,
|
||||
device=device,
|
||||
(batch_size, 3), dtype=torch.float32, device=device
|
||||
)
|
||||
),
|
||||
device=device,
|
||||
@@ -717,9 +711,7 @@ class TestRotate(unittest.TestCase):
|
||||
|
||||
def test_inverse(self, batch_size=5):
|
||||
device = torch.device("cuda:0")
|
||||
log_rot = torch.randn(
|
||||
(batch_size, 3), dtype=torch.float32, device=device
|
||||
)
|
||||
log_rot = torch.randn((batch_size, 3), dtype=torch.float32, device=device)
|
||||
R = so3_exponential_map(log_rot)
|
||||
t = Rotate(R)
|
||||
im = t.inverse()._matrix
|
||||
@@ -749,9 +741,7 @@ class TestRotateAxisAngle(unittest.TestCase):
|
||||
transformed_points = t.transform_points(points)
|
||||
expected_points = torch.tensor([0.0, 0.0, 1.0])
|
||||
self.assertTrue(
|
||||
torch.allclose(
|
||||
transformed_points.squeeze(), expected_points, atol=1e-7
|
||||
)
|
||||
torch.allclose(transformed_points.squeeze(), expected_points, atol=1e-7)
|
||||
)
|
||||
self.assertTrue(torch.allclose(t._matrix, matrix))
|
||||
|
||||
@@ -775,9 +765,7 @@ class TestRotateAxisAngle(unittest.TestCase):
|
||||
transformed_points = t.transform_points(points)
|
||||
expected_points = torch.tensor([0.0, 0.0, 1.0])
|
||||
self.assertTrue(
|
||||
torch.allclose(
|
||||
transformed_points.squeeze(), expected_points, atol=1e-7
|
||||
)
|
||||
torch.allclose(transformed_points.squeeze(), expected_points, atol=1e-7)
|
||||
)
|
||||
self.assertTrue(torch.allclose(t._matrix, matrix, atol=1e-7))
|
||||
|
||||
@@ -835,9 +823,7 @@ class TestRotateAxisAngle(unittest.TestCase):
|
||||
transformed_points = t.transform_points(points)
|
||||
expected_points = torch.tensor([0.0, 0.0, -1.0])
|
||||
self.assertTrue(
|
||||
torch.allclose(
|
||||
transformed_points.squeeze(), expected_points, atol=1e-7
|
||||
)
|
||||
torch.allclose(transformed_points.squeeze(), expected_points, atol=1e-7)
|
||||
)
|
||||
self.assertTrue(torch.allclose(t._matrix, matrix, atol=1e-7))
|
||||
|
||||
@@ -866,9 +852,7 @@ class TestRotateAxisAngle(unittest.TestCase):
|
||||
transformed_points = t.transform_points(points)
|
||||
expected_points = torch.tensor([0.0, 0.0, -1.0])
|
||||
self.assertTrue(
|
||||
torch.allclose(
|
||||
transformed_points.squeeze(), expected_points, atol=1e-7
|
||||
)
|
||||
torch.allclose(transformed_points.squeeze(), expected_points, atol=1e-7)
|
||||
)
|
||||
self.assertTrue(torch.allclose(t._matrix, matrix, atol=1e-7))
|
||||
|
||||
@@ -923,9 +907,7 @@ class TestRotateAxisAngle(unittest.TestCase):
|
||||
transformed_points = t.transform_points(points)
|
||||
expected_points = torch.tensor([0.0, 1.0, 0.0])
|
||||
self.assertTrue(
|
||||
torch.allclose(
|
||||
transformed_points.squeeze(), expected_points, atol=1e-7
|
||||
)
|
||||
torch.allclose(transformed_points.squeeze(), expected_points, atol=1e-7)
|
||||
)
|
||||
self.assertTrue(torch.allclose(t._matrix, matrix, atol=1e-7))
|
||||
|
||||
@@ -949,9 +931,7 @@ class TestRotateAxisAngle(unittest.TestCase):
|
||||
transformed_points = t.transform_points(points)
|
||||
expected_points = torch.tensor([0.0, 1.0, 0.0])
|
||||
self.assertTrue(
|
||||
torch.allclose(
|
||||
transformed_points.squeeze(), expected_points, atol=1e-7
|
||||
)
|
||||
torch.allclose(transformed_points.squeeze(), expected_points, atol=1e-7)
|
||||
)
|
||||
self.assertTrue(torch.allclose(t._matrix, matrix, atol=1e-7))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user