linter comment strictnesss

Summary: The linter has become stricter about the indenting of comments and docstrings. This was accompanied by a codemod. In a few places we can fix the problem nicer than the codemod has.

Reviewed By: gkioxari

Differential Revision: D24363880

fbshipit-source-id: 4cff3bbe3d2a834bc92a490469a2b24fa376e6ab
This commit is contained in:
Jeremy Reizenstein 2020-10-18 02:37:41 -07:00 committed by Facebook GitHub Bot
parent 563d441b00
commit 30e4e891db
4 changed files with 283 additions and 283 deletions

View File

@ -346,7 +346,7 @@ class SoftSilhouetteShader(nn.Module):
self.blend_params = blend_params if blend_params is not None else BlendParams() self.blend_params = blend_params if blend_params is not None else BlendParams()
def forward(self, fragments, meshes, **kwargs) -> torch.Tensor: def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
""" " """
Only want to render the silhouette so RGB values can be ones. Only want to render the silhouette so RGB values can be ones.
There is no need for lighting or texturing There is no need for lighting or texturing
""" """

View File

@ -78,68 +78,68 @@ def _try_place_rectangle(
occupied: List[Tuple[int, int]], occupied: List[Tuple[int, int]],
) -> bool: ) -> bool:
""" """
Try to place rect within the current bounding box. Try to place rect within the current bounding box.
Part of the implementation of pack_rectangles. Part of the implementation of pack_rectangles.
Note that the arguments `placed_so_far` and `occupied` are modified. Note that the arguments `placed_so_far` and `occupied` are modified.
Args: Args:
rect: rectangle to place rect: rectangle to place
placed_so_far: the locations decided upon so far - a list of placed_so_far: the locations decided upon so far - a list of
(x, y, whether flipped). The nth element is the (x, y, whether flipped). The nth element is the
location of the nth rectangle if it has been decided. location of the nth rectangle if it has been decided.
(modified in place) (modified in place)
occupied: the nodes of the graph of extents of rightmost placed occupied: the nodes of the graph of extents of rightmost placed
rectangles - (modified in place) rectangles - (modified in place)
Returns: Returns:
True on success. True on success.
Example: Example:
(We always have placed the first rectangle horizontally and other (We always have placed the first rectangle horizontally and other
rectangles above it.) rectangles above it.)
Let's say the placed boxes 1-4 are layed out like this. Let's say the placed boxes 1-4 are layed out like this.
The coordinates of the points marked X are stored in occupied. The coordinates of the points marked X are stored in occupied.
It is to the right of the X's that we seek to place rect. It is to the right of the X's that we seek to place rect.
+-----------------------X +-----------------------X
|2 | |2 |
| +---X | +---X
| |4 | | |4 |
| | | | | |
| +---+X | +---+X
| |3 | | |3 |
| | | | | |
+-----------------------+----+------X +-----------------------+----+------X
y |1 | y |1 |
^ | --->x | ^ | --->x |
| +-----------------------------------+ | +-----------------------------------+
We want to place this rectangle. We want to place this rectangle.
+-+ +-+
|5| |5|
| | | |
| | = rect | | = rect
| | | |
| | | |
| | | |
+-+ +-+
The call will succeed, returning True, leaving us with The call will succeed, returning True, leaving us with
+-----------------------X +-----------------------X
|2 | +-X |2 | +-X
| +---+|5| | +---+|5|
| |4 || | | |4 || |
| | || | | | || |
| +---++ | | +---++ |
| |3 | | | |3 | |
| | | | | | | |
+-----------------------+----+-+----X +-----------------------+----+-+----X
|1 | |1 |
| | | |
+-----------------------------------+ . +-----------------------------------+ .
""" """
total_width = occupied[0][0] total_width = occupied[0][0]

View File

