Skip to content

Commit 12046a2

Browse files
CHORE: Make Independent 01 general tests (#6891)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent f6a5ba3 commit 12046a2

23 files changed

+2728
-2196
lines changed

.github/workflows/manual_draft.yml

Lines changed: 409 additions & 26 deletions
Large diffs are not rendered by default.

doc/changelog.d/6712.documentation.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make Independent 01 general tests

doc/changelog.d/6900.test.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/ansys/aedt/core/application/analysis_3d.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -518,29 +518,33 @@ def copy_solid_bodies_from(self, design, assignment=None, no_vacuum=True, no_pec
518518
self.modeler.refresh_all_ids()
519519
return True
520520

521-
@pyaedt_function_handler(filename="input_file")
521+
@pyaedt_function_handler(
522+
filename="input_file",
523+
create_lightweigth_part="create_lightweight_part",
524+
point_coicidence_tolerance="point_coincidence_tolerance",
525+
)
522526
def import_3d_cad(
523527
self,
524-
input_file,
525-
healing=False,
526-
refresh_all_ids=True,
527-
import_materials=False,
528-
create_lightweigth_part=False,
529-
group_by_assembly=False,
530-
create_group=True,
531-
separate_disjoints_lumped_object=False,
532-
import_free_surfaces=False,
533-
point_coicidence_tolerance=1e-6,
534-
reduce_stl=False,
535-
reduce_percentage=0,
536-
reduce_error=0,
537-
merge_planar_faces=True,
538-
):
528+
input_file: Union[str, Path],
529+
healing: bool = False,
530+
refresh_all_ids: bool = True,
531+
import_materials: bool = False,
532+
create_lightweight_part: bool = False,
533+
group_by_assembly: bool = False,
534+
create_group: bool = True,
535+
separate_disjoints_lumped_object: bool = False,
536+
import_free_surfaces: bool = False,
537+
point_coincidence_tolerance: float = 1e-6,
538+
reduce_stl: bool = False,
539+
reduce_percentage: int = 0,
540+
reduce_error: int = 0,
541+
merge_planar_faces: bool = True,
542+
) -> bool:
539543
"""Import a CAD model.
540544
541545
Parameters
542546
----------
543-
input_file : str
547+
input_file : str or :class:`pathlib.Path`
544548
Full path and name of the CAD file.
545549
healing : bool, optional
546550
Whether to perform healing. The default is ``False``.
@@ -551,7 +555,7 @@ def import_3d_cad(
551555
import_materials : bool optional
552556
Whether to import material names from the file if present. The
553557
default is ``False``.
554-
create_lightweigth_part : bool ,optional
558+
create_lightweight_part : bool ,optional
555559
Whether to import a lightweight part. The default is ``True``.
556560
group_by_assembly : bool, optional
557561
Whether to import by subassembly. The default is ``False``, in which
@@ -562,7 +566,7 @@ def import_3d_cad(
562566
Whether to automatically separate disjoint parts. The default is ``False``.
563567
import_free_surfaces : bool, optional
564568
Whether to import free surfaces parts. The default is ``False``.
565-
point_coicidence_tolerance : float, optional
569+
point_coincidence_tolerance : float, optional
566570
Tolerance on the point. The default is ``1e-6``.
567571
reduce_stl : bool, optional
568572
Whether to reduce the STL file on import. The default is ``True``.
@@ -582,17 +586,19 @@ def import_3d_cad(
582586
----------
583587
>>> oEditor.Import
584588
"""
589+
input_file = Path(input_file)
590+
585591
return self.modeler.import_3d_cad(
586592
input_file=input_file,
587593
healing=healing,
588594
refresh_all_ids=refresh_all_ids,
589595
import_materials=import_materials,
590-
create_lightweigth_part=create_lightweigth_part,
596+
create_lightweight_part=create_lightweight_part,
591597
group_by_assembly=group_by_assembly,
592598
create_group=create_group,
593599
separate_disjoints_lumped_object=separate_disjoints_lumped_object,
594600
import_free_surfaces=import_free_surfaces,
595-
point_coicidence_tolerance=point_coicidence_tolerance,
601+
point_coincidence_tolerance=point_coincidence_tolerance,
596602
reduce_stl=reduce_stl,
597603
reduce_percentage=reduce_percentage,
598604
reduce_error=reduce_error,

src/ansys/aedt/core/application/design.py

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,9 @@ def project_name(self) -> Optional[str]:
810810
----------
811811
>>> oProject.GetName
812812
"""
813-
if self._project_name:
813+
if self._project_name and self._project_name in self.desktop_class.project_list:
814814
return self._project_name
815-
if self.oproject:
815+
elif self.oproject:
816816
try:
817817
self._project_name = self.oproject.GetName()
818818
self._project_path = None
@@ -2007,14 +2007,14 @@ def set_active_dso_config_name(self, product_name="HFSS", config_name="Local"):
20072007
return False
20082008

20092009
@pyaedt_function_handler()
2010-
def set_registry_from_file(self, registry_file, make_active=True):
2010+
def set_registry_from_file(self, registry_file: Union[str, Path], make_active: bool = True) -> bool:
20112011
"""Apply desktop registry settings from an ACT file.
20122012
20132013
One way to get an ACF file is to export a configuration from the AEDT UI and then edit and reuse it.
20142014
20152015
Parameters
20162016
----------
2017-
registry_file : str
2017+
registry_file : str or :class:`pathlib.Path`
20182018
Full path to the ACF file.
20192019
make_active : bool, optional
20202020
Whether to set the imported configuration as active. The default is ``True``.
@@ -2028,8 +2028,9 @@ def set_registry_from_file(self, registry_file, make_active=True):
20282028
----------
20292029
>>> oDesktop.SetRegistryFromFile
20302030
"""
2031+
registry_file = Path(registry_file)
20312032
try:
2032-
self.odesktop.SetRegistryFromFile(registry_file)
2033+
self.odesktop.SetRegistryFromFile(str(registry_file))
20332034
if make_active:
20342035
with open_file(registry_file, "r") as f:
20352036
for line in f:
@@ -2940,12 +2941,18 @@ def create_dataset3d(
29402941
)
29412942

29422943
@pyaedt_function_handler(filename="input_file", dsname="name")
2943-
def import_dataset1d(self, input_file, name=None, is_project_dataset=True, sort=True):
2944+
def import_dataset1d(
2945+
self,
2946+
input_file: Union[str, Path],
2947+
name: Optional[str] = None,
2948+
is_project_dataset: bool = True,
2949+
sort: bool = True,
2950+
):
29442951
"""Import a 1D dataset.
29452952
29462953
Parameters
29472954
----------
2948-
input_file : str
2955+
input_file : str or :class:`pathlib.Path`
29492956
Full path and name for the TAB file.
29502957
name : str, optional
29512958
Name of the dataset. The default is the file name.
@@ -2963,6 +2970,7 @@ def import_dataset1d(self, input_file, name=None, is_project_dataset=True, sort=
29632970
>>> oProject.AddDataset
29642971
>>> oDesign.AddDataset
29652972
"""
2973+
input_file = Path(input_file)
29662974
with open_file(input_file, "r") as f:
29672975
lines = f.read().splitlines()
29682976
header = lines[0]
@@ -2984,7 +2992,7 @@ def import_dataset1d(self, input_file, name=None, is_project_dataset=True, sort=
29842992
ylist.append(float(item.split()[1]))
29852993

29862994
if not name:
2987-
name = Path(input_file).stem
2995+
name = input_file.stem
29882996

29892997
if name[0] == "$":
29902998
name = name[1:]
@@ -2995,12 +3003,19 @@ def import_dataset1d(self, input_file, name=None, is_project_dataset=True, sort=
29953003
)
29963004

29973005
@pyaedt_function_handler(filename="input_file", dsname="name")
2998-
def import_dataset3d(self, input_file, name=None, encoding="utf-8-sig", is_project_dataset=True, sort=True):
3006+
def import_dataset3d(
3007+
self,
3008+
input_file: Union[str, Path],
3009+
name: Optional[str] = None,
3010+
encoding: str = "utf-8-sig",
3011+
is_project_dataset: bool = True,
3012+
sort: bool = True,
3013+
):
29993014
"""Import a 3D dataset.
30003015
30013016
Parameters
30023017
----------
3003-
input_file : str
3018+
input_file : str or :class:`pathlib.Path`
30043019
Full path and name for the tab/csv/xlsx file.
30053020
name : str, optional
30063021
Name of the dataset. The default is the file name.
@@ -3019,16 +3034,17 @@ def import_dataset3d(self, input_file, name=None, encoding="utf-8-sig", is_proje
30193034
----------
30203035
>>> oProject.AddDataset
30213036
"""
3022-
index_of_dot = input_file.rfind(".")
3023-
file_extension = input_file[index_of_dot + 1 :]
3037+
path = Path(input_file)
3038+
file_extension = path.suffix.lstrip(".").lower()
3039+
30243040
xlist = []
30253041
ylist = []
30263042
zlist = []
30273043
vlist = []
30283044

30293045
if file_extension == "xlsx":
30303046
self.logger.warning("You need pandas and openpyxl library installed for reading excel files")
3031-
lines = read_xlsx(input_file)
3047+
lines = read_xlsx(path)
30323048
if list(lines):
30333049
header = str([lines.columns[i] for i in range(len(lines.columns))])
30343050
xlist = list((lines.iloc[:, 0]).array)
@@ -3040,7 +3056,7 @@ def import_dataset3d(self, input_file, name=None, encoding="utf-8-sig", is_proje
30403056
return False
30413057

30423058
elif file_extension == "csv":
3043-
lines = read_csv(input_file, encoding)
3059+
lines = read_csv(path, encoding)
30443060
header = " ".join(lines[0])
30453061
for row in lines[1:]:
30463062
xlist.append(float(row[0]))
@@ -3049,13 +3065,14 @@ def import_dataset3d(self, input_file, name=None, encoding="utf-8-sig", is_proje
30493065
vlist.append(float(row[3]))
30503066

30513067
elif file_extension == "tab":
3052-
lines = read_tab(input_file)
3068+
lines = read_tab(path)
30533069
header = lines[0]
30543070
for item in lines[1:]:
3055-
xlist.append(float(item.split()[0]))
3056-
ylist.append(float(item.split()[1]))
3057-
zlist.append(float(item.split()[2]))
3058-
vlist.append(float(item.split()[3]))
3071+
cols = item.split()
3072+
xlist.append(float(cols[0]))
3073+
ylist.append(float(cols[1]))
3074+
zlist.append(float(cols[2]))
3075+
vlist.append(float(cols[3]))
30593076

30603077
header_list = header.split()
30613078
units = ["", "", "", ""]
@@ -3067,12 +3084,14 @@ def import_dataset3d(self, input_file, name=None, encoding="utf-8-sig", is_proje
30673084
cont += 1
30683085

30693086
if not name:
3070-
name = Path(input_file).stem
3087+
name = path.stem
30713088

3072-
if name[0] == "$":
3089+
is_project_dataset = False
3090+
if name.startswith("$"):
30733091
name = name[1:]
30743092
is_project_dataset = True
3075-
if self.design_type != "Maxwell 3D" and self.design_type != "Icepak":
3093+
3094+
if self.design_type not in ["Maxwell 3D", "Icepak"]:
30763095
is_project_dataset = True
30773096

30783097
return self.create_dataset(
@@ -3833,12 +3852,17 @@ def export_design_preview_to_jpg(self, output_file):
38333852
@pyaedt_function_handler(
38343853
filename="output_file", export_project="export_project_variables", export_design="export_design_properties"
38353854
)
3836-
def export_variables_to_csv(self, output_file, export_project_variables=True, export_design_properties=True):
3855+
def export_variables_to_csv(
3856+
self,
3857+
output_file: Union[str, Path],
3858+
export_project_variables: bool = True,
3859+
export_design_properties: bool = True,
3860+
) -> bool:
38373861
"""Export design properties, project variables, or both to a CSV file.
38383862
38393863
Parameters
38403864
----------
3841-
output_file : str
3865+
output_file : str or :class:`pathlib.Path`
38423866
Full path and name for the CSV file.
38433867
export_project_variables : bool, optional
38443868
Whether to export project variables. The default is ``True``.
@@ -3858,6 +3882,7 @@ def export_variables_to_csv(self, output_file, export_project_variables=True, ex
38583882
>>> oProject.GetVariableValue
38593883
>>> oDesign.GetVariableValue
38603884
"""
3885+
output_file = Path(output_file)
38613886
varnames = []
38623887
desnames = []
38633888
if export_project_variables:
@@ -3873,7 +3898,7 @@ def export_variables_to_csv(self, output_file, export_project_variables=True, ex
38733898
for el in desnames:
38743899
value = self.odesign.GetVariableValue(el)
38753900
list_full.append([el, value])
3876-
return write_csv(output_file, list_full)
3901+
return write_csv(str(output_file), list_full)
38773902

38783903
@pyaedt_function_handler()
38793904
def read_design_data(self):
@@ -4305,12 +4330,12 @@ def check_if_project_is_loaded(self, input_file):
43054330
return False
43064331

43074332
@pyaedt_function_handler(temp_dir_path="path")
4308-
def set_temporary_directory(self, path):
4333+
def set_temporary_directory(self, path: Union[str, Path]) -> bool:
43094334
"""Set temporary directory path.
43104335
43114336
Parameters
43124337
----------
4313-
path : str
4338+
path : str or :class:`pathlib.Path`
43144339
Temporary directory path.
43154340
43164341
Returns
@@ -4322,7 +4347,8 @@ def set_temporary_directory(self, path):
43224347
----------
43234348
>>> oDesktop.SetTempDirectory()
43244349
"""
4325-
self.odesktop.SetTempDirectory(path)
4350+
path = Path(path)
4351+
self.odesktop.SetTempDirectory(str(path))
43264352
return True
43274353

43284354
@pyaedt_function_handler()

src/ansys/aedt/core/extensions/common/import_nastran.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,7 @@ def main(data: ImportNastranExtensionData):
305305

306306
outfile = simplify_and_preview_stl(str(file_path), decimation=data.decimate)
307307
aedtapp.modeler.import_3d_cad(
308-
outfile,
309-
healing=False,
310-
create_lightweigth_part=data.lightweight,
311-
merge_planar_faces=data.planar,
308+
outfile, healing=False, create_lightweight_part=data.lightweight, merge_planar_faces=data.planar
312309
)
313310

314311
app.logger.info("Geometry imported correctly.")

src/ansys/aedt/core/hfss.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import math
2828
from pathlib import Path
2929
import tempfile
30+
from typing import List
3031
from typing import Optional
3132
from typing import Union
3233
import warnings
@@ -7740,24 +7741,24 @@ def set_export_touchstone(
77407741
@pyaedt_function_handler()
77417742
def import_table(
77427743
self,
7743-
input_file,
7744-
name,
7745-
is_real_imag=True,
7746-
is_field=False,
7747-
column_names=None,
7748-
independent_columns=None,
7749-
):
7744+
input_file: Union[str, Path],
7745+
name: str,
7746+
is_real_imag: bool = True,
7747+
is_field: bool = False,
7748+
column_names: Optional[List[str]] = None,
7749+
independent_columns: Optional[List[bool]] = None,
7750+
) -> bool:
77507751
"""Import a data table.
77517752
77527753
The table can have multiple independent real-valued columns of data,
77537754
and multiple dependent real- or complex-valued columns of data.
7754-
The data supported is comma delimited format (.csv).
7755+
The data supported is comma-delimited format (.csv).
77557756
The first row may contain column names. Complex data columns are inferred from the column data format.
7756-
In comma delimited format, "(double, double)" denotes a complex number.
7757+
In comma-delimited format, "(double, double)" denotes a complex number.
77577758
77587759
Parameters
77597760
----------
7760-
input_file : str
7761+
input_file : str or :class:`pathlib.Path`
77617762
Full path to the file. Supported formats is ``".csv"``.
77627763
name : str
77637764
Table name.

0 commit comments

Comments
 (0)