diff --git a/tidy3d/components/data/data_array.py b/tidy3d/components/data/data_array.py index 203194f80b..2c722b454a 100644 --- a/tidy3d/components/data/data_array.py +++ b/tidy3d/components/data/data_array.py @@ -27,6 +27,7 @@ WATT, ) from ...exceptions import DataError, FileError +from ...log import log from ..autograd import TidyArrayBox, get_static, interpn, is_tidy_box from ..types import Axis, Bound @@ -125,6 +126,12 @@ def _interp_validator(self, field_name: str = None) -> None: This does not check every 'DataArray' by default. Instead, when required, this check can be called from a validator, as is the case with 'CustomMedium' and 'CustomFieldSource'. """ + import importlib.util + + if importlib.util.find_spec("scipy") is None: + log.warning("SciPy not installed, skipping '_interp_validator'...") + return + if field_name is None: field_name = "DataArray" diff --git a/tidy3d/components/geometry/mesh.py b/tidy3d/components/geometry/mesh.py index 0f300e8106..79e844382a 100644 --- a/tidy3d/components/geometry/mesh.py +++ b/tidy3d/components/geometry/mesh.py @@ -63,6 +63,12 @@ def _check_mesh(cls, val: TriangleMeshDataset) -> TriangleMeshDataset: if val is None: return None + import importlib.util + + if importlib.util.find_spec("trimesh") is None: + log.warning("trimesh not installed, skipping '_check_mesh'...") + return val + import trimesh mesh = cls._triangles_to_trimesh(val.surface_mesh)