From 4dedcc3c9bbb90a187cdde73423baab5041cf66a Mon Sep 17 00:00:00 2001 From: jsalant Date: Tue, 19 Sep 2023 10:46:26 -0400 Subject: [PATCH 1/3] better handling if users cancel file dlgs Don't error out if users cancel a file dlg, just do "nothing" --- examples/07-EMIT/interference_gui.py | 17 +++++++++-------- pyaedt/emit_core/results/revision.py | 5 ++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/07-EMIT/interference_gui.py b/examples/07-EMIT/interference_gui.py index 6d7c82ab58e..6dfce44cb1b 100644 --- a/examples/07-EMIT/interference_gui.py +++ b/examples/07-EMIT/interference_gui.py @@ -237,9 +237,9 @@ def setup_widgets(self): # with all EMIT designs in the project. def open_file_dialog(self): - fname = QtWidgets.QFileDialog.getOpenFileName(self, "Select EMIT Project", "", "Ansys Electronics Desktop Files (*.aedt)", ) + fname, _filter = QtWidgets.QFileDialog.getOpenFileName(self, "Select EMIT Project", "", "Ansys Electronics Desktop Files (*.aedt)", ) if fname: - self.file_path_box.setText(fname[0]) + self.file_path_box.setText(fname) # Close previous project and open specified one if self.emitapp is not None: @@ -385,10 +385,11 @@ def save_image(self): else: table = self.interference_matrix - fname = QtWidgets.QFileDialog.getSaveFileName(self, "Save Scenario Matrix", "Scenario Matrix", "png (*.png)") - image = QtGui.QImage(table.size(), QtGui.QImage.Format_ARGB32) - table.render(image) - image.save(fname[0]) + fname, _filter = QtWidgets.QFileDialog.getSaveFileName(self, "Save Scenario Matrix", "Scenario Matrix", "png (*.png)") + if fname: + image = QtGui.QImage(table.size(), QtGui.QImage.Format_ARGB32) + table.render(image) + image.save(fname) ############################################################################### # Save scenario matrix to Excel file @@ -404,7 +405,7 @@ def save_results_excel(self): table = self.interference_matrix defaultName = "Interference Type Classification" - fname = QtWidgets.QFileDialog.getSaveFileName(self, "Save Scenario Matrix", defaultName, "xlsx (*.xlsx)") + fname, _filter = QtWidgets.QFileDialog.getSaveFileName(self, "Save Scenario Matrix", defaultName, "xlsx (*.xlsx)") if fname: workbook = openpyxl.Workbook() @@ -421,7 +422,7 @@ def save_results_excel(self): cell.fill = PatternFill(start_color = self.color_dict[self.all_colors[col-2][row-2]][1][1:], end_color = self.color_dict[self.all_colors[col-2][row-2]][1][1:], fill_type = "solid") - workbook.save(fname[0]) + workbook.save(fname) ############################################################################### # Run interference type simulation diff --git a/pyaedt/emit_core/results/revision.py b/pyaedt/emit_core/results/revision.py index 17cc6ffe8e5..0af75c1ddaf 100644 --- a/pyaedt/emit_core/results/revision.py +++ b/pyaedt/emit_core/results/revision.py @@ -6,7 +6,6 @@ from pyaedt.emit_core.emit_constants import TxRxMode from pyaedt.generic.general_methods import pyaedt_function_handler - class Revision: """ Provides the ``Revision`` object. @@ -500,9 +499,9 @@ def interference_type_classification(self, domain, use_filter=False, filter_list in_filters = True # Save the worst case interference values - if instance.get_value(mode_power) > max_power and in_filters: + if instance.has_valid_values() and instance.get_value(ResultType.EMI) > max_power and in_filters: prob = instance.get_largest_problem_type(ResultType.EMI) - max_power = instance.get_value(mode_power) + max_power = instance.get_value(ResultType.EMI) largest_rx_prob = rx_prob largest_tx_prob = prob.replace(" ", "").split(":") From 5cbf1c75f5c3292afd1d8db394dc726e266c2eba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:49:12 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyaedt/emit_core/results/revision.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyaedt/emit_core/results/revision.py b/pyaedt/emit_core/results/revision.py index 0af75c1ddaf..6519a34c0da 100644 --- a/pyaedt/emit_core/results/revision.py +++ b/pyaedt/emit_core/results/revision.py @@ -6,6 +6,7 @@ from pyaedt.emit_core.emit_constants import TxRxMode from pyaedt.generic.general_methods import pyaedt_function_handler + class Revision: """ Provides the ``Revision`` object. @@ -499,7 +500,11 @@ def interference_type_classification(self, domain, use_filter=False, filter_list in_filters = True # Save the worst case interference values - if instance.has_valid_values() and instance.get_value(ResultType.EMI) > max_power and in_filters: + if ( + instance.has_valid_values() + and instance.get_value(ResultType.EMI) > max_power + and in_filters + ): prob = instance.get_largest_problem_type(ResultType.EMI) max_power = instance.get_value(ResultType.EMI) largest_rx_prob = rx_prob From 262d728831b25d990ad9773a0f474ffd47bf53b2 Mon Sep 17 00:00:00 2001 From: jsalant Date: Wed, 20 Sep 2023 13:13:23 -0400 Subject: [PATCH 3/3] Update test_26_emit.py --- _unittest_solvers/test_26_emit.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_unittest_solvers/test_26_emit.py b/_unittest_solvers/test_26_emit.py index a86b9b65ca4..b89c7805c3e 100644 --- a/_unittest_solvers/test_26_emit.py +++ b/_unittest_solvers/test_26_emit.py @@ -911,7 +911,7 @@ def test_interference_scripts_no_filter(self, add_app): # Test with no filtering expected_interference_colors = [["white", "green", "yellow"], ["red", "green", "white"]] - expected_interference_power = [["N/A", -20.0, -20.0], [-20.0, -20.0, "N/A"]] + expected_interference_power = [["N/A", 16.64, 56.0], [60.0, 16.64, "N/A"]] expected_protection_colors = [["white", "yellow", "yellow"], ["yellow", "yellow", "white"]] expected_protection_power = [["N/A", -20.0, -20.0], [-20.0, -20.0, "N/A"]] @@ -976,10 +976,10 @@ def test_interference_filtering(self, add_app): [["white", "white", "yellow"], ["red", "white", "white"]], ] all_interference_power = [ - [["N/A", -20.0, -20.0], [-20.0, -20.0, "N/A"]], - [["N/A", -20.0, -20.0], [-20.0, -20.0, "N/A"]], - [["N/A", -20.0, -20.0], [-20.0, -20.0, "N/A"]], - [["N/A", "<= -200", -20.0], [-20.0, "<= -200", "N/A"]], + [["N/A", 16.64, 56.0], [-3.96, 16.64, "N/A"]], + [["N/A", 16.64, 56.0], [60.0, 16.64, "N/A"]], + [["N/A", 16.64, 2.45], [60.0, 16.64, "N/A"]], + [["N/A", "<= -200", 56.0], [60.0, "<= -200", "N/A"]], ] interference_filters = [ "TxFundamental:In-band",