Skip to content

Commit f624fcc

Browse files
move global import pysdf into function
1 parent 5f7ec8c commit f624fcc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ppsci/geometry/mesh.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import numpy as np
2020
import paddle
21-
import pysdf
2221

2322
from ppsci.geometry import geometry
2423
from ppsci.geometry import geometry_3d
@@ -38,7 +37,7 @@ class Mesh(geometry.Geometry):
3837
>>> geom = ppsci.geometry.Mesh("/path/to/mesh.stl") # doctest: +SKIP
3938
"""
4039

41-
def __init__(self, mesh: Union["Mesh", str]):
40+
def __init__(self, mesh: Union["pymesh.Mesh", str]):
4241
# check if pymesh is installed when using Mesh Class
4342
if not checker.dynamic_import_to_globals(["pymesh"]):
4443
raise ModuleNotFoundError
@@ -86,6 +85,11 @@ def init_mesh(self):
8685
self.v2 = self.vectors[:, 2]
8786
self.num_vertices = self.py_mesh.num_vertices
8887
self.num_faces = self.py_mesh.num_faces
88+
89+
if not checker.dynamic_import_to_globals(["pysdf"]):
90+
raise ModuleNotFoundError
91+
import pysdf
92+
8993
self.pysdf = pysdf.SDF(self.vertices, self.faces)
9094
self.bounds = (
9195
((np.min(self.vectors[:, :, 0])), np.max(self.vectors[:, :, 0])),

0 commit comments

Comments
 (0)