Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ python_files = "*.py"
python_version = "3.10"
files = [
"tidy3d/web",
"tidy3d/config",
"tidy3d/material_library",
"tidy3d/components/geometry"
]
ignore_missing_imports = true
follow_imports = "skip"
Expand Down
146 changes: 77 additions & 69 deletions tidy3d/components/geometry/base.py

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions tidy3d/components/geometry/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from abc import ABC
from typing import Any, Callable, Literal, Optional, Union
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union

import numpy as np
import pydantic.v1 as pydantic
Expand All @@ -21,6 +21,9 @@

from . import base

if TYPE_CHECKING:
from trimesh import Trimesh

AREA_SIZE_THRESHOLD = 1e-36


Expand All @@ -44,7 +47,7 @@ class TriangleMesh(base.Geometry, ABC):

@pydantic.root_validator(pre=True)
@verify_packages_import(["trimesh"])
def _validate_trimesh_library(cls, values):
def _validate_trimesh_library(cls, values: dict[str, Any]) -> dict[str, Any]:
"""Check if the trimesh package is imported as a validator."""
return values

Expand Down Expand Up @@ -303,7 +306,7 @@ def from_vertices_faces(cls, vertices: np.ndarray, faces: np.ndarray) -> Triangl
@verify_packages_import(["trimesh"])
def _triangles_to_trimesh(
cls, triangles: np.ndarray
): # -> TrimeshType: We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
) -> Trimesh: # -> We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
"""Convert an (N, 3, 3) numpy array of triangles to a ``trimesh.Trimesh``."""
import trimesh

Expand Down Expand Up @@ -492,7 +495,7 @@ def from_height_function(
@verify_packages_import(["trimesh"])
def trimesh(
self,
): # -> TrimeshType: We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
) -> Trimesh: # -> We need to get this out of the classes and into functional methods operating on a class (maybe still referenced to the class)
"""A ``trimesh.Trimesh`` object representing the custom surface mesh geometry."""
return self._triangles_to_trimesh(self.triangles)

Expand Down
Loading