Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Morais <[email protected]>
  • Loading branch information
gmalinve and SMoraisAnsys authored Oct 24, 2024
1 parent 73d828a commit 20ae280
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/ansys/aedt/core/generic/general_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,9 @@ def generate_unique_name(root_name, suffix="", n=6):

import secrets

uName = "".join(secrets.choice(alphabet) for _ in range(n))
name = "".join(secrets.choice(alphabet) for _ in range(n))

unique_name = root_name + "_" + uName
unique_name = root_name + "_" + name
if suffix:
unique_name += "_" + suffix
return unique_name
Expand Down
16 changes: 12 additions & 4 deletions src/ansys/aedt/core/modeler/advanced_cad/oms.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,31 @@

try:
import numpy as np

except ImportError:
warnings.warn("numpy package is needed")
warnings.warn("
"The NumPy module is required to use the OpenStreetMap Reader.\n"
"Install with \n\npip install numpy"
)

try:
import pyvista as pv
import vtk
except ImportError:
warnings.warn("pyvista package is needed")
warnings.warn(
"The PyVista module is required to use the OpenStreetMap Reader.\n"
"Install with \n\npip install pyvista"
)

try:
import osmnx as ox
import srtm
import utm

except ImportError:
warnings.warn("OpenStreetMap Reader requires utm, osmnx and srtm extra packages")
warnings.warn(
"OpenStreetMap Reader requires utm, osmnx and srtm extra packages.\n"
"Install with \n\npip install utm osmnx srtm"
)


class BuildingsPrep(object):
Expand Down
18 changes: 12 additions & 6 deletions src/ansys/aedt/core/modeler/advanced_cad/stackup_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@
try:
import joblib
except ImportError:
pass
joblib = None
warnings.warn(
"The Joblib module is required to use functionalities provided by the module ansys.edt.core.modeler.advanced_cad.stacku_3d.\n"
"Install with \n\npip install joblib"
)
try:
import numpy as np
except ImportError:
pass
np = None
warnings.warn(
"The Numpy module is required to use functionalities provided by the module ansys.edt.core.modeler.advanced_cad.stacku_3d.\n"
"Install with \n\npip install numpy"
)

from ansys.aedt.core import constants
from ansys.aedt.core import pyaedt_path
Expand Down Expand Up @@ -3475,10 +3483,8 @@ def __init__(
self.predict_length()

def predict_length(self):
try:
joblib
except NameError: # pragma: no cover
raise ImportError("joblib package is needed to run ML.")
if joblib is None:
raise ImportError("Package Joblib is required to run ML.")
training_file = None
if 1e9 >= self.frequency.numeric_value >= 1e8:
training_file = os.path.join(pyaedt_path, "misc", "patch_svr_model_100MHz_1GHz.joblib")
Expand Down
6 changes: 5 additions & 1 deletion src/ansys/aedt/core/q3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
try:
import numpy as np
except ImportError: # pragma: no cover
pass
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):
Expand Down

0 comments on commit 20ae280

Please sign in to comment.