Annotate dunder functions

Summary: Annotate the (return type of the) following dunder functions across the codebase: `__init__()`, `__len__()`, `__getitem__()`

Reviewed By: nikhilaravi

Differential Revision: D29001801

fbshipit-source-id: 928d9e1c417ffe01ab8c0445311287786e997c7c
This commit is contained in:
Patrick Labatut
2021-06-24 15:18:19 -07:00
committed by Facebook GitHub Bot
parent 35855bf860
commit 64289a491d
35 changed files with 79 additions and 79 deletions

View File

@@ -219,7 +219,7 @@ class Meshes:
textures=None,
*,
verts_normals=None,
):
) -> None:
"""
Args:
verts:
@@ -469,10 +469,10 @@ class Meshes:
else:
raise ValueError("verts_normals must be a list or tensor")
def __len__(self):
def __len__(self) -> int:
return self._N
def __getitem__(self, index):
def __getitem__(self, index) -> "Meshes":
"""
Args:
index: Specifying the index of the mesh to retrieve.
@@ -493,7 +493,7 @@ class Meshes:
# NOTE consider converting index to cpu for efficiency
if index.dtype == torch.bool:
# advanced indexing on a single dimension
index = index.nonzero()
index = index.nonzero() # pyre-ignore
index = index.squeeze(1) if index.numel() > 0 else index
index = index.tolist()
verts = [self.verts_list()[i] for i in index]

View File

@@ -108,7 +108,7 @@ class Pointclouds:
"equisized",
]
def __init__(self, points, normals=None, features=None):
def __init__(self, points, normals=None, features=None) -> None:
"""
Args:
points:
@@ -306,10 +306,10 @@ class Pointclouds:
points in a cloud."
)
def __len__(self):
def __len__(self) -> int:
return self._N
def __getitem__(self, index):
def __getitem__(self, index) -> "Pointclouds":
"""
Args:
index: Specifying the index of the cloud to retrieve.
@@ -343,7 +343,7 @@ class Pointclouds:
# NOTE consider converting index to cpu for efficiency
if index.dtype == torch.bool:
# advanced indexing on a single dimension
index = index.nonzero()
index = index.nonzero() # pyre-ignore
index = index.squeeze(1) if index.numel() > 0 else index
index = index.tolist()
points = [self.points_list()[i] for i in index]

View File

@@ -155,7 +155,7 @@ class Volumes:
features: Optional[_TensorBatch] = None,
voxel_size: _VoxelSize = 1.0,
volume_translation: _Translation = (0.0, 0.0, 0.0),
):
) -> None:
"""
Args:
**densities**: Batch of input feature volume occupancies of shape