Skip to content

Commit

Permalink
FIX: Load numpy lazily (#5673)
Browse files Browse the repository at this point in the history
  • Loading branch information
SMoraisAnsys authored Jan 17, 2025
1 parent de0df32 commit 5414fb3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/ansys/aedt/core/q3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@
from ansys.aedt.core.modules.boundary.q3d_boundary import Matrix
from ansys.aedt.core.modules.setup_templates import SetupKeys

try:
import numpy as np
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to use functionalities provided by the module ansys.edt.core.q3d.\n"
"Install with \n\npip install numpy"
)
np = None


class QExtractor(FieldAnalysis3D, object):
"""Extracts a 2D or 3D field analysis.
Expand Down Expand Up @@ -1944,6 +1935,8 @@ def set_material_thresholds(
``True`` when successful, ``False`` when failed.
"""
try:
import numpy as np

if not insulator_threshold:
insulator_threshold = 10000
if not perfect_conductor_threshold:
Expand All @@ -1962,6 +1955,11 @@ def set_material_thresholds(

self.oboundary.SetMaterialThresholds(insulator_threshold, perfect_conductor_threshold, magnetic_threshold)
return True
except ImportError: # pragma: no cover
warnings.warn(
"The NumPy module is required to use functionalities provided by the module ansys.edt.core.q3d.\n"
"Install with \n\npip install numpy"
)
except Exception:
return False

Expand Down

0 comments on commit 5414fb3

Please sign in to comment.