Skip to content

Commit

Permalink
REFACTOR: Last bandit refact on pyaedt.modules (#4982)
Browse files Browse the repository at this point in the history
  • Loading branch information
SMoraisAnsys authored Aug 1, 2024
1 parent 797600b commit b9429d0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pyaedt/modules/AdvancedPostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def get_model_plotter_geometries(
Model Object.
"""

assert self._app._aedt_version >= "2021.2", self.logger.error("Object is supported from AEDT 2021 R2.")
if self._app._aedt_version < "2021.2":
raise RuntimeError("Object is supported from AEDT 2021 R2.") # pragma: no cover

files = []
if get_objects_from_aedt and self._app.solution_type not in ["HFSS3DLayout", "HFSS 3D Layout Design"]:
Expand Down
9 changes: 7 additions & 2 deletions pyaedt/modules/Boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ def _get_boundary_data(self, ds):
],
]
except Exception:
pass
self._app.logger.debug(
"An error occurred while getting boundary data for MaxwellParameterSetup."
) # pragma: no cover
try:
if (
"ModelSetup" in self._app.design_properties
Expand All @@ -150,7 +152,7 @@ def _get_boundary_data(self, ds):
self._app.design_properties["ModelSetup"]["MotionSetupList"][ds]["MotionType"],
]
except Exception:
pass
self._app.logger.debug("An error occurred while getting boundary data for ModelSetup.") # pragma: no cover
try:
if ds in self._app.design_properties["BoundarySetup"]["Boundaries"]:
if (
Expand All @@ -164,6 +166,9 @@ def _get_boundary_data(self, ds):
self._app.design_properties["BoundarySetup"]["Boundaries"][ds]["BoundType"],
]
except Exception:
self._app.logger.debug(
"An error occurred while getting boundary data for BoundarySetup."
) # pragma: no cover
return []


Expand Down
22 changes: 16 additions & 6 deletions pyaedt/modules/DesignXPloration.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ def _add_calculation(
if context == f.name:
report_type = "Far Fields"
except Exception:
pass
self._app.logger.debug(
"An error occurred when handling `report_type` while adding calculation."
) # pragma: no cover
sweepdefinition = self._get_context(
calculation,
condition,
Expand All @@ -381,7 +383,7 @@ def _add_calculation(
try:
dx_variables[el] = self._app[el]
except Exception:
pass
self._app.logger.debug("An error occurred while adding calculation.") # pragma: no cover
for v in list(dx_variables.keys()):
self._activate_variable(v)
if self.soltype in ["OptiDesignExplorer", "OptiDXDOE"] and is_goal:
Expand Down Expand Up @@ -1115,7 +1117,9 @@ def __init__(self, p_app):
):
self.setups.append(SetupParam(p_app, data, setups_data[data], setups_data[data]["SetupType"]))
except Exception:
pass
self._app.logger.debug(
"An error occurred while creating an instance of ParametricSetups."
) # pragma: no cover

@property
def p_app(self):
Expand Down Expand Up @@ -1323,7 +1327,9 @@ def __init__(self, p_app):
]:
self.setups.append(SetupOpti(p_app, data, setups_data[data], setups_data[data]["SetupType"]))
except Exception:
pass
self._app.logger.debug(
"An error occurred while creating an instance of OptimizationSetups."
) # pragma: no cover

@property
def p_app(self):
Expand Down Expand Up @@ -1457,7 +1463,9 @@ def add(
if context == f.name:
report_type = "Far Fields"
except Exception:
pass
self._app.logger.debug(
"An error occurred when handling `report_type` while adding a basic optimization analysis."
) # pragma: no cover
sweepdefinition = setup._get_context(
calculation,
condition,
Expand All @@ -1480,7 +1488,9 @@ def add(
try:
dx_variables[el] = self._app[el]
except Exception:
pass
self._app.logger.debug(
"An error occurred while adding a basic optimization analysis."
) # pragma: no cover
for v in list(dx_variables.keys()):
if optimization_type in ["OptiOptimization", "OptiDXDOE", "OptiDesignExplorer", "optiSLang"]:
self._app.activate_variable_optimization(v)
Expand Down

0 comments on commit b9429d0

Please sign in to comment.