From 340d6f066b5f970f2f62f614dcbc1ed03d0cfd0f Mon Sep 17 00:00:00 2001 From: raghajaf Date: Tue, 8 Oct 2024 12:44:20 -0400 Subject: [PATCH 1/3] FIX: Clear function added to multipleband table --- .../test_filter/test_multiple_bands_table.py | 13 +++++++++++++ .../test_filter/test_transmission_zeros.py | 14 +++++++------- .../filtersolutions_core/multiple_bands_table.py | 5 +++++ .../filtersolutions_core/transmission_zeros.py | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py b/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py index 001f73d8589..9fad3d284d9 100644 --- a/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py +++ b/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py @@ -90,3 +90,16 @@ def test_remove_row(self): info.value.args[0] == "Either no value is set for this band or the rowIndex must be greater than zero and less than row count" ) + + def test_clear_table(): + design = ansys.aedt.core.FilterSolutions(implementation_type=FilterImplementation.LUMPED) + design.attributes.filter_multiple_bands_enabled = True + design.multiple_bands_table.clear_table() + assert design.multiple_bands_table.row_count == 0 + for i in range(7): + with pytest.raises(RuntimeError) as info: + design.multiple_bands_table.row(i) + assert ( + info.value.args[0] == "Either no value is set for this band or the rowIndex must be greater than " + "zero and less than row count" + ) diff --git a/_unittest/test_45_FilterSolutions/test_filter/test_transmission_zeros.py b/_unittest/test_45_FilterSolutions/test_filter/test_transmission_zeros.py index a3002cb99cf..3d10a06a012 100644 --- a/_unittest/test_45_FilterSolutions/test_filter/test_transmission_zeros.py +++ b/_unittest/test_45_FilterSolutions/test_filter/test_transmission_zeros.py @@ -69,13 +69,13 @@ def test_append_row(self): assert info.value.args[0] == self.input_value_blank_msg design.transmission_zeros_bandwidth.append_row("1600M") assert design.transmission_zeros_bandwidth.row(0) == ("1600M", "") - design.transmission_zeros_bandwidth.clear_row() + design.transmission_zeros_bandwidth.clear_table() design.transmission_zeros_bandwidth.append_row(zero="1600M", position="2") assert design.transmission_zeros_bandwidth.row(0) == ("1600M", "2") - design.transmission_zeros_bandwidth.clear_row() + design.transmission_zeros_bandwidth.clear_table() design.transmission_zeros_ratio.append_row("1.6") assert design.transmission_zeros_ratio.row(0) == ("1.6", "") - design.transmission_zeros_ratio.clear_row() + design.transmission_zeros_ratio.clear_table() design.transmission_zeros_ratio.append_row(zero="1.6", position="2") assert design.transmission_zeros_ratio.row(0) == ("1.6", "2") @@ -97,7 +97,7 @@ def test_insert_row(self): assert design.transmission_zeros_bandwidth.row(0) == ("1600M", "") design.transmission_zeros_bandwidth.insert_row(0, zero="1600M", position="2") assert design.transmission_zeros_bandwidth.row(0) == ("1600M", "2") - design.transmission_zeros_bandwidth.clear_row() + design.transmission_zeros_bandwidth.clear_table() design.transmission_zeros_ratio.insert_row(0, "1.6") assert design.transmission_zeros_ratio.row(0) == ("1.6", "") design.transmission_zeros_ratio.insert_row(0, zero="1.6", position="2") @@ -114,17 +114,17 @@ def test_remove_row(self): design.transmission_zeros_bandwidth.row(0) assert info.value.args[0] == self.no_transmission_zero_msg - def test_clear_row(self): + def test_clear_table(self): design = ansys.aedt.core.FilterSolutions(implementation_type=FilterImplementation.LUMPED) design.transmission_zeros_bandwidth.insert_row(0, zero="1600M", position="2") assert design.transmission_zeros_bandwidth.row(0) == ("1600M", "2") - design.transmission_zeros_bandwidth.clear_row() + design.transmission_zeros_bandwidth.clear_table() with pytest.raises(RuntimeError) as info: design.transmission_zeros_bandwidth.row(0) assert info.value.args[0] == self.no_transmission_zero_msg design.transmission_zeros_ratio.insert_row(0, zero="1.6", position="2") assert design.transmission_zeros_ratio.row(0) == ("1.6", "2") - design.transmission_zeros_ratio.clear_row() + design.transmission_zeros_ratio.clear_table() with pytest.raises(RuntimeError) as info: design.transmission_zeros_ratio.row(0) assert info.value.args[0] == self.no_transmission_zero_msg diff --git a/src/ansys/aedt/core/filtersolutions_core/multiple_bands_table.py b/src/ansys/aedt/core/filtersolutions_core/multiple_bands_table.py index 8c2c6866d0b..c5d0b1b52df 100644 --- a/src/ansys/aedt/core/filtersolutions_core/multiple_bands_table.py +++ b/src/ansys/aedt/core/filtersolutions_core/multiple_bands_table.py @@ -166,3 +166,8 @@ def remove_row(self, row_index): """ status = self._dll.removeMultipleBandsTableRow(row_index) ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status) + + def clear_table(self): + """Remove all rows from the multiple bands table.""" + for i in range(self.row_count - 1, -1, -1): + self.remove_row(i) diff --git a/src/ansys/aedt/core/filtersolutions_core/transmission_zeros.py b/src/ansys/aedt/core/filtersolutions_core/transmission_zeros.py index 58a0e1b557d..18fe4233244 100644 --- a/src/ansys/aedt/core/filtersolutions_core/transmission_zeros.py +++ b/src/ansys/aedt/core/filtersolutions_core/transmission_zeros.py @@ -241,7 +241,7 @@ def remove_row(self, row_index): status = self._dll.removeTransmissionZerosTableRow(row_index, self.table_format_to_bool()) ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status) - def clear_row(self): + def clear_table(self): """Clear all entries in the transmission zeros table.""" status = self._dll.clearTransmissionZerosTableRow(self.table_format_to_bool()) ansys.aedt.core.filtersolutions_core._dll_interface().raise_error(status) From 013447a9106b775f1dcde037bfb3e77f46848efe Mon Sep 17 00:00:00 2001 From: raghajaf Date: Tue, 8 Oct 2024 13:58:55 -0400 Subject: [PATCH 2/3] FIX: Comments added. --- .../test_filter/test_multiple_bands_table.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py b/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py index 9fad3d284d9..6030af4f69e 100644 --- a/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py +++ b/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py @@ -94,8 +94,11 @@ def test_remove_row(self): def test_clear_table(): design = ansys.aedt.core.FilterSolutions(implementation_type=FilterImplementation.LUMPED) design.attributes.filter_multiple_bands_enabled = True + # There are 2 rows in the table by default + assert design.multiple_bands_table.row_count == 2 design.multiple_bands_table.clear_table() assert design.multiple_bands_table.row_count == 0 + # Check if the table is empty for all 7 rows for i in range(7): with pytest.raises(RuntimeError) as info: design.multiple_bands_table.row(i) From d886ab0ef2ea1c9ce701f3e1823e53faf3d59157 Mon Sep 17 00:00:00 2001 From: raghajaf Date: Tue, 8 Oct 2024 16:12:01 -0400 Subject: [PATCH 3/3] FIX: Unittest is updated. --- .../test_filter/test_multiple_bands_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py b/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py index 6030af4f69e..d408a7de1c7 100644 --- a/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py +++ b/_unittest/test_45_FilterSolutions/test_filter/test_multiple_bands_table.py @@ -91,7 +91,7 @@ def test_remove_row(self): == "Either no value is set for this band or the rowIndex must be greater than zero and less than row count" ) - def test_clear_table(): + def test_clear_table(self): design = ansys.aedt.core.FilterSolutions(implementation_type=FilterImplementation.LUMPED) design.attributes.filter_multiple_bands_enabled = True # There are 2 rows in the table by default