Skip to content

Commit 81727b9

Browse files
committed
Feedback from review and a new test
Incorporate feedback from review and add a test for when export_folder is not supplied.
1 parent 5c194ad commit 81727b9

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

_unittest/test_36_Q2D_PostProcessing.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,20 @@ def test_02_export_w_elements_from_nominal(self):
4343
assert os.path.isfile(file)
4444
finally:
4545
q2d.close_project(saveproject=False)
46+
47+
def test_03_export_w_elements_to_working_directory(self):
48+
test_project = self.local_scratch.copyfile(
49+
os.path.join(local_path, "example_models", "q2d_solved_nominal.aedtz")
50+
)
51+
with Q2d(test_project, non_graphical=settings.non_graphical, new_desktop_session=new_thread) as q2d:
52+
try:
53+
files = q2d.export_w_elements(False)
54+
assert len(files) == 1
55+
for file in files:
56+
_, ext = os.path.splitext(file)
57+
assert ext == ".sp"
58+
assert os.path.isfile(file)
59+
file_dir = os.path.abspath(os.path.dirname(file))
60+
assert file_dir == os.path.abspath(q2d.working_directory)
61+
finally:
62+
q2d.close_project(saveproject=False)

pyaedt/q3d.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ def export_w_elements(self, analyze=False, export_folder=None):
10231023
10241024
Parameters
10251025
----------
1026-
analyze : bool
1026+
analyze : bool, optional
10271027
Whether to analyze before export. Solutions must be present for the design.
10281028
The default is ``False``.
10291029
export_folder : str, optional
@@ -1046,10 +1046,8 @@ def export_w_elements(self, analyze=False, export_folder=None):
10461046

10471047
for s in setups:
10481048
sweeps = self.oanalysis.GetSweeps(s)
1049-
if len(sweeps) == 0:
1049+
if not sweeps:
10501050
sweeps = ["LastAdaptive"]
1051-
else:
1052-
pass
10531051
for sweep in sweeps:
10541052
variation_array = self.list_of_variations(s, sweep)
10551053
solution_name = "{} : {}".format(s, sweep)
@@ -1092,7 +1090,7 @@ def export_w_elements(self, analyze=False, export_folder=None):
10921090
)
10931091
exported_files.append(export_path)
10941092
self.logger.info("Exported W-element: %s", export_path)
1095-
except:
1093+
except: # pragma: no cover
10961094
self.logger.warning("Export W-element failed")
10971095
else:
10981096
varCount = 0
@@ -1136,7 +1134,7 @@ def export_w_elements(self, analyze=False, export_folder=None):
11361134
)
11371135
exported_files.append(export_path)
11381136
self.logger.info("Exported W-element: %s", export_path)
1139-
except:
1137+
except: # pragma: no cover
11401138
self.logger.warning("Export W-element failed")
11411139
return exported_files
11421140

0 commit comments

Comments
 (0)