Skip to content

Commit c8e8c90

Browse files
author
anna-charlotte
committed
fix: mypy
Signed-off-by: anna-charlotte <[email protected]>
1 parent 91802d9 commit c8e8c90

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

docarray/documents/point_cloud.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,24 @@ def display(self, display_from: str = 'url', samples: int = 10000) -> None:
127127
if display_from not in ['tensor', 'url']:
128128
raise ValueError(f'Expected one of ["tensor", "url"], got "{display_from}"')
129129

130-
if getattr(self, display_from) is None:
131-
raise ValueError(
132-
f'Can not to display point cloud from {display_from} when the '
133-
f'{display_from} is None.'
134-
)
135-
136130
if display_from == 'url':
131+
if self.url is None:
132+
raise ValueError(
133+
'Can\'t display point cloud from url when url is None.'
134+
)
137135
tensor = self.url.load(samples=samples)
138136
colors = np.tile(
139137
np.array([0, 0, 0]), (tensor.get_comp_backend().shape(tensor)[0], 1)
140138
)
141139
else:
140+
if self.tensor is None:
141+
raise ValueError('Can\'t display mesh from tensor when tensor is None.')
142142
tensor = self.tensor
143143
comp_be = self.tensor.get_comp_backend()
144144
colors = (
145145
self.color_tensor
146146
if self.color_tensor
147-
else np.tile(
148-
np.array([0, 0, 0]),
149-
(comp_be.shape(tensor)[0], 1),
150-
)
147+
else np.tile(np.array([0, 0, 0]), (comp_be.shape(tensor)[0], 1))
151148
)
152149

153150
pc = trimesh.points.PointCloud(vertices=tensor, colors=colors)

docarray/typing/tensor/tensor.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
from docarray.typing.tensor.tensorflow_tensor import TensorFlowTensor # noqa: F401
1414

1515

16+
AnyTensor = Union[NdArray]
1617
if torch_available and tf_available:
17-
AnyTensor = Union[NdArray, TorchTensor, TensorFlowTensor]
18+
AnyTensor = Union[NdArray, TorchTensor, TensorFlowTensor] # type: ignore
1819
elif torch_available:
1920
AnyTensor = Union[NdArray, TorchTensor] # type: ignore
2021
elif tf_available:
2122
AnyTensor = Union[NdArray, TensorFlowTensor] # type: ignore
22-
else:
23-
AnyTensor = Union[NdArray] # type: ignore

0 commit comments

Comments
 (0)