mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 06:49:13 +08:00
feat: improve type hints (#1515)
* feat(plugins/registry): Improve Type Hints * feat(exporter/texture_utils): Improve Type Hints * feat(exporter/tsdf_utils): Improve Type Hints * feat(cameras/camera_utils): Improve Type Hints * feat(cameras/cameras): Improve Type Hints * feat(cameras/rays): Improve Type Hints * fix: add default value for device * fix: ArrayLike type hint
This commit is contained in:
1 parent
7309273d92
commit
4545dcb6b3
6 files changed
+44
-27
No files matched your search
@@ -17,7 +17,7 @@ Some ray datastructures.
|
||||
"""
|
||||
import random
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable, Dict, Optional
|
||||
from typing import Callable, Dict, Optional, Union
|
||||
|
||||
import torch
|
||||
from torchtyping import TensorType
|
||||
@@ -25,6 +25,8 @@ from torchtyping import TensorType
|
||||
from nerfstudio.utils.math import Gaussians, conical_frustum_to_gaussian
|
||||
from nerfstudio.utils.tensor_dataclass import TensorDataclass
|
||||
|
||||
TORCH_DEVICE = Union[str, torch.device] # pylint: disable=invalid-name
|
||||
|
||||
|
||||
@dataclass
|
||||
class Frustums(TensorDataclass):
|
||||
@@ -77,7 +79,7 @@ class Frustums(TensorDataclass):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_mock_frustum(cls, device="cpu") -> "Frustums":
|
||||
def get_mock_frustum(cls, device: Optional[TORCH_DEVICE] = "cpu") -> "Frustums":
|
||||
"""Helper function to generate a placeholder frustum.
|
||||
|
||||
Returns:
|
||||
@@ -169,7 +171,7 @@ class RayBundle(TensorDataclass):
|
||||
"""
|
||||
self.camera_indices = torch.ones_like(self.origins[..., 0:1]).long() * camera_index
|
||||
|
||||
def __len__(self):
|
||||
def __len__(self) -> int:
|
||||
num_rays = torch.numel(self.origins) // self.origins.shape[-1]
|
||||
return num_rays
|
||||
|
||||
|
||||
Reference in new issue
Block a user