diff --git a/doc/changelog.d/6183.miscellaneous.md b/doc/changelog.d/6183.miscellaneous.md new file mode 100644 index 00000000000..837f689f9ce --- /dev/null +++ b/doc/changelog.d/6183.miscellaneous.md @@ -0,0 +1 @@ +test_12_1_post_processing \ No newline at end of file diff --git a/tests/system/visualization/test_12_1_PostProcessing.py b/tests/system/visualization/test_12_1_PostProcessing.py index 67688553952..5665e677a5f 100644 --- a/tests/system/visualization/test_12_1_PostProcessing.py +++ b/tests/system/visualization/test_12_1_PostProcessing.py @@ -23,7 +23,8 @@ # SOFTWARE. import os -import sys + +# import sys import uuid import pytest @@ -31,18 +32,17 @@ import ansys.aedt.core from ansys.aedt.core import Quantity from ansys.aedt.core.generic.file_utils import read_json -from ansys.aedt.core.generic.general_methods import is_linux + +# from ansys.aedt.core.generic.general_methods import is_linux from ansys.aedt.core.internal.errors import AEDTRuntimeError from ansys.aedt.core.visualization.plot.pyvista import ModelPlotter from ansys.aedt.core.visualization.plot.pyvista import _parse_aedtplt -from ansys.aedt.core.visualization.plot.pyvista import _parse_streamline from tests import TESTS_VISUALIZATION_PATH from tests.system.visualization.conftest import config test_project_name = "coax_setup_solved_231" m2d_trace_export_table = "m2d" - test_circuit_name = "Switching_Speed_FET_And_Diode" test_subfolder = "T12" @@ -62,7 +62,6 @@ def m2d_app(add_app): class TestClass: - @pytest.mark.skipif(config["NonGraphical"], reason="Failing on build machine when running in parallel.") 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 @@ -76,13 +75,7 @@ def test_01_export_model_picture(self, aedtapp, local_scratch): path = aedtapp.post.export_model_picture(full_name=os.path.join(local_scratch.path, "images4.jpg")) assert path - 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 + def test_create_fieldplot_cutplane(self, aedtapp): cutlist = ["Global:XY", "Global:XZ", "Global:YZ"] setup_name = aedtapp.existing_analysis_sweeps[0] assert aedtapp.setups[0].is_solved @@ -96,32 +89,116 @@ def test_01B_Field_Plot(self, aedtapp, local_scratch): plot1.update_field_plot_settings() plot1.update() assert aedtapp.post.field_plots[plot1.name].IsoVal == "Tone" + + def test_create_fieldplot_cutplane_1(self, aedtapp): + cutlist = ["Global:XY", "Global:XZ", "Global:YZ"] + setup_name = aedtapp.existing_analysis_sweeps[0] + quantity_name = "ComplexMag_E" + frequency = Quantity("5GHz") + phase = Quantity("180deg") + intrinsic = {"Freq": frequency, "Phase": phase} + assert aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic, "Plot_1") + + def test_change_plot_scale(self, aedtapp): + cutlist = ["Global:XY", "Global:XZ", "Global:YZ"] + setup_name = aedtapp.existing_analysis_sweeps[0] + quantity_name = "ComplexMag_E" + frequency = Quantity("5GHz") + phase = Quantity("180deg") + intrinsic = {"Freq": frequency, "Phase": phase} + 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 plot1.change_plot_scale(min_value, "30000", scale_levels=50) - assert aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic, plot1.name) + + def test_create_fieldplot_volume_invalid(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} assert not aedtapp.post.create_fieldplot_volume("invalid", "Vector_E", setup_name, intrinsic) + + def test_create_fieldplot_volume(self, aedtapp): + cutlist = ["Global:XY", "Global:XZ", "Global:YZ"] + quantity_name = "ComplexMag_E" + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} field_plot = aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic) assert field_plot - assert aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic, field_plot.name) - volume_plot = aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Vector_E", setup_name, intrinsic) + def test_create_fieldplot_volume_1(self, aedtapp): + quantity_name = "ComplexMag_E" + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} + assert aedtapp.post.create_fieldplot_volume("inner", quantity_name, setup_name, intrinsic, "Plot_1") + def test_export_field_plot(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} + volume_plot = aedtapp.post.create_fieldplot_volume("NewObject_IJD39Q", "Vector_E", setup_name, intrinsic) 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" + + def test_create_fieldplot_surface(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} field_plot = aedtapp.post.create_fieldplot_surface( aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic ) assert field_plot + + def test_create_fieldplot_surface_1(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} assert aedtapp.post.create_fieldplot_surface( - aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic, field_plot.name + aedtapp.modeler["outer"].faces[0].id, "Mag_E", setup_name, intrinsic, "Plot_1" ) + + def test_create_fieldplot_surface_2(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} assert aedtapp.post.create_fieldplot_surface(aedtapp.modeler["outer"], "Mag_E", setup_name, intrinsic) + + def test_create_fieldplot_surface_3(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} assert aedtapp.post.create_fieldplot_surface(aedtapp.modeler["outer"].faces, "Mag_E", setup_name, intrinsic) + + def test_create_fieldplot_surface_4(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} assert not aedtapp.post.create_fieldplot_surface(123123123, "Mag_E", setup_name, intrinsic) + + def test_design_setups(self, aedtapp): assert len(aedtapp.design_setups["Setup1"].sweeps[0].frequencies) > 0 assert isinstance(aedtapp.design_setups["Setup1"].sweeps[0].basis_frequencies, list) + + def test_export_mesh_obj(self, aedtapp): + frequency = Quantity("5GHz") + phase = Quantity("180deg") + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": frequency, "Phase": phase} mesh_file_path = aedtapp.post.export_mesh_obj(setup_name, intrinsic) assert os.path.exists(mesh_file_path) mesh_file_path2 = aedtapp.post.export_mesh_obj( @@ -129,11 +206,14 @@ def test_01B_Field_Plot(self, aedtapp, local_scratch): ) assert os.path.exists(mesh_file_path2) + def test_get_scalar_field_value(self, aedtapp): + setup_name = aedtapp.existing_analysis_sweeps[0] 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, aedtapp, local_scratch): + # TODO + # @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") + def test_plot_animated_field(self, aedtapp, local_scratch): cutlist = ["Global:XY"] phases = [str(i * 5) + "deg" for i in range(2)] model_gif = aedtapp.post.plot_animated_field( @@ -149,8 +229,13 @@ def test_01_Animate_plt(self, aedtapp, local_scratch): export_path=local_scratch.path, ) assert os.path.exists(model_gif.gif_file) + + # TODO + # @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") + def test_animate_fields_from_aedtplt(self, aedtapp): setup_name = aedtapp.existing_analysis_sweeps[0] intrinsic = {"Freq": "5GHz", "Phase": "180deg"} + phases = [str(i * 5) + "deg" for i in range(2)] 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, @@ -167,26 +252,33 @@ def test_01_Animate_plt(self, aedtapp, local_scratch): 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, aedtapp, local_scratch): + def test_create_fieldplot_volume_1(self, aedtapp, local_scratch): quantity_name2 = "ComplexMag_H" setup_name = "Setup1 : LastAdaptive" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} vollist = ["NewObject_IJD39Q"] plot2 = aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic) + assert os.path.exists(plot2.export_image(os.path.join(local_scratch.path, "test_x.jpg"))) + # TODO: + @pytest.mark.skipif(config["NonGraphical"], reason="Not running in non-graphical mode") + def test_export_field_jpg(self, aedtapp, local_scratch): + quantity_name2 = "ComplexMag_H" + setup_name = "Setup1 : LastAdaptive" + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} + vollist = ["NewObject_IJD39Q"] + plot2 = aedtapp.post.create_fieldplot_volume(vollist, quantity_name2, setup_name, intrinsic) 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, aedtapp): + def test_create_scattering(self, aedtapp): portnames = ["1", "2"] assert aedtapp.create_scattering("MyTestScattering") setup_name = "Setup2 : Sweep" with pytest.raises(KeyError): aedtapp.create_scattering("MyTestScattering2", setup_name, portnames, portnames) - def test_03_get_solution_data(self, aedtapp, local_scratch): + def test_get_solution_data(self, aedtapp): trace_names = [] portnames = ["1", "2"] for el in portnames: @@ -204,42 +296,54 @@ def test_03_get_solution_data(self, aedtapp, local_scratch): 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 + + def test_export_data_to_csv(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"]} + nominal_values = aedtapp.available_variations.get_independent_nominal_values() + for key, value in nominal_values.items(): + families[key] = value + my_data = aedtapp.post.get_solution_data(expressions=trace_names, variations=families) 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") - my_data.enable_pandas_output = False - 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(local_scratch.path, "output2.csv")) - assert os.path.exists(os.path.join(local_scratch.path, "output2.csv")) + def test_get_touchstone_data(self, aedtapp): assert aedtapp.get_touchstone_data("Setup1") - def test_04_export_touchstone(self, aedtapp, local_scratch): + def test_export_touchstone(self, aedtapp, local_scratch): setup_name = "Setup1" sweep_name = "Sweep" 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")) + def test_export_touchstone_1(self, aedtapp, local_scratch): + setup_name = "Setup1" sweep_name = None 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")) + + def test_export_touchstone_2(self, aedtapp, local_scratch): setup_name = None + sweep_name = None 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")) + def test_export_touchstone_2(self, aedtapp): + setup_name = None + sweep_name = None 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, aedtapp, local_scratch): + # TODO + # @pytest.mark.skipif(config["desktopVersion"] != "2023.1", reason="Not running in non-graphical mode") + def test_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, aedtapp, local_scratch): + def test_export_report_to_csv(self, aedtapp, local_scratch): aedtapp.post.export_report_to_csv( local_scratch.path, "MyTestScattering", @@ -251,11 +355,11 @@ def test_06_export_report_to_csv(self, aedtapp, local_scratch): ) assert os.path.exists(os.path.join(local_scratch.path, "MyTestScattering.csv")) - def test_06_export_report_to_rdat(self, aedtapp, local_scratch): + def test_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, aedtapp, local_scratch): + def test_export_field_file_on_grid(self, aedtapp, local_scratch): file_path = aedtapp.post.export_field_file_on_grid( "E", "Setup1 : LastAdaptive", @@ -266,23 +370,9 @@ def test_07_export_fields_from_Calculator(self, aedtapp, local_scratch): is_vector=True, intrinsics="5GHz", ) - - assert os.path.exists(file_path) - model_pv = ModelPlotter() - model_pv.add_field_from_file(file_path) - assert model_pv.plot(show=False) - model_pv.clean_cache_and_files(clean_cache=True) - file_path = aedtapp.post.export_field_file_on_grid( - "E", - "Setup1 : LastAdaptive", - aedtapp.available_variations.nominal_values, - grid_stop=[5, 5, 5], - grid_step=[0.5, 0.5, 0.5], - is_vector=True, - intrinsics="5GHz", - ) assert os.path.exists(file_path) + def test_export_field_file_on_grid_1(self, aedtapp, local_scratch): aedtapp.post.export_field_file_on_grid( "E", "Setup1 : LastAdaptive", @@ -295,6 +385,7 @@ def test_07_export_fields_from_Calculator(self, aedtapp, local_scratch): ) assert os.path.exists(os.path.join(local_scratch.path, "Efield.fld")) + def test_export_field_file_on_grid_spherical(self, aedtapp, local_scratch): aedtapp.post.export_field_file_on_grid( "Mag_E", "Setup1 : LastAdaptive", @@ -308,6 +399,7 @@ def test_07_export_fields_from_Calculator(self, aedtapp, local_scratch): ) assert os.path.exists(os.path.join(local_scratch.path, "MagEfieldSph.fld")) + def test_export_field_file_on_grid_cylindrical(self, aedtapp, local_scratch): aedtapp.post.export_field_file_on_grid( "Mag_E", "Setup1 : LastAdaptive", @@ -321,26 +413,64 @@ def test_07_export_fields_from_Calculator(self, aedtapp, local_scratch): ) assert os.path.exists(os.path.join(local_scratch.path, "MagEfieldCyl.fld")) - def test_07_copydata(self, aedtapp, local_scratch): + def test_ModelPlotter_plot(self, aedtapp, local_scratch): + file_path = aedtapp.post.export_field_file_on_grid( + "E", + "Setup1 : LastAdaptive", + aedtapp.available_variations.nominal_values, + local_scratch.path, + grid_stop=[5, 5, 5], + grid_step=[0.5, 0.5, 0.5], + is_vector=True, + intrinsics="5GHz", + ) + model_pv = ModelPlotter() + model_pv.add_field_from_file(file_path) + assert model_pv.plot(show=False) + + def test_ModelPlotter_clean_cache_and_files(self, aedtapp, local_scratch): + file_path = aedtapp.post.export_field_file_on_grid( + "E", + "Setup1 : LastAdaptive", + aedtapp.available_variations.nominal_values, + local_scratch.path, + grid_stop=[5, 5, 5], + grid_step=[0.5, 0.5, 0.5], + is_vector=True, + intrinsics="5GHz", + ) + model_pv = ModelPlotter() + model_pv.add_field_from_file(file_path) + model_pv.plot(show=False) + assert model_pv.clean_cache_and_files(clean_cache=True) == True + + def test_copydata(self, aedtapp, local_scratch): assert aedtapp.post.copy_report_data("MyTestScattering") - def test_08_manipulate_report(self, aedtapp, local_scratch): + def test_rename_report(self, aedtapp): assert aedtapp.post.rename_report("MyTestScattering", "MyNewScattering") + + def test_rename_report_1(self, aedtapp): 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, aedtapp, local_scratch): + def test_create_report(self, aedtapp, local_scratch): plot = aedtapp.post.create_report("dB(S(1,1))") assert plot - assert plot.export_config(os.path.join(local_scratch.path, f"{plot.plot_name}.json")) + + def test_create_report_from_configuration(self, aedtapp, local_scratch): assert aedtapp.post.create_report_from_configuration( - os.path.join(local_scratch.path, f"{plot.plot_name}.json"), solution_name=aedtapp.nominal_sweep + os.path.join(local_scratch.path, "plot_test.json"), solution_name=aedtapp.nominal_sweep ) + + def test_create_report_from_configuration(self, aedtapp, local_scratch): assert aedtapp.post.create_report_from_configuration( - os.path.join(local_scratch.path, f"{plot.plot_name}.json"), + os.path.join(local_scratch.path, "plot_test.json"), solution_name=aedtapp.nominal_sweep, matplotlib=True, ) + + def test_create_report_from_configuration(self, aedtapp): assert aedtapp.post.create_report( expressions="MaxMagDeltaS", variations={"Pass": ["All"]}, @@ -348,18 +478,18 @@ def test_09_manipulate_report(self, aedtapp, local_scratch): report_category="Modal Solution Data", plot_type="Rectangular Plot", ) - new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") - assert new_report.create() + def test_get_solution_data(self, aedtapp): data = aedtapp.post.get_solution_data("S(1,1)") assert data.primary_sweep == "Freq" assert data.expressions[0] == "S(1,1)" assert len(aedtapp.post.all_report_names) > 0 + def test_eports_by_category_modal_solution(self, aedtapp): 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, aedtapp, local_scratch): + def test_import_traces(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") @@ -395,7 +525,7 @@ def test_09c_import_into_report(self, aedtapp, local_scratch): with pytest.raises(ValueError): new_report.import_traces(csv_file_path, None) - def test_09d_delete_traces_from_report(self, aedtapp, local_scratch): + def test_delete_traces(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 @@ -405,7 +535,7 @@ def test_09d_delete_traces_from_report(self, aedtapp, local_scratch): with pytest.raises(ValueError): new_report.delete_traces(plot_name, ["V(out)_Test"]) - def test_09e_add_traces_to_report(self, aedtapp): + def test_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) @@ -417,7 +547,7 @@ def test_09e_add_traces_to_report(self, aedtapp): setup = "Transient" assert not new_report.add_trace_to_report(traces, setup, variations) - def test_09f_update_trace_name(self, aedtapp): + def test_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 @@ -425,7 +555,7 @@ def test_09f_update_trace_name(self, aedtapp): report.traces[0].name = new_name assert new_name in report.traces[0].aedt_name - def test_09g_update_traces_in_report(self, aedtapp): + def test_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) @@ -435,38 +565,41 @@ def test_09g_update_traces_in_report(self, aedtapp): 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, aedtapp): # pragma: no cover - assert aedtapp.post.create_report("dB(S(1,1))") + # TODO: passed locally + # @pytest.mark.skipif( + # config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." + # ) + def test_create_monitor(self, aedtapp): # pragma: no cover + 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() - + new_report.create() assert new_report.add_cartesian_x_marker("3GHz") assert new_report.add_cartesian_y_marker("-55") - @pytest.mark.skipif( - 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, aedtapp): # pragma: no cover + # TODO: passed locally + # @pytest.mark.skipif( + # config["desktopVersion"] < "2022.2", + # reason="Skipped because it cannot run on build machine in non-graphical mode", + # ) + def test_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() + 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, aedtapp): + # TODO: passed locally + # @pytest.mark.skipif( + # config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." + # ) + def test_add_line_from_equation(self, aedtapp): new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") - assert new_report.create() + 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, aedtapp): + # TODO + # @pytest.mark.skipif( + # config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." + # ) + def test_edit_grid(self, aedtapp): report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_grid() assert report.edit_grid(minor_x=False) @@ -474,19 +607,33 @@ def test_09m_edit_properties(self, aedtapp): assert report.edit_grid(major_color=(0, 0, 125)) assert report.edit_grid(major_color=(0, 255, 0)) assert report.edit_grid(style_major="Dot") + + def test_edit_x_axis(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_x_axis( font="Bangers", font_size=14, italic=True, bold=False, color=(0, 128, 0), display_units=False ) + + def test_edit_y_axis(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_y_axis( font="Bangers", font_size=14, italic=True, bold=False, color=(0, 128, 0), display_units=False ) + + def test_edit_x_axis(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_x_axis( font="Courier", font_size=14, italic=True, bold=False, color=(0, 128, 0), label="Freq" ) + + def test_edit_y_axis(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_y_axis( font="Courier", font_size=14, italic=True, bold=False, color=(0, 128, 0), label="Touchstone" ) + def test_edit_x_axis_scaling(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_x_axis_scaling( linear_scaling=True, min_scale="1GHz", @@ -495,12 +642,21 @@ def test_09m_edit_properties(self, aedtapp): min_spacing="0.5GHz", units="MHz", ) + + def test_edit_y_axis_scaling(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_y_axis_scaling( linear_scaling=False, min_scale="-50", max_scale="10", minor_tick_divs=10, min_spacing="5" ) + + def test_edit_legend(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_legend( show_solution_name=True, show_variation_key=False, show_trace_name=False, back_color=(255, 255, 255) ) + + def test_edit_header(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_header( company_name="PyAEDT", show_design_name=True, @@ -511,6 +667,9 @@ def test_09m_edit_properties(self, aedtapp): bold=False, color=(0, 125, 125), ) + + def test_edit_general_settings(self, aedtapp): + report = aedtapp.post.create_report("dB(S(1,1))") assert report.edit_general_settings( background_color=(128, 255, 255), plot_color=(255, 0, 255), @@ -520,34 +679,42 @@ def test_09m_edit_properties(self, aedtapp): use_scientific_notation=True, ) - @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, aedtapp): # pragma: no cover + # TODO: passed locally + # @pytest.mark.skipif( + # config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." + # ) + def test_set_trace_properties(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 - symbols = new_report.traces[0].SYMBOLSTYLE - assert new_report.traces[0].set_trace_properties( style=style.Dot, width=5, trace_type=trace.Digital, color=(0, 255, 0) ) + + def test_set_symbol_properties(self, aedtapp): # pragma: no cover + new_report = aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + new_report.create() + symbols = new_report.traces[0].SYMBOLSTYLE assert new_report.traces[0].set_symbol_properties( show=True, style=symbols.Box, show_arrows=False, fill=False, color=(0, 0, 255) ) + + def test_set_line_properties(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 new_report.add_limit_line_from_points([3, 5, 5, 3], [-50, -50, -60, -60], "GHz") assert new_report.limit_lines[0].set_line_properties( style=style.Dot, width=4, hatch_above=False, violation_emphasis=True, hatch_pixels=1, color=(255, 255, 0) ) - @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, aedtapp): # 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_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) assert new_report.notes[0].set_note_properties( back_color=(0, 0, 255), @@ -560,18 +727,19 @@ def test_09o_add_note(self, aedtapp): # pragma: no cover color=(255, 0, 0), ) - def test_10_delete_report(self, aedtapp): + def test_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, aedtapp): + def test_steal_focus_oneditor(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, aedtapp, local_scratch): + # TODO: check after tests + # @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in ironpython") + def test_create_fieldplot_cutplane(self, aedtapp): cutlist = ["Global:XY"] setup_name = aedtapp.existing_analysis_sweeps[0] quantity_name = "ComplexMag_E" @@ -580,6 +748,14 @@ def test_14_Field_Ploton_cutplanedesignname(self, aedtapp, local_scratch): plot1 = aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic) plot1.IsoVal = "Tone" assert plot1.update_field_plot_settings() + + def test_plot_field_from_fieldplot(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + quantity_name = "ComplexMag_E" + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} + plot1 = aedtapp.post.create_fieldplot_cutplane(cutlist, quantity_name, setup_name, intrinsic) + plot1.IsoVal = "Tone" aedtapp.logger.info("Generating the image") plot_obj = aedtapp.post.plot_field_from_fieldplot( plot_name=plot1.name, @@ -591,6 +767,17 @@ def test_14_Field_Ploton_cutplanedesignname(self, aedtapp, local_scratch): show=False, ) assert os.path.exists(plot_obj.image_file) + + def test_plot_field_from_fieldplot_scale(self, aedtapp, local_scratch): + plot_obj = aedtapp.post.plot_field_from_fieldplot( + plot_name="plot_test", + project_path=local_scratch.path, + mesh_plot=False, + image_format="jpg", + view="xy", + plot_label="plot_test" + " label", + show=False, + ) os.unlink(plot_obj.image_file) plot_obj.x_scale = 1.1 plot_obj.y_scale = 0.9 @@ -599,39 +786,67 @@ def test_14_Field_Ploton_cutplanedesignname(self, aedtapp, local_scratch): assert plot_obj.y_scale == 0.9 assert plot_obj.z_scale == 0.3 + def test_plot_field_from_fieldplot_background(self, aedtapp, local_scratch): + plot_obj = aedtapp.post.plot_field_from_fieldplot( + plot_name="plot_test", + project_path=local_scratch.path, + mesh_plot=False, + image_format="jpg", + view="xy", + plot_label="plot_test" + " label", + show=False, + ) plot_obj.background_image = os.path.join(local_scratch.path, "file_not_exists.jpg") assert not plot_obj.background_image + + def test_plot_field_from_fieldplot(self, aedtapp, local_scratch): + plot_obj = aedtapp.post.plot_field_from_fieldplot( + plot_name="plot_test", + project_path=local_scratch.path, + mesh_plot=False, + image_format="jpg", + view="xy", + plot_label="plot_test" + " label", + show=False, + ) 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) + def test_plot_field_from_fieldplot_aedtplt(self, aedtapp, local_scratch): plot_obj = aedtapp.post.plot_field_from_fieldplot( - plot_name=plot1.name, + plot_name="plot_test", project_path=local_scratch.path, mesh_plot=False, image_format="jpg", view="xy", - plot_label=plot1.name + " label", + plot_label="plot_test" + " label", show=False, file_format="aedtplt", ) assert os.path.exists(plot_obj.image_file) - 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, aedtapp, local_scratch): + # TODO + # @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="Not running in IronPython.") + def test_create_fieldplot_cutplane_vector(self, aedtapp, local_scratch): cutlist = ["Global:XY"] setup_name = aedtapp.existing_analysis_sweeps[0] quantity_name = "Vector_E" intrinsic = {"Freq": "5GHz", "Phase": "180deg"} aedtapp.logger.info("Generating the plot") - plot1 = aedtapp.post.create_fieldplot_cutplane( + assert aedtapp.post.create_fieldplot_cutplane( + cutlist, quantity_name, setup_name, intrinsic, filter_objects=aedtapp.modeler.object_names + ) + + def test_plot_field_range_min_max(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + quantity_name = "Vector_E" + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} + assert 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() - aedtapp.logger.info("Generating the image") plot_obj = aedtapp.post.plot_field( "Vector_E", cutlist, @@ -647,6 +862,11 @@ def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): assert os.path.exists(plot_obj.image_file) assert plot_obj.range_min is None assert plot_obj.range_max is None + + def test_plot_field_range_min_max_1(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} plot_obj_1 = aedtapp.post.plot_field( "Vector_E", cutlist, @@ -663,6 +883,11 @@ def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): 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 + + def test_plot_field_range_min_max_2(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} plot_obj_2 = aedtapp.post.plot_field( "Vector_E", cutlist, @@ -681,7 +906,14 @@ def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): 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 = aedtapp.post.plot_field( + assert plot_obj_2.range_max == 10e6 + + def test_plot_field_range_min_max_3(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} + + plot_obj_1 = aedtapp.post.plot_field( "Vector_E", cutlist, "CutPlane", @@ -692,13 +924,17 @@ def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): show=False, export_path=local_scratch.path, image_format="jpg", - log_scale=True, - scale_min=0, - scale_max=10e6, + log_scale=False, ) - 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 + 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 + + def test_plot_field_range_min_max_4(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} + plot_obj_4 = aedtapp.post.plot_field( "Vector_E", cutlist, @@ -717,6 +953,11 @@ def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): 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 + + def test_plot_field_range_min_max_5(self, aedtapp, local_scratch): + cutlist = ["Global:XY"] + setup_name = aedtapp.existing_analysis_sweeps[0] + intrinsic = {"Freq": "5GHz", "Phase": "180deg"} plot_obj_5 = aedtapp.post.plot_field( "Vector_E", cutlist, @@ -735,21 +976,23 @@ def test_14B_Field_Ploton_Vector(self, aedtapp, local_scratch): assert plot_obj_5.range_min is None 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, aedtapp, local_scratch): + def test_plot_model_obj(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) + + def test_plot_model_obj_1(self, aedtapp, local_scratch): 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) + + def test_plot_model_obj_2(self, aedtapp, local_scratch): obj3 = aedtapp.post.plot_model_obj( show=False, export_path=os.path.join(local_scratch.path, "image2.jpg"), clean_files=True ) assert os.path.exists(obj3.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, aedtapp): + def test_create_field_plot(self, aedtapp): cutlist = ["Global:XY"] plot = aedtapp.post._create_fieldplot( assignment=cutlist, @@ -760,7 +1003,7 @@ def test_16_create_field_plot(self, aedtapp): ) assert plot - def test_53_line_plot(self, aedtapp): + def test_create_fieldplot_line(self, aedtapp): udp1 = [0, 0, 0] udp2 = [1, 0, 0] setup_name = "Setup1 : LastAdaptive" @@ -770,16 +1013,18 @@ def test_53_line_plot(self, aedtapp): assert field_line_plot aedtapp.post.create_fieldplot_line("Poly1", "Mag_E", setup_name, intrinsic, field_line_plot.name) - def test_55_reload(self, aedtapp, add_app): + def test_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, aedtapp): + def test_reports_by_category_eye_diagram_no_report(self, aedtapp): assert not aedtapp.post.reports_by_category.eye_diagram() + + def test_reports_by_category_eigenmode(self, aedtapp): assert aedtapp.post.reports_by_category.eigenmode() - def test_59_test_parse_vector(self): + def test_test_parse_vector(self): out = _parse_aedtplt( os.path.join(TESTS_VISUALIZATION_PATH, "example_models", test_subfolder, "test_vector.aedtplt") ) @@ -791,26 +1036,20 @@ def test_59_test_parse_vector(self): os.path.join(TESTS_VISUALIZATION_PATH, "example_models", test_subfolder, "test_vector_no_solutions.aedtplt") ) - def test_60_test_parse_vector(self): - out = _parse_streamline( - os.path.join(TESTS_VISUALIZATION_PATH, "example_models", test_subfolder, "test_streamline.fldplt") - ) - assert isinstance(out, list) - - def test_61_export_mesh(self, aedtapp): + def test_export_mesh(self, aedtapp): assert os.path.exists(aedtapp.export_mesh_stats("Setup1")) - def test_67_sweep_from_json(self, aedtapp): + def test_sweep_from_json(self, aedtapp): dict_vals = read_json( os.path.join(TESTS_VISUALIZATION_PATH, "example_models", "report_json", "Modal_Report_Simple.json") ) 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, aedtapp): + # @pytest.mark.skipif( + # config["desktopVersion"] < "2022.2", reason="Not working in non graphical in version lower than 2022.2" + # ) + def test_sweep_from_json_1(self, aedtapp): assert aedtapp.post.create_report_from_configuration( os.path.join(TESTS_VISUALIZATION_PATH, "example_models", "report_json", "Modal_Report.json") ) @@ -819,18 +1058,20 @@ def test_70_sweep_from_json(self, aedtapp): matplotlib=True, ) - def test_74_dynamic_update(self, aedtapp): + def test_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, aedtapp): + def test_setup_derivative(self, aedtapp): setup_derivative = aedtapp.setups[1] - setup_derivative_auto = aedtapp.setups[2] assert setup_derivative.set_tuning_offset({"inner_radius": 0.1}) + + def test_setup_derivative_auto(self, aedtapp): + setup_derivative_auto = aedtapp.setups[2] assert setup_derivative_auto.set_tuning_offset({"inner_radius": 0.1}) - def test_trace_characteristics(self, m2d_app, local_scratch): + def test_trace_characteristics(self, m2d_app): m2d_app.set_active_design("Design1") assert m2d_app.post.plots[0].add_trace_characteristics("XAtYVal", arguments=["0"], solution_range=["Full"]) @@ -840,6 +1081,11 @@ def test_trace_export_table(self, m2d_app, local_scratch): output_file_path = os.path.join(local_scratch.path, "zeroes.tab") assert m2d_app.post.plots[0].export_table_to_file(plot_name, output_file_path, "Legend") assert os.path.exists(output_file_path) + + def test_trace_export_table(self, m2d_app, local_scratch): + m2d_app.set_active_design("Design2") + plot_name = m2d_app.post.plots[0].plot_name + output_file_path = os.path.join(local_scratch.path, "zeroes.tab") with pytest.raises(AEDTRuntimeError): m2d_app.post.plots[0].export_table_to_file("Invalid Name", output_file_path, "Legend") with pytest.raises(AEDTRuntimeError):