@ -9,177 +9,177 @@ from . import utils as struct_utils
class Meshes(object): class Meshes(object):
""" """
This class provides functions for working with batches of triangulated This class provides functions for working with batches of triangulated
meshes with varying numbers of faces and vertices, and converting between meshes with varying numbers of faces and vertices, and converting between
representations. representations.
Within Meshes, there are three different representations of the faces and Within Meshes, there are three different representations of the faces and
verts data: verts data:
List List
- only used for input as a starting point to convert to other representations. - only used for input as a starting point to convert to other representations.
Padded Padded
- has specific batch dimension. - has specific batch dimension.
Packed Packed
- no batch dimension. - no batch dimension.
- has auxillary variables used to index into the padded representation. - has auxillary variables used to index into the padded representation.
Example: Example:
Input list of verts V_n = [[V_1], [V_2], ... , [V_N]] Input list of verts V_n = [[V_1], [V_2], ... , [V_N]]
where V_1, ... , V_N are the number of verts in each mesh and N is the where V_1, ... , V_N are the number of verts in each mesh and N is the
numer of meshes. numer of meshes.
Input list of faces F_n = [[F_1], [F_2], ... , [F_N]] Input list of faces F_n = [[F_1], [F_2], ... , [F_N]]
where F_1, ... , F_N are the number of faces in each mesh. where F_1, ... , F_N are the number of faces in each mesh.
# SPHINX IGNORE # SPHINX IGNORE
List | Padded | Packed List | Padded | Packed
---------------------------|-------------------------|------------------------ ---------------------------|-------------------------|------------------------
[[V_1], ... , [V_N]] | size = (N, max(V_n), 3) | size = (sum(V_n), 3) [[V_1], ... , [V_N]] | size = (N, max(V_n), 3) | size = (sum(V_n), 3)
| | | |
Example for verts: | | Example for verts: | |
| | | |
V_1 = 3, V_2 = 4, V_3 = 5 | size = (3, 5, 3) | size = (12, 3) V_1 = 3, V_2 = 4, V_3 = 5 | size = (3, 5, 3) | size = (12, 3)
| | | |
List([ | tensor([ | tensor([ List([ | tensor([ | tensor([
[ | [ | [0.1, 0.3, 0.5], [ | [ | [0.1, 0.3, 0.5],
[0.1, 0.3, 0.5], | [0.1, 0.3, 0.5], | [0.5, 0.2, 0.1], [0.1, 0.3, 0.5], | [0.1, 0.3, 0.5], | [0.5, 0.2, 0.1],
[0.5, 0.2, 0.1], | [0.5, 0.2, 0.1], | [0.6, 0.8, 0.7], [0.5, 0.2, 0.1], | [0.5, 0.2, 0.1], | [0.6, 0.8, 0.7],
[0.6, 0.8, 0.7], | [0.6, 0.8, 0.7], | [0.1, 0.3, 0.3], [0.6, 0.8, 0.7], | [0.6, 0.8, 0.7], | [0.1, 0.3, 0.3],
], | [0, 0, 0], | [0.6, 0.7, 0.8], ], | [0, 0, 0], | [0.6, 0.7, 0.8],
[ | [0, 0, 0], | [0.2, 0.3, 0.4], [ | [0, 0, 0], | [0.2, 0.3, 0.4],
[0.1, 0.3, 0.3], | ], | [0.1, 0.5, 0.3], [0.1, 0.3, 0.3], | ], | [0.1, 0.5, 0.3],
[0.6, 0.7, 0.8], | [ | [0.7, 0.3, 0.6], [0.6, 0.7, 0.8], | [ | [0.7, 0.3, 0.6],
[0.2, 0.3, 0.4], | [0.1, 0.3, 0.3], | [0.2, 0.4, 0.8], [0.2, 0.3, 0.4], | [0.1, 0.3, 0.3], | [0.2, 0.4, 0.8],
[0.1, 0.5, 0.3], | [0.6, 0.7, 0.8], | [0.9, 0.5, 0.2], [0.1, 0.5, 0.3], | [0.6, 0.7, 0.8], | [0.9, 0.5, 0.2],
], | [0.2, 0.3, 0.4], | [0.2, 0.3, 0.4], ], | [0.2, 0.3, 0.4], | [0.2, 0.3, 0.4],
[ | [0.1, 0.5, 0.3], | [0.9, 0.3, 0.8], [ | [0.1, 0.5, 0.3], | [0.9, 0.3, 0.8],
[0.7, 0.3, 0.6], | [0, 0, 0], | ]) [0.7, 0.3, 0.6], | [0, 0, 0], | ])
[0.2, 0.4, 0.8], | ], | [0.2, 0.4, 0.8], | ], |
[0.9, 0.5, 0.2], | [ | [0.9, 0.5, 0.2], | [ |
[0.2, 0.3, 0.4], | [0.7, 0.3, 0.6], | [0.2, 0.3, 0.4], | [0.7, 0.3, 0.6], |
[0.9, 0.3, 0.8], | [0.2, 0.4, 0.8], | [0.9, 0.3, 0.8], | [0.2, 0.4, 0.8], |
] | [0.9, 0.5, 0.2], | ] | [0.9, 0.5, 0.2], |
]) | [0.2, 0.3, 0.4], | ]) | [0.2, 0.3, 0.4], |
| [0.9, 0.3, 0.8], | | [0.9, 0.3, 0.8], |
| ] | | ] |
| ]) | | ]) |
Example for faces: | | Example for faces: | |
| | | |
F_1 = 1, F_2 = 2, F_3 = 7 | size = (3, 7, 3) | size = (10, 3) F_1 = 1, F_2 = 2, F_3 = 7 | size = (3, 7, 3) | size = (10, 3)
| | | |
List([ | tensor([ | tensor([ List([ | tensor([ | tensor([
[ | [ | [ 0, 1, 2], [ | [ | [ 0, 1, 2],
[0, 1, 2], | [0, 1, 2], | [ 3, 4, 5], [0, 1, 2], | [0, 1, 2], | [ 3, 4, 5],
], | [-1, -1, -1], | [ 4, 5, 6], ], | [-1, -1, -1], | [ 4, 5, 6],
[ | [-1, -1, -1] | [ 8, 9, 7], [ | [-1, -1, -1] | [ 8, 9, 7],
[0, 1, 2], | [-1, -1, -1] | [ 7, 8, 10], [0, 1, 2], | [-1, -1, -1] | [ 7, 8, 10],
[1, 2, 3], | [-1, -1, -1] | [ 9, 10, 8], [1, 2, 3], | [-1, -1, -1] | [ 9, 10, 8],
], | [-1, -1, -1], | [11, 10, 9], ], | [-1, -1, -1], | [11, 10, 9],
[ | [-1, -1, -1], | [11, 7, 8], [ | [-1, -1, -1], | [11, 7, 8],
[1, 2, 0], | ], | [11, 10, 8], [1, 2, 0], | ], | [11, 10, 8],
[0, 1, 3], | [ | [11, 9, 8], [0, 1, 3], | [ | [11, 9, 8],
[2, 3, 1], | [0, 1, 2], | ]) [2, 3, 1], | [0, 1, 2], | ])
[4, 3, 2], | [1, 2, 3], | [4, 3, 2], | [1, 2, 3], |
[4, 0, 1], | [-1, -1, -1], | [4, 0, 1], | [-1, -1, -1], |
[4, 3, 1], | [-1, -1, -1], | [4, 3, 1], | [-1, -1, -1], |
[4, 2, 1], | [-1, -1, -1], | [4, 2, 1], | [-1, -1, -1], |
], | [-1, -1, -1], | ], | [-1, -1, -1], |
]) | [-1, -1, -1], | ]) | [-1, -1, -1], |
| ], | | ], |
| [ | | [ |
| [1, 2, 0], | | [1, 2, 0], |
| [0, 1, 3], | | [0, 1, 3], |
| [2, 3, 1], | | [2, 3, 1], |
| [4, 3, 2], | | [4, 3, 2], |
| [4, 0, 1], | | [4, 0, 1], |
| [4, 3, 1], | | [4, 3, 1], |
| [4, 2, 1], | | [4, 2, 1], |
| ] | | ] |
| ]) | | ]) |
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Auxillary variables for packed representation Auxillary variables for packed representation
Name | Size | Example from above Name | Size | Example from above
-------------------------------|---------------------|----------------------- -------------------------------|---------------------|-----------------------
| | | |
verts_packed_to_mesh_idx | size = (sum(V_n)) | tensor([ verts_packed_to_mesh_idx | size = (sum(V_n)) | tensor([
| | 0, 0, 0, 1, 1, 1, | | 0, 0, 0, 1, 1, 1,
| | 1, 2, 2, 2, 2, 2 | | 1, 2, 2, 2, 2, 2
| | )] | | )]
| | size = (12) | | size = (12)
| | | |
mesh_to_verts_packed_first_idx | size = (N) | tensor([0, 3, 7]) mesh_to_verts_packed_first_idx | size = (N) | tensor([0, 3, 7])
| | size = (3) | | size = (3)
| | | |
num_verts_per_mesh | size = (N) | tensor([3, 4, 5]) num_verts_per_mesh | size = (N) | tensor([3, 4, 5])
| | size = (3) | | size = (3)
| | | |
faces_packed_to_mesh_idx | size = (sum(F_n)) | tensor([ faces_packed_to_mesh_idx | size = (sum(F_n)) | tensor([
| | 0, 1, 1, 2, 2, 2, | | 0, 1, 1, 2, 2, 2,
| | 2, 2, 2, 2 | | 2, 2, 2, 2
| | )] | | )]
| | size = (10) | | size = (10)
| | | |
mesh_to_faces_packed_first_idx | size = (N) | tensor([0, 1, 3]) mesh_to_faces_packed_first_idx | size = (N) | tensor([0, 1, 3])
| | size = (3) | | size = (3)
| | | |
num_faces_per_mesh | size = (N) | tensor([1, 2, 7]) num_faces_per_mesh | size = (N) | tensor([1, 2, 7])
| | size = (3) | | size = (3)
| | | |
verts_padded_to_packed_idx | size = (sum(V_n)) | tensor([ verts_padded_to_packed_idx | size = (sum(V_n)) | tensor([
| | 0, 1, 2, 5, 6, 7, | | 0, 1, 2, 5, 6, 7,
| | 8, 10, 11, 12, 13, | | 8, 10, 11, 12, 13,
| | 14 | | 14
| | )] | | )]
| | size = (12) | | size = (12)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
# SPHINX IGNORE # SPHINX IGNORE
From the faces, edges are computed and have packed and padded From the faces, edges are computed and have packed and padded
representations with auxillary variables. representations with auxillary variables.
E_n = [[E_1], ... , [E_N]] E_n = [[E_1], ... , [E_N]]
where E_1, ... , E_N are the number of unique edges in each mesh. where E_1, ... , E_N are the number of unique edges in each mesh.
Total number of unique edges = sum(E_n) Total number of unique edges = sum(E_n)
# SPHINX IGNORE # SPHINX IGNORE
Name | Size | Example from above Name | Size | Example from above
-------------------------------|-------------------------|---------------------- -------------------------------|-------------------------|----------------------
| | | |
edges_packed | size = (sum(E_n), 2) | tensor([ edges_packed | size = (sum(E_n), 2) | tensor([
| | [0, 1], | | [0, 1],
| | [0, 2], | | [0, 2],
| | [1, 2], | | [1, 2],
| | ... | | ...
| | [10, 11], | | [10, 11],
| | )] | | )]
| | size = (18, 2) | | size = (18, 2)
| | | |
num_edges_per_mesh | size = (N) | tensor([3, 5, 10]) num_edges_per_mesh | size = (N) | tensor([3, 5, 10])
| | size = (3) | | size = (3)
| | | |
edges_packed_to_mesh_idx | size = (sum(E_n)) | tensor([ edges_packed_to_mesh_idx | size = (sum(E_n)) | tensor([
| | 0, 0, 0, | | 0, 0, 0,
| | . . . | | . . .
| | 2, 2, 2 | | 2, 2, 2
| | ]) | | ])
| | size = (18) | | size = (18)
| | | |
faces_packed_to_edges_packed | size = (sum(F_n), 3) | tensor([ faces_packed_to_edges_packed | size = (sum(F_n), 3) | tensor([
| | [2, 1, 0], | | [2, 1, 0],
| | [5, 4, 3], | | [5, 4, 3],
| | . . . | | . . .
| | [12, 14, 16], | | [12, 14, 16],
| | ]) | | ])
| | size = (10, 3) | | size = (10, 3)
| | | |
mesh_to_edges_packed_first_idx | size = (N) | tensor([0, 3, 8]) mesh_to_edges_packed_first_idx | size = (N) | tensor([0, 3, 8])
| | size = (3) | | size = (3)
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
# SPHINX IGNORE # SPHINX IGNORE
""" """
_INTERNAL_TENSORS = [ _INTERNAL_TENSORS = [

View File

@ -8,85 +8,85 @@ from . import utils as struct_utils
class Pointclouds(object): class Pointclouds(object):
""" """
This class provides functions for working with batches of 3d point clouds, This class provides functions for working with batches of 3d point clouds,
and converting between representations. and converting between representations.
Within Pointclouds, there are three different representations of the data. Within Pointclouds, there are three different representations of the data.
List List
- only used for input as a starting point to convert to other representations. - only used for input as a starting point to convert to other representations.
Padded Padded
- has specific batch dimension. - has specific batch dimension.
Packed Packed
- no batch dimension. - no batch dimension.
- has auxillary variables used to index into the padded representation. - has auxillary variables used to index into the padded representation.
Example Example
Input list of points = [[P_1], [P_2], ... , [P_N]] Input list of points = [[P_1], [P_2], ... , [P_N]]
where P_1, ... , P_N are the number of points in each cloud and N is the where P_1, ... , P_N are the number of points in each cloud and N is the
number of clouds. number of clouds.
# SPHINX IGNORE # SPHINX IGNORE
List | Padded | Packed List | Padded | Packed
---------------------------|-------------------------|------------------------ ---------------------------|-------------------------|------------------------
[[P_1], ... , [P_N]] | size = (N, max(P_n), 3) | size = (sum(P_n), 3) [[P_1], ... , [P_N]] | size = (N, max(P_n), 3) | size = (sum(P_n), 3)
| | | |
Example for locations | | Example for locations | |
or colors: | | or colors: | |
| | | |
P_1 = 3, P_2 = 4, P_3 = 5 | size = (3, 5, 3) | size = (12, 3) P_1 = 3, P_2 = 4, P_3 = 5 | size = (3, 5, 3) | size = (12, 3)
| | | |
List([ | tensor([ | tensor([ List([ | tensor([ | tensor([
[ | [ | [0.1, 0.3, 0.5], [ | [ | [0.1, 0.3, 0.5],
[0.1, 0.3, 0.5], | [0.1, 0.3, 0.5], | [0.5, 0.2, 0.1], [0.1, 0.3, 0.5], | [0.1, 0.3, 0.5], | [0.5, 0.2, 0.1],
[0.5, 0.2, 0.1], | [0.5, 0.2, 0.1], | [0.6, 0.8, 0.7], [0.5, 0.2, 0.1], | [0.5, 0.2, 0.1], | [0.6, 0.8, 0.7],
[0.6, 0.8, 0.7] | [0.6, 0.8, 0.7], | [0.1, 0.3, 0.3], [0.6, 0.8, 0.7] | [0.6, 0.8, 0.7], | [0.1, 0.3, 0.3],
], | [0, 0, 0], | [0.6, 0.7, 0.8], ], | [0, 0, 0], | [0.6, 0.7, 0.8],
[ | [0, 0, 0] | [0.2, 0.3, 0.4], [ | [0, 0, 0] | [0.2, 0.3, 0.4],
[0.1, 0.3, 0.3], | ], | [0.1, 0.5, 0.3], [0.1, 0.3, 0.3], | ], | [0.1, 0.5, 0.3],
[0.6, 0.7, 0.8], | [ | [0.7, 0.3, 0.6], [0.6, 0.7, 0.8], | [ | [0.7, 0.3, 0.6],
[0.2, 0.3, 0.4], | [0.1, 0.3, 0.3], | [0.2, 0.4, 0.8], [0.2, 0.3, 0.4], | [0.1, 0.3, 0.3], | [0.2, 0.4, 0.8],
[0.1, 0.5, 0.3] | [0.6, 0.7, 0.8], | [0.9, 0.5, 0.2], [0.1, 0.5, 0.3] | [0.6, 0.7, 0.8], | [0.9, 0.5, 0.2],
], | [0.2, 0.3, 0.4], | [0.2, 0.3, 0.4], ], | [0.2, 0.3, 0.4], | [0.2, 0.3, 0.4],
[ | [0.1, 0.5, 0.3], | [0.9, 0.3, 0.8], [ | [0.1, 0.5, 0.3], | [0.9, 0.3, 0.8],
[0.7, 0.3, 0.6], | [0, 0, 0] | ]) [0.7, 0.3, 0.6], | [0, 0, 0] | ])
[0.2, 0.4, 0.8], | ], | [0.2, 0.4, 0.8], | ], |
[0.9, 0.5, 0.2], | [ | [0.9, 0.5, 0.2], | [ |
[0.2, 0.3, 0.4], | [0.7, 0.3, 0.6], | [0.2, 0.3, 0.4], | [0.7, 0.3, 0.6], |
[0.9, 0.3, 0.8], | [0.2, 0.4, 0.8], | [0.9, 0.3, 0.8], | [0.2, 0.4, 0.8], |
] | [0.9, 0.5, 0.2], | ] | [0.9, 0.5, 0.2], |
]) | [0.2, 0.3, 0.4], | ]) | [0.2, 0.3, 0.4], |
| [0.9, 0.3, 0.8] | | [0.9, 0.3, 0.8] |
| ] | | ] |
| ]) | | ]) |
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Auxillary variables for packed representation Auxillary variables for packed representation
Name | Size | Example from above Name | Size | Example from above
-------------------------------|---------------------|----------------------- -------------------------------|---------------------|-----------------------
| | | |
packed_to_cloud_idx | size = (sum(P_n)) | tensor([ packed_to_cloud_idx | size = (sum(P_n)) | tensor([
| | 0, 0, 0, 1, 1, 1, | | 0, 0, 0, 1, 1, 1,
| | 1, 2, 2, 2, 2, 2 | | 1, 2, 2, 2, 2, 2
| | )] | | )]
| | size = (12) | | size = (12)
| | | |
cloud_to_packed_first_idx | size = (N) | tensor([0, 3, 7]) cloud_to_packed_first_idx | size = (N) | tensor([0, 3, 7])
| | size = (3) | | size = (3)
| | | |
num_points_per_cloud | size = (N) | tensor([3, 4, 5]) num_points_per_cloud | size = (N) | tensor([3, 4, 5])
| | size = (3) | | size = (3)
| | | |
padded_to_packed_idx | size = (sum(P_n)) | tensor([ padded_to_packed_idx | size = (sum(P_n)) | tensor([
| | 0, 1, 2, 5, 6, 7, | | 0, 1, 2, 5, 6, 7,
| | 8, 10, 11, 12, 13, | | 8, 10, 11, 12, 13,
| | 14 | | 14
| | )] | | )]
| | size = (12) | | size = (12)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
# SPHINX IGNORE # SPHINX IGNORE
""" """
_INTERNAL_TENSORS = [ _INTERNAL_TENSORS = [