From b58a1ce61a81cd7343cc9ea05cad0fd30f97a78f Mon Sep 17 00:00:00 2001 From: mcapodif Date: Thu, 16 Jan 2025 21:27:47 +0100 Subject: [PATCH 1/3] Improved tests --- tests/system/general/test_01_3dlayout_edb.py | 380 +++++++------- .../general/test_12_1_PostProcessing.py | 463 +++++++++--------- 2 files changed, 404 insertions(+), 439 deletions(-) diff --git a/tests/system/general/test_01_3dlayout_edb.py b/tests/system/general/test_01_3dlayout_edb.py index 1afbe1e7eda..7c8f2cb03c1 100644 --- a/tests/system/general/test_01_3dlayout_edb.py +++ b/tests/system/general/test_01_3dlayout_edb.py @@ -36,50 +36,39 @@ original_project_name = "ANSYS-HSD_V1" -@pytest.fixture(scope="class") +@pytest.fixture() def aedtapp(add_app): app = add_app(project_name=original_project_name, application=Hfss3dLayout, subfolder=test_subfolder) - return app + yield app + app.close_project(app.project_name) -@pytest.fixture(scope="class") +@pytest.fixture() def flipchip(add_app): app = add_app( project_name="Package", design_name="FlipChip_TopBot", application=Hfss3dLayout, subfolder=test_subfolder ) - return app + yield app + app.close_project(app.project_name) -@pytest.fixture(scope="class") +@pytest.fixture() def dcir_example_project(add_app): app = add_app(project_name="ANSYS-HSD_V1_dcir", application=Hfss3dLayout, subfolder=test_subfolder) - return app + yield app + app.close_project(app.project_name) -@pytest.fixture(scope="class") +@pytest.fixture() def ic_mode_design(add_app): app = add_app(project_name="ic_mode_design", application=Hfss3dLayout, subfolder=test_subfolder) - return app - - -@pytest.fixture(scope="class", autouse=True) -def examples(local_scratch, aedtapp): - design_name = aedtapp.design_name - return design_name, None + yield app + app.close_project(app.project_name) class TestClass: - @pytest.fixture(autouse=True) - def init(self, aedtapp, flipchip, dcir_example_project, ic_mode_design, local_scratch, examples): - self.aedtapp = aedtapp - self.flipchip = flipchip - self.dcir_example_project = dcir_example_project - self.ic_mode_design = ic_mode_design - self.local_scratch = local_scratch - self.design_name = examples[0] - - def test_01_get_components(self): - comp = self.aedtapp.modeler.components + def test_01_get_components(self, aedtapp): + comp = aedtapp.modeler.components assert len(comp) > 0 assert comp["L10"].object_units == "mm" assert comp["L10"].angle == "4.71238898038469" @@ -119,14 +108,14 @@ def test_01_get_components(self): assert r5.model.ind == "0" assert r5.model.is_parallel == False - def test_02a_get_geometries(self): - line = self.aedtapp.modeler.geometries["line_209"] + def test_02a_get_geometries(self, aedtapp): + line = aedtapp.modeler.geometries["line_209"] assert line.edges assert isinstance(line.edge_by_point([0, 0]), int) assert line.points assert line.points assert line.is_closed - poly = self.aedtapp.modeler.geometries["poly_1872"] + poly = aedtapp.modeler.geometries["poly_1872"] assert poly.edges assert poly.points assert poly.bottom_edge_x == 0 @@ -143,8 +132,8 @@ def test_02a_get_geometries(self): assert not poly.is_void assert not poly.lock_position assert poly.is_closed - assert len(self.aedtapp.modeler.geometries) > 0 - rect = self.aedtapp.modeler.rectangles["rect_5951"] + assert len(aedtapp.modeler.geometries) > 0 + rect = aedtapp.modeler.rectangles["rect_5951"] assert rect.point_a assert rect.point_b assert rect.two_point_description @@ -154,43 +143,43 @@ def test_02a_get_geometries(self): assert rect.height rect.two_point_description = True assert rect.point_a - circle = self.aedtapp.modeler.circles["circle_5952"] + circle = aedtapp.modeler.circles["circle_5952"] assert circle.center assert circle.radius circle.radius = "2.5mm" assert circle.radius == "2.5mm" - def test_02b_geo_units(self): - assert self.aedtapp.modeler.geometries["line_209"].object_units == "mm" - - def test_02c_geo_layer(self): - assert self.aedtapp.modeler.geometries["line_209"].placement_layer - assert len(self.aedtapp.modeler.layers.drawing_layers) > 0 - assert len(self.aedtapp.modeler.layers.all_signal_layers) > 0 - assert len(self.aedtapp.modeler.layers.all_diel_layers) > 0 - assert len(self.aedtapp.modeler.stackup.all_signal_layers) == len(self.aedtapp.modeler.stackup.signals) - assert len(self.aedtapp.modeler.stackup.all_diel_layers) == len(self.aedtapp.modeler.stackup.dielectrics) - assert len(self.aedtapp.modeler.stackup.stackup_layers) == len(self.aedtapp.modeler.stackup.drawings) - assert len(self.aedtapp.modeler.layers.all_signal_layers) + len( - self.aedtapp.modeler.layers.all_diel_layers - ) == len(self.aedtapp.modeler.layers.stackup_layers) - assert isinstance(self.aedtapp.modeler.layers.all_signal_layers[0].name, str) - assert isinstance(self.aedtapp.modeler.layers.all_diel_layers[0].name, str) - - def test_02d_geo_lock(self): - self.aedtapp.modeler.geometries["line_209"].lock_position = True - assert self.aedtapp.modeler.geometries["line_209"].lock_position == True - self.aedtapp.modeler.geometries["line_209"].lock_position = False - assert self.aedtapp.modeler.geometries["line_209"].lock_position == False - - def test_02e_geo_setter(self): - self.aedtapp.modeler.geometries["line_209"].layer = "PWR" - assert self.aedtapp.modeler.geometries["line_209"].layer == "PWR" - self.aedtapp.modeler.geometries["line_209"].net_name = "VCC" - assert self.aedtapp.modeler.geometries["line_209"].net_name == "VCC" - - def test_03_get_pins(self): - pins = self.aedtapp.modeler.pins + def test_02b_geo_units(self, aedtapp): + assert aedtapp.modeler.geometries["line_209"].object_units == "mm" + + def test_02c_geo_layer(self, aedtapp): + assert aedtapp.modeler.geometries["line_209"].placement_layer + assert len(aedtapp.modeler.layers.drawing_layers) > 0 + assert len(aedtapp.modeler.layers.all_signal_layers) > 0 + assert len(aedtapp.modeler.layers.all_diel_layers) > 0 + assert len(aedtapp.modeler.stackup.all_signal_layers) == len(aedtapp.modeler.stackup.signals) + assert len(aedtapp.modeler.stackup.all_diel_layers) == len(aedtapp.modeler.stackup.dielectrics) + assert len(aedtapp.modeler.stackup.stackup_layers) == len(aedtapp.modeler.stackup.drawings) + assert len(aedtapp.modeler.layers.all_signal_layers) + len(aedtapp.modeler.layers.all_diel_layers) == len( + aedtapp.modeler.layers.stackup_layers + ) + assert isinstance(aedtapp.modeler.layers.all_signal_layers[0].name, str) + assert isinstance(aedtapp.modeler.layers.all_diel_layers[0].name, str) + + def test_02d_geo_lock(self, aedtapp): + aedtapp.modeler.geometries["line_209"].lock_position = True + assert aedtapp.modeler.geometries["line_209"].lock_position == True + aedtapp.modeler.geometries["line_209"].lock_position = False + assert aedtapp.modeler.geometries["line_209"].lock_position == False + + def test_02e_geo_setter(self, aedtapp): + aedtapp.modeler.geometries["line_209"].layer = "PWR" + assert aedtapp.modeler.geometries["line_209"].layer == "PWR" + aedtapp.modeler.geometries["line_209"].net_name = "VCC" + assert aedtapp.modeler.geometries["line_209"].net_name == "VCC" + + def test_03_get_pins(self, aedtapp): + pins = aedtapp.modeler.pins assert len(pins) > 0 assert pins["L10-1"].object_units == "mm" assert pins["L10-1"].componentname == "L10" @@ -200,8 +189,8 @@ def test_03_get_pins(self): assert pins["L10-1"].start_layer == "1_Top" assert pins["L10-1"].stop_layer == "1_Top" - def test_03B_get_vias(self): - vias = self.aedtapp.modeler.vias + def test_03B_get_vias(self, aedtapp): + vias = aedtapp.modeler.vias assert len(vias) > 0 assert vias["Via1920"].object_units == "mm" assert not vias["Via1920"].is_pin @@ -211,54 +200,54 @@ def test_03B_get_vias(self): assert vias["Via1920"].stop_layer == "16_Bottom" assert vias["Via1920"].holediam == "0.1499997mm" - def test_03C_voids(self): - assert len(self.aedtapp.modeler.voids) > 0 - poly = self.aedtapp.modeler.polygons["poly_2084"] + def test_03C_voids(self, aedtapp): + assert len(aedtapp.modeler.voids) > 0 + poly = aedtapp.modeler.polygons["poly_2084"] assert len(poly.polygon_voids) > 0 - def test_04_add_mesh_operations(self): - self.aedtapp.create_setup("HFSS") - setup1 = self.aedtapp.mesh.assign_length_mesh("HFSS", "PWR", "GND") - setup2 = self.aedtapp.mesh.assign_skin_depth("HFSS", "PWR", "GND") + def test_04_add_mesh_operations(self, aedtapp): + aedtapp.create_setup("HFSS") + setup1 = aedtapp.mesh.assign_length_mesh("HFSS", "PWR", "GND") + setup2 = aedtapp.mesh.assign_skin_depth("HFSS", "PWR", "GND") assert setup1 assert setup2 setup1.props["RestrictElem"] = False assert setup1.update() - assert self.aedtapp.mesh.delete_mesh_operations( + assert aedtapp.mesh.delete_mesh_operations( "HFSS", setup1.name, ) - def test_05_change_property(self): - ports = self.aedtapp.create_ports_on_component_by_nets("U1", "DDR4_DQS0_P") - assert self.aedtapp.modeler.change_property(f"Excitations:{ports[0].name}", "Impedance", "49ohm", "EM Design") + def test_05_change_property(self, aedtapp): + ports = aedtapp.create_ports_on_component_by_nets("U1", "DDR4_DQS0_P") + assert aedtapp.modeler.change_property(f"Excitations:{ports[0].name}", "Impedance", "49ohm", "EM Design") - def test_06_assign_spice_model(self): + def test_06_assign_spice_model(self, aedtapp): model_path = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "GRM32ER72A225KA35_25C_0V.sp") - assert self.aedtapp.modeler.set_spice_model( + assert aedtapp.modeler.set_spice_model( assignment="C1", input_file=model_path, subcircuit_name="GRM32ER72A225KA35_25C_0V" ) - def test_07_nets(self): - nets = self.aedtapp.modeler.nets + def test_07_nets(self, aedtapp, local_scratch): + nets = aedtapp.modeler.nets assert nets["GND"].name == "GND" assert len(nets) > 0 assert len(nets["GND"].components) > 0 - local_png1 = os.path.join(self.local_scratch.path, "test1.png") + local_png1 = os.path.join(local_scratch.path, "test1.png") nets["AVCC_1V3"].plot(save_plot=local_png1, show=False) assert os.path.exists(local_png1) - def test_07a_nets_count(self): - nets = self.aedtapp.modeler.nets - power_nets = self.aedtapp.modeler.power_nets - signal_nets = self.aedtapp.modeler.signal_nets - no_nets = self.aedtapp.modeler.no_nets + def test_07a_nets_count(self, aedtapp): + nets = aedtapp.modeler.nets + power_nets = aedtapp.modeler.power_nets + signal_nets = aedtapp.modeler.signal_nets + no_nets = aedtapp.modeler.no_nets assert len(nets) == len(power_nets) + len(signal_nets) + len(no_nets) - def test_08_merge(self, add_app): + def test_08_merge(self, flipchip): tol = 1e-12 - brd = add_app(application=Hfss3dLayout, project_name=self.flipchip.project_name, design_name="Dummy_Board") - comp = brd.modeler.merge_design(self.flipchip, rotation=90) + brd = Hfss3dLayout(project=flipchip.project_name, design="Dummy_Board") + comp = brd.modeler.merge_design(flipchip, rotation=90) assert comp.location[0] == 0.0 assert comp.rotation_axis == "Z" comp.rotation_axis = "X" @@ -281,47 +270,47 @@ def test_08_merge(self, add_app): assert (comp.location[0] - 0.1) < tol assert (comp.location[1] - 0.2) < tol - def test_10_change_stackup(self): + def test_10_change_stackup(self, aedtapp): if config["NonGraphical"]: - assert self.aedtapp.modeler.layers.change_stackup_type("Multizone", 4) - assert len(self.aedtapp.modeler.layers.zones) == 3 - assert self.aedtapp.modeler.layers.change_stackup_type("Overlap") - assert self.aedtapp.modeler.layers.change_stackup_type("Laminate") - assert not self.aedtapp.modeler.layers.change_stackup_type("lami") + assert aedtapp.modeler.layers.change_stackup_type("Multizone", 4) + assert len(aedtapp.modeler.layers.zones) == 3 + assert aedtapp.modeler.layers.change_stackup_type("Overlap") + assert aedtapp.modeler.layers.change_stackup_type("Laminate") + assert not aedtapp.modeler.layers.change_stackup_type("lami") @pytest.mark.skipif(config["NonGraphical"], reason="Not running in non-graphical mode") - def test_11_export_picture(self): - assert os.path.exists(self.aedtapp.post.export_model_picture(orientation="top")) + def test_11_export_picture(self, aedtapp): + assert os.path.exists(aedtapp.post.export_model_picture(orientation="top")) - def test_12_objects_by_net(self): - poly_on_gnd = self.aedtapp.modeler.objects_by_net("GND", "poly") + def test_12_objects_by_net(self, aedtapp): + poly_on_gnd = aedtapp.modeler.objects_by_net("GND", "poly") assert len(poly_on_gnd) > 0 - assert self.aedtapp.modeler.geometries[poly_on_gnd[0]].net_name == "GND" + assert aedtapp.modeler.geometries[poly_on_gnd[0]].net_name == "GND" - def test_13_objects_by_layer(self): - lines_on_top = self.aedtapp.modeler.objects_by_layer("1_Top", "line") + def test_13_objects_by_layer(self, aedtapp): + lines_on_top = aedtapp.modeler.objects_by_layer("1_Top", "line") assert len(lines_on_top) > 0 - assert self.aedtapp.modeler.geometries[lines_on_top[0]].placement_layer == "1_Top" - - def test_14_set_solderball(self): - assert not self.aedtapp.modeler.components["U1"].die_enabled - assert not self.aedtapp.modeler.components["U1"].die_type - assert self.aedtapp.modeler.components["U1"].set_die_type() - assert self.aedtapp.modeler.components["U1"].set_solderball("Cyl") - assert self.aedtapp.modeler.components["U1"].solderball_enabled - assert self.aedtapp.modeler.components["U1"].set_solderball(None) - assert not self.aedtapp.modeler.components["U1"].solderball_enabled - assert not self.aedtapp.modeler.components["L10"].set_solderball(None) - assert self.aedtapp.modeler.components["J1"].set_solderball("Sph") - - def test_15_3dplacement(self): - self.aedtapp.insert_design("placement_3d") - l1 = self.aedtapp.modeler.layers.add_layer("BOTTOM", "signal") - self.aedtapp.modeler.layers.add_layer("diel", "dielectric") - self.aedtapp.modeler.layers.add_layer("TOP", "signal") + assert aedtapp.modeler.geometries[lines_on_top[0]].placement_layer == "1_Top" + + def test_14_set_solderball(self, aedtapp): + assert not aedtapp.modeler.components["U1"].die_enabled + assert not aedtapp.modeler.components["U1"].die_type + assert aedtapp.modeler.components["U1"].set_die_type() + assert aedtapp.modeler.components["U1"].set_solderball("Cyl") + assert aedtapp.modeler.components["U1"].solderball_enabled + assert aedtapp.modeler.components["U1"].set_solderball(None) + assert not aedtapp.modeler.components["U1"].solderball_enabled + assert not aedtapp.modeler.components["L10"].set_solderball(None) + assert aedtapp.modeler.components["J1"].set_solderball("Sph") + + def test_15_3dplacement(self, aedtapp): + aedtapp.insert_design("placement_3d") + l1 = aedtapp.modeler.layers.add_layer("BOTTOM", "signal") + aedtapp.modeler.layers.add_layer("diel", "dielectric") + aedtapp.modeler.layers.add_layer("TOP", "signal") tol = 1e-12 encrypted_model_path = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "SMA_RF_Jack.a3dcomp") - comp = self.aedtapp.modeler.place_3d_component( + comp = aedtapp.modeler.place_3d_component( encrypted_model_path, 1, placement_layer="TOP", component_name="my_connector", pos_x=0.001, pos_y=0.002 ) assert (comp.location[0] - 1.017) < tol @@ -333,29 +322,28 @@ def test_15_3dplacement(self): comp.angle = "10deg" assert comp.angle == "10deg" assert comp.component_name == "my_connector" - assert len(self.aedtapp.modeler.components_3d) == 1 - comp2 = self.aedtapp.modeler.place_3d_component( + assert len(aedtapp.modeler.components_3d) == 1 + comp2 = aedtapp.modeler.place_3d_component( encrypted_model_path, 1, component_name="my_connector2", pos_x=0.001, pos_y=0.002, pos_z=1 ) assert comp2.location[2] == 1.0 - def test_16_differential_ports(self): - self.aedtapp.set_active_design(self.design_name) - pins = list(self.aedtapp.modeler.components["R3"].pins.keys()) - assert self.aedtapp.create_differential_port(pins[0], pins[1], "test_differential", deembed=True) - assert "test_differential" in self.aedtapp.port_list + def test_16_differential_ports(self, aedtapp): + pins = list(aedtapp.modeler.components["R3"].pins.keys()) + assert aedtapp.create_differential_port(pins[0], pins[1], "test_differential", deembed=True) + assert "test_differential" in aedtapp.port_list - def test_17_ports_on_components_nets(self): - component = self.aedtapp.modeler.components["J1"] + def test_17_ports_on_components_nets(self, aedtapp): + component = aedtapp.modeler.components["J1"] nets = [ - self.aedtapp.modeler.pins[i].net_name + aedtapp.modeler.pins[i].net_name for i in component.pins - if "GND" not in self.aedtapp.modeler.pins[i].net_name and self.aedtapp.modeler.pins[i].net_name != "" + if "GND" not in aedtapp.modeler.pins[i].net_name and aedtapp.modeler.pins[i].net_name != "" ] - ports_before = len(self.aedtapp.port_list) - ports = self.aedtapp.create_ports_on_component_by_nets("J1", nets) + ports_before = len(aedtapp.port_list) + ports = aedtapp.create_ports_on_component_by_nets("J1", nets) assert ports - ports_after = len(self.aedtapp.port_list) + ports_after = len(aedtapp.port_list) assert ports_after - ports_before == len(nets) ports[0].name = "port_test" assert ports[0].name == "port_test" @@ -363,78 +351,74 @@ def test_17_ports_on_components_nets(self): ports[0].props["Port"] = "port_test2" assert ports[0].name == "port_test2" - def test_18_set_variable(self): - self.aedtapp.variable_manager.set_variable("var_test", expression="123") - self.aedtapp["var_test"] = "234" - assert "var_test" in self.aedtapp.variable_manager.design_variable_names - assert self.aedtapp.variable_manager.design_variables["var_test"].expression == "234" + def test_18_set_variable(self, aedtapp): + aedtapp.variable_manager.set_variable("var_test", expression="123") + aedtapp["var_test"] = "234" + assert "var_test" in aedtapp.variable_manager.design_variable_names + assert aedtapp.variable_manager.design_variables["var_test"].expression == "234" @pytest.mark.skipif(is_linux, reason="Not Supported on Linux.") - def test_19_dcir(self): + def test_19_dcir(self, dcir_example_project): import pandas as pd - setup = self.dcir_example_project.get_setup("SIwaveDCIR1") + setup = dcir_example_project.get_setup("SIwaveDCIR1") assert setup.is_solved - assert self.dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "RL", "Path Resistance") - assert self.dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "Vias", "Current") - solution_data = self.dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "Sources", "Voltage") - assert self.dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="") - assert self.dcir_example_project.post.create_report( - self.dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="Vias")[0], + assert dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "RL", "Path Resistance") + assert dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "Vias", "Current") + solution_data = dcir_example_project.get_dcir_solution_data("SIwaveDCIR1", "Sources", "Voltage") + assert dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="") + assert dcir_example_project.post.create_report( + dcir_example_project.post.available_report_quantities(is_siwave_dc=True, context="Vias")[0], domain="DCIR", context="RL", ) - assert isinstance(self.dcir_example_project.get_dcir_element_data_current_source("SIwaveDCIR1"), pd.DataFrame) - assert self.dcir_example_project.post.compute_power_by_layer() - assert self.dcir_example_project.post.compute_power_by_layer(layers=["1_Top"]) - assert self.dcir_example_project.post.compute_power_by_net() - assert self.dcir_example_project.post.compute_power_by_net(nets=["5V", "GND"]) - assert self.dcir_example_project.post.compute_power_by_layer(solution="SIwaveDCIR1") - - def test_20_change_options(self): - assert self.aedtapp.change_options() - assert self.aedtapp.change_options(color_by_net=False) - assert not self.aedtapp.change_options(color_by_net=None) - - def test_21_show_extent(self): - assert self.aedtapp.show_extent() - assert self.aedtapp.show_extent(show=False) - assert not self.aedtapp.show_extent(show=None) - - def test_22_change_design_settings(self): - assert ( - self.aedtapp.get_oo_property_value(self.aedtapp.odesign, "Design Settings", "DCExtrapolation") == "Standard" - ) - assert self.aedtapp.change_design_settings({"UseAdvancedDCExtrap": True}) - assert ( - self.aedtapp.get_oo_property_value(self.aedtapp.odesign, "Design Settings", "DCExtrapolation") == "Advanced" - ) - - def test_23_dissolve_element(self): - comp = self.aedtapp.modeler.components["D1"] + assert isinstance(dcir_example_project.get_dcir_element_data_current_source("SIwaveDCIR1"), pd.DataFrame) + assert dcir_example_project.post.compute_power_by_layer() + assert dcir_example_project.post.compute_power_by_layer(layers=["1_Top"]) + assert dcir_example_project.post.compute_power_by_net() + assert dcir_example_project.post.compute_power_by_net(nets=["5V", "GND"]) + assert dcir_example_project.post.compute_power_by_layer(solution="SIwaveDCIR1") + + def test_20_change_options(self, aedtapp): + assert aedtapp.change_options() + assert aedtapp.change_options(color_by_net=False) + assert not aedtapp.change_options(color_by_net=None) + + def test_21_show_extent(self, aedtapp): + assert aedtapp.show_extent() + assert aedtapp.show_extent(show=False) + assert not aedtapp.show_extent(show=None) + + def test_22_change_design_settings(self, aedtapp): + assert aedtapp.get_oo_property_value(aedtapp.odesign, "Design Settings", "DCExtrapolation") == "Standard" + assert aedtapp.change_design_settings({"UseAdvancedDCExtrap": True}) + assert aedtapp.get_oo_property_value(aedtapp.odesign, "Design Settings", "DCExtrapolation") == "Advanced" + + def test_23_dissolve_element(self, aedtapp): + comp = aedtapp.modeler.components["D1"] pins = {name: pin for name, pin in comp.pins.items() if name in ["D1-1", "D1-2", "D1-7"]} - self.aedtapp.dissolve_component("D1") - comp = self.aedtapp.modeler.create_component_on_pins(list(pins.keys())) + aedtapp.dissolve_component("D1") + comp = aedtapp.modeler.create_component_on_pins(list(pins.keys())) nets = [ list(pins.values())[0].net_name, list(pins.values())[1].net_name, ] - assert self.aedtapp.create_ports_on_component_by_nets(comp.name, nets) - assert self.aedtapp.create_pec_on_component_by_nets(comp.name, "GND") + assert aedtapp.create_ports_on_component_by_nets(comp.name, nets) + assert aedtapp.create_pec_on_component_by_nets(comp.name, "GND") @pytest.mark.skipif(config["desktopVersion"] <= "2024.1", reason="Introduced in 2024R1") - def test_24_open_ic_mode_design(self): - assert self.ic_mode_design.ic_mode + def test_24_open_ic_mode_design(self, ic_mode_design): + assert ic_mode_design.ic_mode - def test_25a_set_port_properties(self): - component: Components3DLayout = self.aedtapp.modeler.components["Q1"] + def test_25a_set_port_properties(self, aedtapp): + component: Components3DLayout = aedtapp.modeler.components["Q1"] assert component.port_properties == ("0", True, "0", "0") new_values = ("10um", False, "0um", "0um") component.port_properties = new_values assert component.port_properties == new_values - def test_25b_set_port_properties_on_ic_component(self): - component: Components3DLayout = self.aedtapp.modeler.components["U10"] + def test_25b_set_port_properties_on_ic_component(self, aedtapp): + component: Components3DLayout = aedtapp.modeler.components["U10"] original_die_properties = component.die_properties assert component.port_properties == ("0", True, "0", "0") new_values = ("10um", False, "0um", "0um") @@ -442,28 +426,28 @@ def test_25b_set_port_properties_on_ic_component(self): assert component.port_properties == new_values assert component.die_properties == original_die_properties - def test_25c_get_properties_on_rlc_component(self): - component: Components3DLayout = self.aedtapp.modeler.components["C1"] + def test_25c_get_properties_on_rlc_component(self, aedtapp): + component: Components3DLayout = aedtapp.modeler.components["C1"] assert component.die_properties is None assert component.port_properties is None - def test_25d_set_port_properties_on_rlc_component(self): - component: Components3DLayout = self.aedtapp.modeler.components["C1"] + def test_25d_set_port_properties_on_rlc_component(self, aedtapp): + component: Components3DLayout = aedtapp.modeler.components["C1"] component.port_properties = ("10um", False, "0um", "0um") assert component.port_properties is None - def test_26_import_table(self): - self.aedtapp.insert_design("import_table") + def test_26_import_table(self, aedtapp): + aedtapp.insert_design("import_table") file_header = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "table_header.csv") file_invented = "invented.csv" - assert not self.aedtapp.import_table(file_header, column_separator="dummy") - assert not self.aedtapp.import_table(file_invented) + assert not aedtapp.import_table(file_header, column_separator="dummy") + assert not aedtapp.import_table(file_invented) - table = self.aedtapp.import_table(file_header) - assert table in self.aedtapp.existing_analysis_sweeps + table = aedtapp.import_table(file_header) + assert table in aedtapp.existing_analysis_sweeps - assert not self.aedtapp.delete_imported_data("invented") + assert not aedtapp.delete_imported_data("invented") - assert self.aedtapp.delete_imported_data(table) - assert table not in self.aedtapp.existing_analysis_sweeps + assert aedtapp.delete_imported_data(table) + assert table not in aedtapp.existing_analysis_sweeps diff --git a/tests/system/general/test_12_1_PostProcessing.py b/tests/system/general/test_12_1_PostProcessing.py index c03c327e662..630348a29cf 100644 --- a/tests/system/general/test_12_1_PostProcessing.py +++ b/tests/system/general/test_12_1_PostProcessing.py @@ -62,108 +62,101 @@ @pytest.fixture(scope="class") def aedtapp(add_app): app = add_app(project_name=test_project_name, subfolder=test_subfolder) - return app + yield app + app.close_project(app.project_name) class TestClass: - @pytest.fixture(autouse=True) - def init(self, aedtapp, local_scratch): - self.aedtapp = aedtapp - self.local_scratch = local_scratch @pytest.mark.skipif(config["NonGraphical"], reason="Failing on build machine when running in parallel.") - def test_01_export_model_picture(self): - path = self.aedtapp.post.export_model_picture(full_name=os.path.join(self.local_scratch.path, "images2.jpg")) + def test_01_export_model_picture(self, aedtapp, local_scratch): + path = aedtapp.post.export_model_picture(full_name=os.path.join(local_scratch.path, "images2.jpg")) assert path - path = self.aedtapp.post.export_model_picture( - full_name=os.path.join(self.local_scratch.path, "images3.jpg"), + path = aedtapp.post.export_model_picture( + full_name=os.path.join(local_scratch.path, "images3.jpg"), show_axis=True, show_grid=False, show_ruler=True, ) assert os.path.exists(path) - path = self.aedtapp.post.export_model_picture(full_name=os.path.join(self.local_scratch.path, "images4.jpg")) + path = aedtapp.post.export_model_picture(full_name=os.path.join(local_scratch.path, "images4.jpg")) assert path - def test_01B_Field_Plot(self): - self.aedtapp.analyze(self.aedtapp.active_setup) - assert len(self.aedtapp.post.available_display_types()) > 0 - assert len(self.aedtapp.post.available_report_types) > 0 - assert len(self.aedtapp.post.available_report_quantities()) > 0 - assert isinstance(self.aedtapp.post.get_all_report_quantities(solution="Setup1 : LastAdaptive"), dict) - assert len(self.aedtapp.post.available_report_solutions()) > 0 + def test_01B_Field_Plot(self, aedtapp, local_scratch): + aedtapp.analyze(aedtapp.active_setup) + assert len(aedtapp.post.available_display_types()) > 0 + assert len(aedtapp.post.available_report_types) > 0 + assert len(aedtapp.post.available_report_quantities()) > 0 + assert isinstance(aedtapp.post.get_all_report_quantities(solution="Setup1 : LastAdaptive"), dict) + assert len(aedtapp.post.available_report_solutions()) > 0 cutlist = ["Global:XY", "Global:XZ", "Global:YZ"] - setup_name = self.aedtapp.existing_analysis_sweeps[0] - assert self.aedtapp.setups[0].is_solved + setup_name = aedtapp.existing_analysis_sweeps[0] + assert aedtapp.setups[0].is_solved quantity_name = "ComplexMag_E" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} - min_value = self.aedtapp.post.get_scalar_field_value(quantity_name, "Minimum", setup_name, intrinsics="5GHz") - plot1 = self.aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic) + min_value = aedtapp.post.get_scalar_field_value(quantity_name, "Minimum", setup_name, intrinsics="5GHz") + plot1 = aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic) plot1.IsoVal = "Tone" plot1.update_field_plot_settings() plot1.update() - assert self.aedtapp.post.field_plots[plot1.name].IsoVal == "Tone" + assert aedtapp.post.field_plots[plot1.name].IsoVal == "Tone" assert plot1.change_plot_scale(min_value, "30000", scale_levels=50) - assert self.aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic, plot1.name) - assert not self.aedtapp.post.create_fieldplot_volume("invalid", "Vector_E", setup_name, intrinsic) - field_plot = self.aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic) + assert aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic, plot1.name) + assert not aedtapp.post.create_fieldplot_volume("invalid", "Vector_E", setup_name, intrinsic) + field_plot = aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic) assert field_plot - assert self.aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic, field_plot.name) + assert aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic, field_plot.name) - volume_plot = self.aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Vector_E", setup_name, intrinsic) + volume_plot = aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Vector_E", setup_name, intrinsic) - export_status = self.aedtapp.post.export_field_plot( - plot_name=volume_plot.name, output_dir=self.aedtapp.working_directory, file_format="case" + export_status = aedtapp.post.export_field_plot( + plot_name=volume_plot.name, output_dir=aedtapp.working_directory, file_format="case" ) assert export_status assert os.path.splitext(export_status)[1] == ".case" - field_plot = self.aedtapp.post.create_fieldplot_surface( - self.aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic + field_plot = aedtapp.post.create_fieldplot_surface( + aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic ) assert field_plot - assert self.aedtapp.post.create_fieldplot_surface( - self.aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic, field_plot.name - ) - assert self.aedtapp.post.create_fieldplot_surface(self.aedtapp.modeler["outer"], "Mag_E", setup_name, intrinsic) - assert self.aedtapp.post.create_fieldplot_surface( - self.aedtapp.modeler["outer"].faces, "Mag_E", setup_name, intrinsic - ) - assert not self.aedtapp.post.create_fieldplot_surface(123123123, "Mag_E", setup_name, intrinsic) - assert len(self.aedtapp.setups[0].sweeps[0].frequencies) > 0 - assert isinstance(self.aedtapp.setups[0].sweeps[0].basis_frequencies, list) - mesh_file_path = self.aedtapp.post.export_mesh_obj(setup_name, intrinsic) + assert aedtapp.post.create_fieldplot_surface( + aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic, field_plot.name + ) + assert aedtapp.post.create_fieldplot_surface(aedtapp.modeler["outer"], "Mag_E", setup_name, intrinsic) + assert aedtapp.post.create_fieldplot_surface(aedtapp.modeler["outer"].faces, "Mag_E", setup_name, intrinsic) + assert not aedtapp.post.create_fieldplot_surface(123123123, "Mag_E", setup_name, intrinsic) + assert len(aedtapp.setups[0].sweeps[0].frequencies) > 0 + assert isinstance(aedtapp.setups[0].sweeps[0].basis_frequencies, list) + mesh_file_path = aedtapp.post.export_mesh_obj(setup_name, intrinsic) assert os.path.exists(mesh_file_path) - mesh_file_path2 = self.aedtapp.post.export_mesh_obj( + mesh_file_path2 = aedtapp.post.export_mesh_obj( setup_name, intrinsic, export_air_objects=True, on_surfaces=False ) assert os.path.exists(mesh_file_path2) - min_value = self.aedtapp.post.get_scalar_field_value( - "E", "Minimum", setup_name, intrinsics="5GHz", is_vector=True - ) + min_value = aedtapp.post.get_scalar_field_value("E", "Minimum", setup_name, intrinsics="5GHz", is_vector=True) assert isinstance(min_value, float) @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") - def test_01_Animate_plt(self): + def test_01_Animate_plt(self, aedtapp, local_scratch): cutlist = ["Global:XY"] phases = [str(i * 5) + "deg" for i in range(2)] - model_gif = self.aedtapp.post.plot_animated_field( + model_gif = aedtapp.post.plot_animated_field( quantity="Mag_E", assignment=cutlist, plot_type="CutPlane", - setup=self.aedtapp.nominal_adaptive, + setup=aedtapp.nominal_adaptive, intrinsics={"Freq": "5GHz", "Phase": "0deg"}, variation_variable="Phase", variations=phases, show=False, export_gif=True, - export_path=self.local_scratch.path, + export_path=local_scratch.path, ) assert os.path.exists(model_gif.gif_file) - setup_name = self.aedtapp.existing_analysis_sweeps[0] + setup_name = aedtapp.existing_analysis_sweeps[0] intrinsic = {"Freq": "5GHz", "Phase": "180deg"} - pl1 = self.aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Mag_E", setup_name, intrinsic) - model_gif2 = self.aedtapp.post.animate_fields_from_aedtplt( + pl1 = aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Mag_E", setup_name, intrinsic) + model_gif2 = aedtapp.post.animate_fields_from_aedtplt( plot_name=pl1.name, plot_folder=None, variation_variable="Phase", @@ -172,82 +165,74 @@ def test_01_Animate_plt(self): export_gif=False, show=False, ) - model_gif2.gif_file = os.path.join(self.aedtapp.working_directory, "test2.gif") + model_gif2.gif_file = os.path.join(aedtapp.working_directory, "test2.gif") model_gif2.camera_position = [0, 50, 200] model_gif2.focal_point = [0, 50, 0] model_gif2.animate() assert os.path.exists(model_gif2.gif_file) @pytest.mark.skipif(config["NonGraphical"], reason="Not running in non-graphical mode") - def test_02_export_fields(self): + def test_02_export_fields(self, aedtapp, local_scratch): quantity_name2 = "ComplexMag_H" setup_name = "Setup1 : LastAdaptive" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} vollist = ["NewObject_IJD39Q"] - plot2 = self.aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic) + plot2 = aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic) - self.aedtapp.post.export_field_jpg( - os.path.join(self.local_scratch.path, "prova2.jpg"), plot2.name, plot2.plot_folder - ) - assert os.path.exists(os.path.join(self.local_scratch.path, "prova2.jpg")) - assert os.path.exists(plot2.export_image(os.path.join(self.local_scratch.path, "test_x.jpg"))) + aedtapp.post.export_field_jpg(os.path.join(local_scratch.path, "prova2.jpg"), plot2.name, plot2.plot_folder) + assert os.path.exists(os.path.join(local_scratch.path, "prova2.jpg")) + assert os.path.exists(plot2.export_image(os.path.join(local_scratch.path, "test_x.jpg"))) - def test_03_create_scattering(self): + def test_03_create_scattering(self, aedtapp): portnames = ["1", "2"] - assert self.aedtapp.create_scattering("MyTestScattering") + assert aedtapp.create_scattering("MyTestScattering") setup_name = "Setup2 : Sweep" - assert not self.aedtapp.create_scattering("MyTestScattering2", setup_name, portnames, portnames) + assert not aedtapp.create_scattering("MyTestScattering2", setup_name, portnames, portnames) - def test_03_get_solution_data(self): + def test_03_get_solution_data(self, aedtapp, local_scratch): trace_names = [] portnames = ["1", "2"] for el in portnames: for el2 in portnames: trace_names.append("S(" + el + "," + el2 + ")") families = {"Freq": ["All"]} - for el in self.aedtapp.available_variations.nominal_w_values_dict: - families[el] = self.aedtapp.available_variations.nominal_w_values_dict[el] + for el in aedtapp.available_variations.nominal_w_values_dict: + families[el] = aedtapp.available_variations.nominal_w_values_dict[el] - my_data = self.aedtapp.post.get_solution_data(expressions=trace_names, variations=families) + my_data = aedtapp.post.get_solution_data(expressions=trace_names, variations=families) assert my_data assert my_data.expressions assert len(my_data.data_db10(trace_names[0])) > 0 assert len(my_data.data_imag(trace_names[0])) > 0 assert len(my_data.data_real(trace_names[0])) > 0 assert len(my_data.data_magnitude(trace_names[0])) > 0 - assert my_data.export_data_to_csv(os.path.join(self.local_scratch.path, "output.csv")) - assert os.path.exists(os.path.join(self.local_scratch.path, "output.csv")) - assert self.aedtapp.get_touchstone_data("Setup1") + assert my_data.export_data_to_csv(os.path.join(local_scratch.path, "output.csv")) + assert os.path.exists(os.path.join(local_scratch.path, "output.csv")) + assert aedtapp.get_touchstone_data("Setup1") - def test_04_export_touchstone(self): + def test_04_export_touchstone(self, aedtapp, local_scratch): setup_name = "Setup1" sweep_name = "Sweep" - self.aedtapp.export_touchstone( - setup_name, sweep_name, os.path.join(self.local_scratch.path, "Setup1_Sweep.S2p") - ) - assert os.path.exists(os.path.join(self.local_scratch.path, "Setup1_Sweep.S2p")) + aedtapp.export_touchstone(setup_name, sweep_name, os.path.join(local_scratch.path, "Setup1_Sweep.S2p")) + assert os.path.exists(os.path.join(local_scratch.path, "Setup1_Sweep.S2p")) sweep_name = None - self.aedtapp.export_touchstone( - setup_name, sweep_name, os.path.join(self.local_scratch.path, "Setup1_Sweep2.S2p") - ) - assert os.path.exists(os.path.join(self.local_scratch.path, "Setup1_Sweep2.S2p")) + aedtapp.export_touchstone(setup_name, sweep_name, os.path.join(local_scratch.path, "Setup1_Sweep2.S2p")) + assert os.path.exists(os.path.join(local_scratch.path, "Setup1_Sweep2.S2p")) setup_name = None - self.aedtapp.export_touchstone( - setup_name, sweep_name, os.path.join(self.local_scratch.path, "Setup1_Sweep3.S2p") - ) - assert os.path.exists(os.path.join(self.local_scratch.path, "Setup1_Sweep3.S2p")) + aedtapp.export_touchstone(setup_name, sweep_name, os.path.join(local_scratch.path, "Setup1_Sweep3.S2p")) + assert os.path.exists(os.path.join(local_scratch.path, "Setup1_Sweep3.S2p")) - assert self.aedtapp.export_touchstone(setup_name, sweep_name) + assert aedtapp.export_touchstone(setup_name, sweep_name) @pytest.mark.skipif(config["desktopVersion"] != "2023.1", reason="Not running in non-graphical mode") - def test_05_export_report_to_jpg(self): - self.aedtapp.post.export_report_to_jpg(self.local_scratch.path, "MyTestScattering") - assert os.path.exists(os.path.join(self.local_scratch.path, "MyTestScattering.jpg")) + def test_05_export_report_to_jpg(self, aedtapp, local_scratch): + aedtapp.post.export_report_to_jpg(local_scratch.path, "MyTestScattering") + assert os.path.exists(os.path.join(local_scratch.path, "MyTestScattering.jpg")) - def test_06_export_report_to_csv(self): - self.aedtapp.post.export_report_to_csv( - self.local_scratch.path, + def test_06_export_report_to_csv(self, aedtapp, local_scratch): + aedtapp.post.export_report_to_csv( + local_scratch.path, "MyTestScattering", start="3GHz", end="6GHz", @@ -255,18 +240,18 @@ def test_06_export_report_to_csv(self): uniform=True, use_trace_number_format=False, ) - assert os.path.exists(os.path.join(self.local_scratch.path, "MyTestScattering.csv")) + assert os.path.exists(os.path.join(local_scratch.path, "MyTestScattering.csv")) - def test_06_export_report_to_rdat(self): - self.aedtapp.post.export_report_to_file(self.local_scratch.path, "MyTestScattering", ".rdat") - assert os.path.exists(os.path.join(self.local_scratch.path, "MyTestScattering.rdat")) + def test_06_export_report_to_rdat(self, aedtapp, local_scratch): + aedtapp.post.export_report_to_file(local_scratch.path, "MyTestScattering", ".rdat") + assert os.path.exists(os.path.join(local_scratch.path, "MyTestScattering.rdat")) - def test_07_export_fields_from_Calculator(self): - file_path = self.aedtapp.post.export_field_file_on_grid( + def test_07_export_fields_from_Calculator(self, aedtapp, local_scratch): + file_path = aedtapp.post.export_field_file_on_grid( "E", "Setup1 : LastAdaptive", - self.aedtapp.available_variations.nominal_w_values_dict, - self.local_scratch.path, + aedtapp.available_variations.nominal_w_values_dict, + local_scratch.path, grid_stop=[5, 5, 5], grid_step=[0.5, 0.5, 0.5], is_vector=True, @@ -274,10 +259,10 @@ def test_07_export_fields_from_Calculator(self): ) assert os.path.exists(file_path) - file_path = self.aedtapp.post.export_field_file_on_grid( + file_path = aedtapp.post.export_field_file_on_grid( "E", "Setup1 : LastAdaptive", - self.aedtapp.available_variations.nominal_w_values_dict, + aedtapp.available_variations.nominal_w_values_dict, grid_stop=[5, 5, 5], grid_step=[0.5, 0.5, 0.5], is_vector=True, @@ -285,100 +270,98 @@ def test_07_export_fields_from_Calculator(self): ) assert os.path.exists(file_path) - self.aedtapp.post.export_field_file_on_grid( + aedtapp.post.export_field_file_on_grid( "E", "Setup1 : LastAdaptive", - self.aedtapp.available_variations.nominal_w_values_dict, - os.path.join(self.local_scratch.path, "Efield.fld"), + aedtapp.available_variations.nominal_w_values_dict, + os.path.join(local_scratch.path, "Efield.fld"), grid_stop=[5, 5, 5], grid_step=[0.5, 0.5, 0.5], is_vector=True, intrinsics="5GHz", ) - assert os.path.exists(os.path.join(self.local_scratch.path, "Efield.fld")) + assert os.path.exists(os.path.join(local_scratch.path, "Efield.fld")) - self.aedtapp.post.export_field_file_on_grid( + aedtapp.post.export_field_file_on_grid( "Mag_E", "Setup1 : LastAdaptive", - self.aedtapp.available_variations.nominal_w_values_dict, - os.path.join(self.local_scratch.path, "MagEfieldSph.fld"), + aedtapp.available_variations.nominal_w_values_dict, + os.path.join(local_scratch.path, "MagEfieldSph.fld"), grid_type="Spherical", grid_stop=[5, 300, 300], grid_step=[5, 50, 50], is_vector=False, intrinsics="5GHz", ) - assert os.path.exists(os.path.join(self.local_scratch.path, "MagEfieldSph.fld")) + assert os.path.exists(os.path.join(local_scratch.path, "MagEfieldSph.fld")) - self.aedtapp.post.export_field_file_on_grid( + aedtapp.post.export_field_file_on_grid( "Mag_E", "Setup1 : LastAdaptive", - self.aedtapp.available_variations.nominal_w_values_dict, - os.path.join(self.local_scratch.path, "MagEfieldCyl.fld"), + aedtapp.available_variations.nominal_w_values_dict, + os.path.join(local_scratch.path, "MagEfieldCyl.fld"), grid_type="Cylindrical", grid_stop=[5, 300, 5], grid_step=[5, 50, 5], is_vector=False, intrinsics="5GHz", ) - assert os.path.exists(os.path.join(self.local_scratch.path, "MagEfieldCyl.fld")) + assert os.path.exists(os.path.join(local_scratch.path, "MagEfieldCyl.fld")) - def test_07_copydata(self): - assert self.aedtapp.post.copy_report_data("MyTestScattering") + def test_07_copydata(self, aedtapp, local_scratch): + assert aedtapp.post.copy_report_data("MyTestScattering") - def test_08_manipulate_report(self): - assert self.aedtapp.post.rename_report("MyTestScattering", "MyNewScattering") - assert [plot for plot in self.aedtapp.post.plots if plot.plot_name == "MyNewScattering"] - assert not self.aedtapp.post.rename_report("invalid", "MyNewScattering") + def test_08_manipulate_report(self, aedtapp, local_scratch): + assert aedtapp.post.rename_report("MyTestScattering", "MyNewScattering") + assert [plot for plot in aedtapp.post.plots if plot.plot_name == "MyNewScattering"] + assert not aedtapp.post.rename_report("invalid", "MyNewScattering") - def test_09_manipulate_report(self): - plot = self.aedtapp.post.create_report("dB(S(1,1))") + def test_09_manipulate_report(self, aedtapp, local_scratch): + plot = aedtapp.post.create_report("dB(S(1,1))") assert plot - assert plot.export_config(os.path.join(self.local_scratch.path, f"{plot.plot_name}.json")) - assert self.aedtapp.post.create_report_from_configuration( - os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"), solution_name=self.aedtapp.nominal_sweep + assert plot.export_config(os.path.join(local_scratch.path, f"{plot.plot_name}.json")) + assert aedtapp.post.create_report_from_configuration( + os.path.join(local_scratch.path, f"{plot.plot_name}.json"), solution_name=aedtapp.nominal_sweep ) - assert self.aedtapp.post.create_report_from_configuration( - os.path.join(self.local_scratch.path, f"{plot.plot_name}.json"), - solution_name=self.aedtapp.nominal_sweep, + assert aedtapp.post.create_report_from_configuration( + os.path.join(local_scratch.path, f"{plot.plot_name}.json"), + solution_name=aedtapp.nominal_sweep, matplotlib=True, ) - assert self.aedtapp.post.create_report( + assert aedtapp.post.create_report( expressions="MaxMagDeltaS", variations={"Pass": ["All"]}, primary_sweep_variable="Pass", report_category="Modal Solution Data", plot_type="Rectangular Plot", ) - new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") assert new_report.create() - data = self.aedtapp.post.get_solution_data("S(1,1)") + data = aedtapp.post.get_solution_data("S(1,1)") assert data.primary_sweep == "Freq" assert data.expressions[0] == "S(1,1)" - assert len(self.aedtapp.post.all_report_names) > 0 + assert len(aedtapp.post.all_report_names) > 0 - new_report = self.aedtapp.post.reports_by_category.modal_solution( - "dB(S(1,1))", setup=self.aedtapp.nominal_sweep - ) + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))", setup=aedtapp.nominal_sweep) assert new_report.create() - def test_09c_import_into_report(self): - new_report = self.aedtapp.create_scattering("import_test") - csv_file_path = self.aedtapp.post.export_report_to_csv(self.local_scratch.path, "import_test") - rdat_file_path = self.aedtapp.post.export_report_to_file(self.local_scratch.path, "import_test", ".rdat") + def test_09c_import_into_report(self, aedtapp, local_scratch): + new_report = aedtapp.create_scattering("import_test") + csv_file_path = aedtapp.post.export_report_to_csv(local_scratch.path, "import_test") + rdat_file_path = aedtapp.post.export_report_to_file(local_scratch.path, "import_test", ".rdat") plot_name = new_report.plot_name trace_names = [] trace_names.append(new_report.expressions[0]) families = {"Freq": ["All"]} - for el in self.aedtapp.available_variations.nominal_w_values_dict: - families[el] = self.aedtapp.available_variations.nominal_w_values_dict[el] + for el in aedtapp.available_variations.nominal_w_values_dict: + families[el] = aedtapp.available_variations.nominal_w_values_dict[el] # get solution data and save in .csv file - my_data = self.aedtapp.post.get_solution_data(expressions=trace_names, variations=families) - my_data.export_data_to_csv(os.path.join(self.local_scratch.path, "output.csv")) - csv_solution_data_file_path = os.path.join(self.local_scratch.path, "output.csv") + my_data = aedtapp.post.get_solution_data(expressions=trace_names, variations=families) + my_data.export_data_to_csv(os.path.join(local_scratch.path, "output.csv")) + csv_solution_data_file_path = os.path.join(local_scratch.path, "output.csv") assert not new_report.import_traces(csv_solution_data_file_path, plot_name) # test import with correct inputs from csv @@ -395,8 +378,8 @@ def test_09c_import_into_report(self): with pytest.raises(ValueError): new_report.import_traces(csv_file_path, None) - def test_09d_delete_traces_from_report(self): - new_report = self.aedtapp.create_scattering("delete_traces_test") + def test_09d_delete_traces_from_report(self, aedtapp, local_scratch): + new_report = aedtapp.create_scattering("delete_traces_test") traces_to_delete = [new_report.expressions[0]] plot_name = new_report.plot_name assert new_report.delete_traces(plot_name, traces_to_delete) @@ -405,42 +388,42 @@ def test_09d_delete_traces_from_report(self): with pytest.raises(ValueError): new_report.delete_traces(plot_name, ["V(out)_Test"]) - def test_09e_add_traces_to_report(self): - new_report = self.aedtapp.create_scattering("add_traces_test") + def test_09e_add_traces_to_report(self, aedtapp): + new_report = aedtapp.create_scattering("add_traces_test") traces = new_report.get_solution_data().expressions assert new_report.add_trace_to_report(traces) - setup = self.aedtapp.post.plots[0].setup - variations = self.aedtapp.post.plots[0].variations["height"] = "10mm" + setup = aedtapp.post.plots[0].setup + variations = aedtapp.post.plots[0].variations["height"] = "10mm" assert not new_report.add_trace_to_report(traces, setup, variations) - variations = self.aedtapp.post.plots[0].variations + variations = aedtapp.post.plots[0].variations assert new_report.add_trace_to_report(traces, setup, variations) setup = "Transient" assert not new_report.add_trace_to_report(traces, setup, variations) - def test_09f_update_trace_name(self): - report = self.aedtapp.create_scattering("add_traces_test_2") + def test_09f_update_trace_name(self, aedtapp): + report = aedtapp.create_scattering("add_traces_test_2") old_trace_name = report.traces[0].name assert old_trace_name in report.traces[0].aedt_name new_name = "update_trace_name_test" report.traces[0].name = new_name assert new_name in report.traces[0].aedt_name - def test_09g_update_traces_in_report(self): - new_report = self.aedtapp.create_scattering("update_traces_test") + def test_09g_update_traces_in_report(self, aedtapp): + new_report = aedtapp.create_scattering("update_traces_test") traces = new_report.get_solution_data().expressions assert new_report.update_trace_in_report(traces) - setup = self.aedtapp.post.plots[0].setup - variations = self.aedtapp.post.plots[0].variations["height"] = "10mm" + setup = aedtapp.post.plots[0].setup + variations = aedtapp.post.plots[0].variations["height"] = "10mm" assert not new_report.add_trace_to_report(traces, setup, variations) - variations = self.aedtapp.post.plots[0].variations + variations = aedtapp.post.plots[0].variations assert new_report.update_trace_in_report(traces, setup, variations) @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." ) - def test_09h_create_monitor(self): # pragma: no cover - assert self.aedtapp.post.create_report("dB(S(1,1))") - new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + def test_09h_create_monitor(self, aedtapp): # pragma: no cover + assert aedtapp.post.create_report("dB(S(1,1))") + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") assert new_report.create() assert new_report.add_cartesian_x_marker("3GHz") @@ -450,24 +433,24 @@ def test_09h_create_monitor(self): # pragma: no cover config["desktopVersion"] < "2022.2", reason="Skipped because it cannot run on build machine in non-graphical mode", ) - def test_09i_add_line_from_point(self): # pragma: no cover - new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + def test_09i_add_line_from_point(self, aedtapp): # pragma: no cover + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") assert new_report.create() assert new_report.add_limit_line_from_points([3, 5, 5, 3], [-50, -50, -60, -60], "GHz") @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." ) - def test_09l_add_line_from_equation(self): - new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + def test_09l_add_line_from_equation(self, aedtapp): + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") assert new_report.create() assert new_report.add_limit_line_from_equation(start_x=1, stop_x=20, step=0.5, units="GHz") @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." ) - def test_09m_edit_properties(self): - report = self.aedtapp.post.create_report("dB(S(1,1))") + def test_09m_edit_properties(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_grid() assert report.edit_grid(minor_x=False) assert report.edit_grid(major_y=False) @@ -523,8 +506,8 @@ def test_09m_edit_properties(self): @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." ) - def test_09n_add_line_from_point(self): # pragma: no cover - new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + def test_09n_add_line_from_point(self, aedtapp): # pragma: no cover + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") new_report.create() style = new_report.traces[0].LINESTYLE trace = new_report.traces[0].TRACETYPE @@ -544,8 +527,8 @@ def test_09n_add_line_from_point(self): # pragma: no cover @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." ) - def test_09o_add_note(self): # pragma: no cover - new_report = self.aedtapp.post.reports_by_category.modal_solution() + def test_09o_add_note(self, aedtapp): # pragma: no cover + new_report = aedtapp.post.reports_by_category.modal_solution() new_report.create() new_report.add_note("Test", 8000, 1500) @@ -560,30 +543,30 @@ def test_09o_add_note(self): # pragma: no cover color=(255, 0, 0), ) - def test_10_delete_report(self): - plots_number = len(self.aedtapp.post.plots) - assert self.aedtapp.post.delete_report("MyNewScattering") - assert len(self.aedtapp.post.plots) == plots_number - 1 - assert self.aedtapp.post.delete_report() - assert len(self.aedtapp.post.plots) == 0 + def test_10_delete_report(self, aedtapp): + plots_number = len(aedtapp.post.plots) + assert aedtapp.post.delete_report("MyNewScattering") + assert len(aedtapp.post.plots) == plots_number - 1 + assert aedtapp.post.delete_report() + assert len(aedtapp.post.plots) == 0 - def test_12_steal_on_focus(self): - assert self.aedtapp.post.steal_focus_oneditor() + def test_12_steal_on_focus(self, aedtapp): + assert aedtapp.post.steal_focus_oneditor() @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") - def test_14_Field_Ploton_cutplanedesignname(self): + def test_14_Field_Ploton_cutplanedesignname(self, aedtapp, local_scratch): cutlist = ["Global:XY"] - setup_name = self.aedtapp.existing_analysis_sweeps[0] + setup_name = aedtapp.existing_analysis_sweeps[0] quantity_name = "ComplexMag_E" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} - self.aedtapp.logger.info("Generating the plot") - plot1 = self.aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic) + aedtapp.logger.info("Generating the plot") + plot1 = aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic) plot1.IsoVal = "Tone" assert plot1.update_field_plot_settings() - self.aedtapp.logger.info("Generating the image") - plot_obj = self.aedtapp.post.plot_field_from_fieldplot( + aedtapp.logger.info("Generating the image") + plot_obj = aedtapp.post.plot_field_from_fieldplot( plot_name=plot1.name, - project_path=self.local_scratch.path, + project_path=local_scratch.path, mesh_plot=False, image_format="jpg", view="xy", @@ -599,16 +582,16 @@ def test_14_Field_Ploton_cutplanedesignname(self): assert plot_obj.y_scale == 0.9 assert plot_obj.z_scale == 0.3 - plot_obj.background_image = os.path.join(self.local_scratch.path, "file_not_exists.jpg") + plot_obj.background_image = os.path.join(local_scratch.path, "file_not_exists.jpg") assert not plot_obj.background_image plot_obj.convert_fields_in_db = True plot_obj.log_multiplier = 20 plot_obj.plot(plot_obj.image_file, show=False) assert os.path.exists(plot_obj.image_file) - plot_obj = self.aedtapp.post.plot_field_from_fieldplot( + plot_obj = aedtapp.post.plot_field_from_fieldplot( plot_name=plot1.name, - project_path=self.local_scratch.path, + project_path=local_scratch.path, mesh_plot=False, image_format="jpg", view="xy", @@ -620,19 +603,19 @@ def test_14_Field_Ploton_cutplanedesignname(self): plot_obj.plot(plot_obj.image_file, show=False) @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in IronPython.") - def test_14B_Field_Ploton_Vector(self): + def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): cutlist = ["Global:XY"] - setup_name = self.aedtapp.existing_analysis_sweeps[0] + setup_name = aedtapp.existing_analysis_sweeps[0] quantity_name = "Vector_E" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} - self.aedtapp.logger.info("Generating the plot") - plot1 = self.aedtapp.post.create_fieldplot_cutplane( - cutlist, quantity_name, setup_name, intrinsic, filter_objects=self.aedtapp.modeler.object_names + aedtapp.logger.info("Generating the plot") + plot1 = aedtapp.post.create_fieldplot_cutplane( + cutlist, quantity_name, setup_name, intrinsic, filter_objects=aedtapp.modeler.object_names ) plot1.IsoVal = "Tone" assert plot1.update_field_plot_settings() - self.aedtapp.logger.info("Generating the image") - plot_obj = self.aedtapp.post.plot_field( + aedtapp.logger.info("Generating the image") + plot_obj = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -641,13 +624,13 @@ def test_14B_Field_Ploton_Vector(self): mesh_on_fields=False, view="isometric", show=False, - export_path=self.local_scratch.path, + export_path=local_scratch.path, image_format="jpg", ) assert os.path.exists(plot_obj.image_file) assert plot_obj.range_min is None assert plot_obj.range_max is None - plot_obj_1 = self.aedtapp.post.plot_field( + plot_obj_1 = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -656,14 +639,14 @@ def test_14B_Field_Ploton_Vector(self): mesh_on_fields=False, view="isometric", show=False, - export_path=self.local_scratch.path, + export_path=local_scratch.path, image_format="jpg", log_scale=False, ) assert os.path.exists(plot_obj_1.image_file) assert plot_obj_1.range_min is None assert plot_obj_1.range_max is None - plot_obj_2 = self.aedtapp.post.plot_field( + plot_obj_2 = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -672,7 +655,7 @@ def test_14B_Field_Ploton_Vector(self): mesh_on_fields=False, view="isometric", show=False, - export_path=self.local_scratch.path, + export_path=local_scratch.path, image_format="jpg", log_scale=False, scale_min=0, @@ -681,7 +664,7 @@ def test_14B_Field_Ploton_Vector(self): assert os.path.exists(plot_obj_2.image_file) assert plot_obj_2.range_min == 0 assert plot_obj_2.range_max == 10e6 - plot_obj_3 = self.aedtapp.post.plot_field( + plot_obj_3 = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -690,7 +673,7 @@ def test_14B_Field_Ploton_Vector(self): mesh_on_fields=False, view="isometric", show=False, - export_path=self.local_scratch.path, + export_path=local_scratch.path, image_format="jpg", log_scale=True, scale_min=0, @@ -699,7 +682,7 @@ def test_14B_Field_Ploton_Vector(self): assert os.path.exists(plot_obj_3.image_file) assert plot_obj_3.range_min is None assert plot_obj_3.range_max is None - plot_obj_4 = self.aedtapp.post.plot_field( + plot_obj_4 = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -708,7 +691,7 @@ def test_14B_Field_Ploton_Vector(self): mesh_on_fields=False, view="isometric", show=False, - export_path=self.local_scratch.path, + export_path=local_scratch.path, image_format="jpg", log_scale=True, scale_min=10e6, @@ -717,7 +700,7 @@ def test_14B_Field_Ploton_Vector(self): assert os.path.exists(plot_obj_4.image_file) assert plot_obj_4.range_min is None assert plot_obj_4.range_max is None - plot_obj_5 = self.aedtapp.post.plot_field( + plot_obj_5 = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -726,7 +709,7 @@ def test_14B_Field_Ploton_Vector(self): mesh_on_fields=False, view="isometric", show=False, - export_path=self.local_scratch.path, + export_path=local_scratch.path, image_format="jpg", log_scale=False, scale_min=0, @@ -736,46 +719,44 @@ def test_14B_Field_Ploton_Vector(self): assert plot_obj_5.range_max is None @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") - def test_15_export_plot(self): - obj = self.aedtapp.post.plot_model_obj( - show=False, export_path=os.path.join(self.local_scratch.path, "image.jpg") - ) + def test_15_export_plot(self, aedtapp, local_scratch): + obj = aedtapp.post.plot_model_obj(show=False, export_path=os.path.join(local_scratch.path, "image.jpg")) assert os.path.exists(obj.image_file) - obj2 = self.aedtapp.post.plot_model_obj( - show=False, export_path=os.path.join(self.local_scratch.path, "image2.jpg"), plot_as_separate_objects=False + obj2 = aedtapp.post.plot_model_obj( + show=False, export_path=os.path.join(local_scratch.path, "image2.jpg"), plot_as_separate_objects=False ) assert os.path.exists(obj2.image_file) @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") - def test_16_create_field_plot(self): + def test_16_create_field_plot(self, aedtapp): cutlist = ["Global:XY"] - plot = self.aedtapp.post._create_fieldplot( + plot = aedtapp.post._create_fieldplot( assignment=cutlist, quantity="Mag_E", - setup=self.aedtapp.nominal_adaptive, + setup=aedtapp.nominal_adaptive, intrinsics={}, list_type="CutPlane", ) assert plot - def test_53_line_plot(self): + def test_53_line_plot(self, aedtapp): udp1 = [0, 0, 0] udp2 = [1, 0, 0] setup_name = "Setup1 : LastAdaptive" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} - self.aedtapp.modeler.create_polyline([udp1, udp2], name="Poly1", non_model=True) - field_line_plot = self.aedtapp.post.create_fieldplot_line("Poly1", "Mag_E", setup_name, intrinsic) + aedtapp.modeler.create_polyline([udp1, udp2], name="Poly1", non_model=True) + field_line_plot = aedtapp.post.create_fieldplot_line("Poly1", "Mag_E", setup_name, intrinsic) assert field_line_plot - self.aedtapp.post.create_fieldplot_line("Poly1", "Mag_E", setup_name, intrinsic, field_line_plot.name) + aedtapp.post.create_fieldplot_line("Poly1", "Mag_E", setup_name, intrinsic, field_line_plot.name) - def test_55_reload(self, add_app): - self.aedtapp.save_project() - app2 = add_app(project_name=self.aedtapp.project_name, just_open=True) - assert len(app2.post.field_plots) == len(self.aedtapp.post.field_plots) + def test_55_reload(self, aedtapp, add_app): + aedtapp.save_project() + app2 = add_app(project_name=aedtapp.project_name, just_open=True) + assert len(app2.post.field_plots) == len(aedtapp.post.field_plots) - def test_58_test_no_report(self): - assert not self.aedtapp.post.reports_by_category.eye_diagram() - assert self.aedtapp.post.reports_by_category.eigenmode() + def test_58_test_no_report(self, aedtapp): + assert not aedtapp.post.reports_by_category.eye_diagram() + assert aedtapp.post.reports_by_category.eigenmode() def test_59_test_parse_vector(self): out = _parse_aedtplt(os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "test_vector.aedtplt")) @@ -793,34 +774,34 @@ def test_60_test_parse_vector(self): ) assert isinstance(out, list) - def test_61_export_mesh(self): - assert os.path.exists(self.aedtapp.export_mesh_stats("Setup1")) + def test_61_export_mesh(self, aedtapp): + assert os.path.exists(aedtapp.export_mesh_stats("Setup1")) - def test_67_sweep_from_json(self): + def test_67_sweep_from_json(self, aedtapp): dict_vals = read_json( os.path.join(TESTS_GENERAL_PATH, "example_models", "report_json", "Modal_Report_Simple.json") ) - assert self.aedtapp.post.create_report_from_configuration(report_settings=dict_vals) - assert self.aedtapp.post.create_report_from_configuration(report_settings=dict_vals, matplotlib=True) + assert aedtapp.post.create_report_from_configuration(report_settings=dict_vals) + assert aedtapp.post.create_report_from_configuration(report_settings=dict_vals, matplotlib=True) @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non graphical in version lower than 2022.2" ) - def test_70_sweep_from_json(self): - assert self.aedtapp.post.create_report_from_configuration( + def test_70_sweep_from_json(self, aedtapp): + assert aedtapp.post.create_report_from_configuration( os.path.join(TESTS_GENERAL_PATH, "example_models", "report_json", "Modal_Report.json") ) - assert self.aedtapp.post.create_report_from_configuration( + assert aedtapp.post.create_report_from_configuration( os.path.join(TESTS_GENERAL_PATH, "example_models", "report_json", "Modal_Report.json"), matplotlib=True ) - def test_74_dynamic_update(self): - val = self.aedtapp.post.update_report_dynamically - self.aedtapp.post.update_report_dynamically = not val - assert self.aedtapp.post.update_report_dynamically != val + def test_74_dynamic_update(self, aedtapp): + val = aedtapp.post.update_report_dynamically + aedtapp.post.update_report_dynamically = not val + assert aedtapp.post.update_report_dynamically != val - def test_75_tune_derivative(self): - setup_derivative = self.aedtapp.setups[1] - setup_derivative_auto = self.aedtapp.setups[2] + def test_75_tune_derivative(self, aedtapp): + setup_derivative = aedtapp.setups[1] + setup_derivative_auto = aedtapp.setups[2] assert setup_derivative.set_tuning_offset({"inner_radius": 0.1}) assert setup_derivative_auto.set_tuning_offset({"inner_radius": 0.1}) From 7ec8c7f24e49db6f111f78380fa5b43398c421c8 Mon Sep 17 00:00:00 2001 From: mcapodif Date: Fri, 17 Jan 2025 09:30:46 +0100 Subject: [PATCH 2/3] fix referencing wheelhouse --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 2e45dbd248a..8183d00c950 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ dependencies = [ "pyyaml", "defusedxml>=0.7,<8.0", "attrs!=24.3.0", + "referencing!=0.36.1", ] [project.optional-dependencies] From 37b53cb40042f4a6f0777548d8cb5ce95ea44ef2 Mon Sep 17 00:00:00 2001 From: mcapodif Date: Fri, 17 Jan 2025 09:39:45 +0100 Subject: [PATCH 3/3] fix referencing wheelhouse --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8183d00c950..dcc8fd7b6c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ dependencies = [ "pyyaml", "defusedxml>=0.7,<8.0", "attrs!=24.3.0", - "referencing!=0.36.1", + "referencing<0.36.0", ] [project.optional-dependencies]