Skip to content

Commit

Permalink
type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Jan 19, 2025
1 parent ce82b3b commit 9539bb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_hsv_rgba(self):
truth = g.np.array([hsv_to_rgb(*v) for v in hsv])

# they should match
assert g.np.allclose(ours[:, :3], truth, atol=0.0001), ours[:,:3] - truth
assert g.np.allclose(ours[:, :3], truth, atol=0.0001), ours[:, :3] - truth

def test_concatenate_empty_mesh(self):
box = g.get_mesh("box.STL")
Expand Down
8 changes: 5 additions & 3 deletions trimesh/visual/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .. import caching, util
from ..constants import tol
from ..grouping import unique_rows
from ..typed import ArrayLike, DTypeLike, Integer, NDArray, Optional
from ..typed import ArrayLike, DTypeLike, Integer, Iterable, NDArray, Optional, Union
from .base import Visuals


Expand Down Expand Up @@ -455,7 +455,9 @@ def to_texture(self):
mat, uv = color_to_uv(vertex_colors=self.vertex_colors)
return TextureVisuals(material=mat, uv=uv)

def concatenate(self, other: "ColorVisuals", *args) -> "ColorVisuals":
def concatenate(
self, other: Union[Iterable[Visuals], Visuals], *args
) -> "ColorVisuals":
"""
Concatenate two or more ColorVisuals objects
into a single object.
Expand Down Expand Up @@ -560,7 +562,7 @@ def __hash__(self):
return self._colors.__hash__()


def to_rgba(colors: ArrayLike, dtype: DTypeLike = np.uint8) -> NDArray:
def to_rgba(colors: Optional[ArrayLike], dtype: DTypeLike = np.uint8) -> NDArray:
"""
Convert a single or multiple RGB colors to RGBA colors.
Expand Down

0 comments on commit 9539bb8

Please sign in to comment.