From 26a884b555efcfcb5a90aaa5f53c9d2962403edd Mon Sep 17 00:00:00 2001 From: gmalinve <103059376+gmalinve@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:12:06 +0100 Subject: [PATCH 01/23] Fix/plot animated field (#4408) Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> --- pyaedt/modules/AdvancedPostProcessing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyaedt/modules/AdvancedPostProcessing.py b/pyaedt/modules/AdvancedPostProcessing.py index e88ed21ce0a..17c51454c4c 100644 --- a/pyaedt/modules/AdvancedPostProcessing.py +++ b/pyaedt/modules/AdvancedPostProcessing.py @@ -580,7 +580,6 @@ def plot_animated_field( variation_variable="Phi", variation_list=["0deg"], view="isometric", - plot_label=None, show=True, scale_min=None, scale_max=None, @@ -594,7 +593,7 @@ def plot_animated_field( show_grid=False, show_bounding=False, show_legend=True, - filter_objects=[], + filter_objects=None, ): """Create an animated field plot using Python PyVista and export to a gif file. @@ -650,6 +649,7 @@ def plot_animated_field( Whether to display the legend or not. The default is ``True``. filter_objects : list, optional Objects list for filtering the ``CutPlane`` plots. + The default is ``None`` in which case an empty list is passed. Returns ------- @@ -662,6 +662,8 @@ def plot_animated_field( intrinsics = {} if not export_path: export_path = self._app.working_directory + if not filter_objects: + filter_objects = [] v = 0 fields_to_add = [] @@ -682,7 +684,7 @@ def plot_animated_field( object_list, quantity, setup_name, intrinsics, filter_objects=filter_objects ) if plotf: - file_to_add = self.export_field_plot(plotf.name, export_path, plotf.name + str(v), file_format="case") + file_to_add = self.export_field_plot(plotf.name, export_path, plotf.name + str(v)) if file_to_add: fields_to_add.append(file_to_add) plotf.delete() From 00f8bd69b209cc9bffc37cf4a517a406a7133c07 Mon Sep 17 00:00:00 2001 From: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> Date: Tue, 26 Mar 2024 18:27:16 +0100 Subject: [PATCH 02/23] Remove any usage of bare exception. (#4331) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com> Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> --- _unittest/conftest.py | 2 +- _unittest/test_01_Design.py | 6 +- _unittest/test_02_3D_modeler.py | 2 +- _unittest/test_12_PostProcessing.py | 2 +- _unittest/test_21_Circuit.py | 2 +- _unittest_solvers/conftest.py | 2 +- _unittest_solvers/test_26_emit.py | 8 +- doc/source/conf.py | 2 +- pyaedt/__init__.py | 2 +- pyaedt/aedt_logger.py | 7 +- pyaedt/application/Analysis.py | 38 +++++----- pyaedt/application/AnalysisNexxim.py | 4 +- pyaedt/application/AnalysisRMxprt.py | 2 +- pyaedt/application/Design.py | 52 ++++++------- pyaedt/application/Variables.py | 16 ++-- pyaedt/application/aedt_objects.py | 2 +- pyaedt/application/design_solutions.py | 24 +++--- pyaedt/circuit.py | 18 ++--- pyaedt/common_rpc.py | 4 +- pyaedt/desktop.py | 40 +++++----- pyaedt/downloads.py | 2 +- pyaedt/generic/DataHandlers.py | 4 +- pyaedt/generic/clr_module.py | 4 +- pyaedt/generic/filesystem.py | 4 +- pyaedt/generic/general_methods.py | 18 ++--- pyaedt/generic/grpc_plugin.py | 4 +- pyaedt/generic/ibis_reader.py | 2 +- pyaedt/generic/plot.py | 10 +-- pyaedt/hfss.py | 22 +++--- pyaedt/hfss3dlayout.py | 12 +-- pyaedt/icepak.py | 4 +- pyaedt/maxwell.py | 10 +-- pyaedt/maxwellcircuit.py | 2 +- pyaedt/misc/aedtlib_personalib_install.py | 2 +- pyaedt/misc/misc.py | 2 +- pyaedt/modeler/cad/Modeler.py | 42 +++++----- pyaedt/modeler/cad/Primitives.py | 80 ++++++++++---------- pyaedt/modeler/cad/Primitives3D.py | 14 ++-- pyaedt/modeler/cad/components_3d.py | 4 +- pyaedt/modeler/cad/elements3d.py | 26 +++---- pyaedt/modeler/cad/object3d.py | 36 ++++----- pyaedt/modeler/cad/polylines.py | 6 +- pyaedt/modeler/circuits/PrimitivesCircuit.py | 2 +- pyaedt/modeler/circuits/object3dcircuit.py | 24 +++--- pyaedt/modeler/modeler3d.py | 4 +- pyaedt/modeler/modelerpcb.py | 10 +-- pyaedt/modeler/pcb/Primitives3DLayout.py | 6 +- pyaedt/modeler/pcb/object3dlayout.py | 2 +- pyaedt/modeler/schematic.py | 6 +- pyaedt/modules/Boundary.py | 8 +- pyaedt/modules/CableModeling.py | 26 +++---- pyaedt/modules/DesignXPloration.py | 12 +-- pyaedt/modules/LayerStackup.py | 6 +- pyaedt/modules/Material.py | 6 +- pyaedt/modules/MaterialLib.py | 6 +- pyaedt/modules/Mesh.py | 10 +-- pyaedt/modules/Mesh3DLayout.py | 2 +- pyaedt/modules/MeshIcepak.py | 2 + pyaedt/modules/PostProcessor.py | 24 +++--- pyaedt/modules/SolveSetup.py | 12 +-- pyaedt/modules/SolveSweeps.py | 2 +- pyaedt/modules/monitor_icepak.py | 12 +-- pyaedt/modules/report_templates.py | 16 ++-- pyaedt/modules/solutions.py | 16 ++-- pyaedt/q3d.py | 16 ++-- pyaedt/rpc/rpyc_services.py | 6 +- pyaedt/sbrplus/plot.py | 4 +- 67 files changed, 394 insertions(+), 391 deletions(-) diff --git a/_unittest/conftest.py b/_unittest/conftest.py index 5daf7321ad9..c118de30461 100644 --- a/_unittest/conftest.py +++ b/_unittest/conftest.py @@ -85,7 +85,7 @@ try: with open(local_config_file) as f: local_config = json.load(f) - except: # pragma: no cover + except Exception: # pragma: no cover local_config = {} config.update(local_config) diff --git a/_unittest/test_01_Design.py b/_unittest/test_01_Design.py index 4fb2ebf52f0..54e3654bc7b 100644 --- a/_unittest/test_01_Design.py +++ b/_unittest/test_01_Design.py @@ -340,7 +340,7 @@ def test_34_force_project_path_disable(self): h = Hfss("c:/dummy/test.aedt", specified_version=desktop_version) except Exception as e: exception_raised = True - assert e.args[0] == "Project doesn't exists. Check it and retry." + assert e.args[0] == "Project doesn't exist. Check it and retry." assert exception_raised settings.force_error_on_missing_project = False @@ -374,7 +374,7 @@ def test_36_test_load(self, add_app): f.write(" ") try: hfss = Hfss(projectname=file_name2, specified_version=desktop_version) - except: + except Exception: assert True try: os.makedirs(os.path.join(self.local_scratch.path, "test_36_2.aedb")) @@ -382,7 +382,7 @@ def test_36_test_load(self, add_app): with open(file_name3, "w") as f: f.write(" ") hfss = Hfss3dLayout(projectname=file_name3, specified_version=desktop_version) - except: + except Exception: assert True def test_37_add_custom_toolkit(self, desktop): diff --git a/_unittest/test_02_3D_modeler.py b/_unittest/test_02_3D_modeler.py index 454c62da9c5..c8128e75e52 100644 --- a/_unittest/test_02_3D_modeler.py +++ b/_unittest/test_02_3D_modeler.py @@ -359,7 +359,7 @@ def test_35_activate_variable_for_tuning(self): try: self.aedtapp.activate_variable_tuning("Idontexist") assert False - except: + except Exception: assert True def test_36_activate_variable_for_optimization(self): diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index 8e3a906e7ab..aced256c218 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -678,7 +678,7 @@ def test_71_antenna_plot(self, field_test): try: p = ffdata.polar_plot_3d_pyvista(farfield_quantity="RealizedGain", convert_to_db=True, show=False) assert isinstance(p, object) - except: + except Exception: assert True @pytest.mark.skipif(is_linux or sys.version_info < (3, 8), reason="FarFieldSolution not supported by IronPython") diff --git a/_unittest/test_21_Circuit.py b/_unittest/test_21_Circuit.py index ecd03f8ee77..06948314a1c 100644 --- a/_unittest/test_21_Circuit.py +++ b/_unittest/test_21_Circuit.py @@ -447,7 +447,7 @@ def test_34_activate_variables(self): try: self.aedtapp.activate_variable_tuning("Idontexist") assert False - except: + except Exception: assert True def test_35_netlist_data_block(self): diff --git a/_unittest_solvers/conftest.py b/_unittest_solvers/conftest.py index 7bf9ea7bc83..90bbaf63b55 100644 --- a/_unittest_solvers/conftest.py +++ b/_unittest_solvers/conftest.py @@ -79,7 +79,7 @@ try: with open(local_config_file) as f: local_config = json.load(f) - except: # pragma: no cover + except Exception: # pragma: no cover local_config = {} config.update(local_config) diff --git a/_unittest_solvers/test_26_emit.py b/_unittest_solvers/test_26_emit.py index b47a1c132ef..91cfc2b9fff 100644 --- a/_unittest_solvers/test_26_emit.py +++ b/_unittest_solvers/test_26_emit.py @@ -176,14 +176,14 @@ def test_04_radio_component(self, add_app): exception_raised = False try: radio.set_band_power_level(100) - except: + except Exception: exception_raised = True assert exception_raised # Try getting band power from the radio exception_raised = False try: radio.get_band_power_level() - except: + except Exception: exception_raised = True assert exception_raised # full units support added with 2023.2 @@ -562,7 +562,7 @@ def test_10_radio_band_getters(self, add_app): exception_raised = False try: freqs = rev.get_active_frequencies(radios[0], bands[0], TxRxMode.BOTH, "MHz") - except: + except Exception: exception_raised = True assert exception_raised @@ -629,7 +629,7 @@ def test_11_sampling_getters(self, add_app): exception_raised = False try: rad.set_channel_sampling() - except: + except Exception: exception_raised = True assert exception_raised diff --git a/doc/source/conf.py b/doc/source/conf.py index 93a99524d57..b9d3743588f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -64,7 +64,7 @@ def run(self): def autodoc_skip_member(app, what, name, obj, skip, options): try: exclude = True if ".. deprecated::" in obj.__doc__ else False - except: + except Exception: exclude = False exclude2 = True if name.startswith("_") else False return True if (skip or exclude or exclude2) else None # Can interfere with subsequent skip functions. diff --git a/pyaedt/__init__.py b/pyaedt/__init__.py index 6274f54bd48..dbfbf26f363 100644 --- a/pyaedt/__init__.py +++ b/pyaedt/__init__.py @@ -64,7 +64,7 @@ def custom_show_warning(message, category, filename, lineno, file=None, line=Non try: from pyaedt.generic.design_types import Hfss3dLayout -except: +except Exception: from pyaedt.generic.design_types import Hfss3dLayout from pyaedt.generic.design_types import Circuit diff --git a/pyaedt/aedt_logger.py b/pyaedt/aedt_logger.py index 5fdbac374d9..23a19660e6c 100644 --- a/pyaedt/aedt_logger.py +++ b/pyaedt/aedt_logger.py @@ -252,7 +252,7 @@ def _log_on_desktop(self): return True else: return False - except: # pragma: no cover + except Exception: # pragma: no cover return False @_log_on_desktop.setter @@ -590,7 +590,8 @@ def _log_on_dekstop(self, message_type, message_text, level=None, proj_name=None des_name = des_name[des_name.find(";") + 1 :] try: self._desktop.AddMessage(proj_name, des_name, message_type, message_text) - except: + + except Exception: # pragma: no cover pass def _log_on_handler(self, message_type, message_text, *args, **kwargs): @@ -658,7 +659,7 @@ def clear_messages(self, proj_name=None, des_name=None, level=2): des_name = self.design_name try: self._desktop.ClearMessages(proj_name, des_name, level) - except: + except Exception: # pragma: no cover pass @property diff --git a/pyaedt/application/Analysis.py b/pyaedt/application/Analysis.py index 86175299a86..1f0df1b21bf 100644 --- a/pyaedt/application/Analysis.py +++ b/pyaedt/application/Analysis.py @@ -348,7 +348,7 @@ def existing_analysis_sweeps(self): elif self.solution_type not in ["Eigenmode"]: try: sweeps = list(self.oanalysis.GetSweeps(el)) - except: + except Exception: sweeps = [] for sw in sweeps: if el + " : " + sw not in sweep_list: @@ -474,7 +474,7 @@ def excitations(self): del list_names[1::2] list_names = list(set(list_names)) return list_names - except: + except Exception: return [] @pyaedt_function_handler() @@ -588,12 +588,12 @@ def list_of_variations(self, setup_name=None, sweep_name=None): ): try: return list(self.osolution.ListVariations("{0} : {1}".format(setup_name, sweep_name))) - except: + except Exception: return [""] else: try: return list(self.odesign.ListVariations("{0} : {1}".format(setup_name, sweep_name))) - except: + except Exception: return [""] @pyaedt_function_handler() @@ -689,7 +689,7 @@ def export_results( try: self.post.oreportsetup.ExportToFile(str(report_name), export_path) self.logger.info("Export Data: {}".format(export_path)) - except: + except Exception: pass exported_files.append(export_path) @@ -800,7 +800,7 @@ def export_results( ) exported_files.append(export_path) self.logger.info("Exported Touchstone: %s", export_path) - except: + except Exception: self.logger.warning("Export SnP failed: no solutions found") elif self.design_type == "2D Extractor": export_path = os.path.join( @@ -822,7 +822,7 @@ def export_results( ) exported_files.append(export_path) self.logger.info("Exported Touchstone: %s", export_path) - except: + except Exception: self.logger.warning("Export SnP failed: no solutions found") elif self.design_type == "Q3D Extractor": export_path = os.path.join( @@ -843,7 +843,7 @@ def export_results( ) exported_files.append(export_path) self.logger.info("Exported Touchstone: %s", export_path) - except: + except Exception: self.logger.warning("Export SnP failed: no solutions found") else: self.logger.warning("Setup is not solved. To export results please analyze setup first.") @@ -938,9 +938,9 @@ def _get_native_data(self): ds, ) ) - except: + except Exception: pass - except: + except Exception: pass return boundaries @@ -1755,7 +1755,7 @@ def analyze_setup( try: self.set_registry_key(r"Desktop/ActiveDSOConfigurations/" + self.design_type, name) set_custom_dso = True - except: + except Exception: pass elif num_gpu or num_tasks or num_cores: config_name = "pyaedt_config" @@ -1780,7 +1780,7 @@ def analyze_setup( self.logger.error("Permission denied.") skip_files = True # For other errors - except: + except Exception: self.logger.error("Error occurred while copying file.") skip_files = True if not skip_files: @@ -1829,7 +1829,7 @@ def analyze_setup( self._desktop.SetRegistryFromFile(target_name) self.set_registry_key(r"Desktop/ActiveDSOConfigurations/" + self.design_type, config_name) set_custom_dso = True - except: + except Exception: pass if not name: try: @@ -1838,7 +1838,7 @@ def analyze_setup( self.odesign.AnalyzeAll(blocking) else: self.odesign.AnalyzeAll() - except: + except Exception: if set_custom_dso: self.set_registry_key(r"Desktop/ActiveDSOConfigurations/" + self.design_type, active_config) self.logger.error("Error in solving all setups (AnalyzeAll).") @@ -1852,7 +1852,7 @@ def analyze_setup( self.odesign.Analyze(name, blocking) else: self.odesign.Analyze(name) - except: + except Exception: if set_custom_dso: self.set_registry_key(r"Desktop/ActiveDSOConfigurations/" + self.design_type, active_config) self.logger.error("Error in Solving Setup %s", name) @@ -1861,7 +1861,7 @@ def analyze_setup( try: self.logger.info("Solving Optimetrics") self.ooptimetrics.SolveSetup(name) - except: + except Exception: if set_custom_dso: self.set_registry_key(r"Desktop/ActiveDSOConfigurations/" + self.design_type, active_config) self.logger.error("Error in Solving or Missing Setup %s", name) @@ -2274,7 +2274,7 @@ def value_with_units( else: try: units = self.odesktop.GetDefaultUnit(unit_system) - except: + except Exception: self.logger.warning("Defined unit system is incorrect.") units = "" from pyaedt.generic.general_methods import _dim_arg @@ -2377,13 +2377,13 @@ def export_rl_matrix( precision, is_exponential, ) - except: + except Exception: self.logger.error("Solutions are empty. Solve before exporting.") return False else: try: self.oanalysis.ExportSolnData(analysis_setup, matrix_name, is_post_processed, variations, file_path) - except: + except Exception: self.logger.error("Solutions are empty. Solve before exporting.") return False diff --git a/pyaedt/application/AnalysisNexxim.py b/pyaedt/application/AnalysisNexxim.py index ef087ec72bd..64c65c6e8e8 100644 --- a/pyaedt/application/AnalysisNexxim.py +++ b/pyaedt/application/AnalysisNexxim.py @@ -124,7 +124,7 @@ def push_down(self, component_name): try: self.oproject.SetActiveDesign(out_name) self.__init__(projectname=self.project_name, designname=out_name) - except: # pragma: no cover + except Exception: # pragma: no cover return False return True @@ -141,7 +141,7 @@ def pop_up(self): parent_name = self.odesign.GetName().split(";")[1].split("/")[0] self.oproject.SetActiveDesign(parent_name) self.__init__(projectname=self.project_name, designname=parent_name) - except: + except Exception: return False return True diff --git a/pyaedt/application/AnalysisRMxprt.py b/pyaedt/application/AnalysisRMxprt.py index bcc1c83da31..a63acd5bc83 100644 --- a/pyaedt/application/AnalysisRMxprt.py +++ b/pyaedt/application/AnalysisRMxprt.py @@ -147,7 +147,7 @@ def set_material_threshold(self, conductivity=100000, permeability=100): try: self.odesign.SetThreshold(conductivity, permeability) return True - except: + except Exception: return False @pyaedt_function_handler() diff --git a/pyaedt/application/Design.py b/pyaedt/application/Design.py index 68549844fc7..d14f2c8e52c 100644 --- a/pyaedt/application/Design.py +++ b/pyaedt/application/Design.py @@ -544,7 +544,7 @@ def project_properties(self): file_path = check_and_download_file(local_path, self.project_file) try: settings._project_properties[os.path.normpath(self.project_file)] = load_entire_aedt_file(file_path) - except: + except Exception: pass self._logger.info("aedt file load time {}".format(time.time() - start)) if os.path.normpath(self.project_file) in settings._project_properties: @@ -571,7 +571,7 @@ def design_properties(self): else: if designs["Name"] == self.design_name: return designs - except: + except Exception: return OrderedDict() @property @@ -699,7 +699,7 @@ def project_name(self): if self.oproject: try: return self.oproject.GetName() - except: + except Exception: return None else: return None @@ -954,7 +954,7 @@ def toolkit_directory(self): toolkit_directory = self.project_path + "/" + name + ".pyaedt" try: settings.remote_rpc_session.filemanager.makedirs(toolkit_directory) - except: + except Exception: toolkit_directory = settings.remote_rpc_session.filemanager.temp_dir() + "/" + name + ".pyaedt" elif settings.remote_api or settings.remote_rpc_session: toolkit_directory = self.results_directory @@ -1180,7 +1180,7 @@ def oproject(self, proj_name=None): self.logger.info("Project %s has been opened.", self._oproject.GetName()) time.sleep(0.5) elif settings.force_error_on_missing_project and ".aedt" in proj_name: - raise Exception("Project doesn't exists. Check it and retry.") + raise Exception("Project doesn't exist. Check it and retry.") else: project_list = self.odesktop.GetProjectList() self._oproject = self.odesktop.NewProject() @@ -1266,7 +1266,7 @@ def get_oo_name(self, aedt_object, object_name=None): else: return aedt_object.GetChildNames() - except: + except Exception: return [] @pyaedt_function_handler() @@ -1287,7 +1287,7 @@ def get_oo_object(self, aedt_object, object_name): """ try: return aedt_object.GetChildObject(object_name) - except: + except Exception: return False @pyaedt_function_handler() @@ -1308,7 +1308,7 @@ def get_oo_properties(self, aedt_object, object_name): """ try: return aedt_object.GetChildObject(object_name).GetPropNames() - except: + except Exception: return [] @pyaedt_function_handler() @@ -1329,7 +1329,7 @@ def get_oo_property_value(self, aedt_object, object_name, prop_name): """ try: return aedt_object.GetChildObject(object_name).GetPropValue(prop_name) - except: + except Exception: return None @pyaedt_function_handler() @@ -1400,7 +1400,7 @@ def export_profile(self, setup_name, variation_string="", file_path=None): else: try: self.odesign.ExportProfile(setup_name, variation_string, file_path) - except: + except Exception: self.odesign.ExportProfile(setup_name, variation_string, file_path, True) self.logger.info("Exported Profile to file {}".format(file_path)) return file_path @@ -1570,7 +1570,7 @@ def _arg_with_units(self, value, units=None): try: float(value) val = "{0}{1}".format(value, units) - except: + except Exception: val = value else: val = "{0}{1}".format(value, units) @@ -1601,7 +1601,7 @@ def set_license_type(self, license_type="Pool"): try: self.odesktop.SetRegistryString("Desktop/Settings/ProjectOptions/HPCLicenseType", license_type) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -1630,7 +1630,7 @@ def set_registry_key(self, key_full_name, key_value): self.odesktop.SetRegistryString(key_full_name, key_value) self.logger.info("Key %s correctly changed.", key_full_name) return True - except: + except Exception: self.logger.warning("Error setting up Key %s.", key_full_name) return False elif isinstance(key_value, int): @@ -1638,7 +1638,7 @@ def set_registry_key(self, key_full_name, key_value): self.odesktop.SetRegistryInt(key_full_name, key_value) self.logger.info("Key %s correctly changed.", key_full_name) return True - except: + except Exception: self.logger.warning("Error setting up Key %s.", key_full_name) return False else: @@ -1729,7 +1729,7 @@ def _is_object_oriented_enabled(self): try: self.oproject.GetChildObject("Variables") return True - except: + except Exception: return False @pyaedt_function_handler() @@ -1757,7 +1757,7 @@ def set_active_dso_config_name(self, product_name="HFSS", config_name="Local"): self.set_registry_key("Desktop/ActiveDSOConfigurations/{}".format(product_name), config_name) self.logger.info("Configuration Changed correctly to %s for %s.", config_name, product_name) return True - except: + except Exception: self.logger.warning("Error Setting Up Configuration %s for %s.", config_name, product_name) return False @@ -1798,7 +1798,7 @@ def set_registry_from_file(self, registry_file, make_active=True): if design_type and config_name: self.set_active_dso_config_name(design_type[1], config_name[1]) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -2235,7 +2235,7 @@ def _get_boundaries_data(self): self.design_properties["BoundarySetup"]["Boundaries"][ds]["BoundType"], ) ) - except: + except Exception: pass if self.design_properties and "MaxwellParameterSetup" in self.design_properties: for ds in self.design_properties["MaxwellParameterSetup"]["MaxwellParameters"]: @@ -2253,7 +2253,7 @@ def _get_boundaries_data(self): ], ) ) - except: + except Exception: pass if self.design_properties and "ModelSetup" in self.design_properties: if "MotionSetupList" in self.design_properties["ModelSetup"]: @@ -2271,7 +2271,7 @@ def _get_boundaries_data(self): self.design_properties["ModelSetup"]["MotionSetupList"][ds]["MotionType"], ) ) - except: + except Exception: pass if self.design_type in ["HFSS 3D Layout Design"]: for port in self.oboundary.GetAllPortsList(): @@ -2350,7 +2350,7 @@ def _get_project_datasets(self): "Coordinates" ] datasets[ds] = self._get_ds_data(ds, data) - except: + except Exception: pass return datasets @@ -2362,7 +2362,7 @@ def _get_design_datasets(self): for ds in self.design_properties["ModelSetup"]["DesignDatasets"]["DatasetDefinitions"]: data = self.design_properties["ModelSetup"]["DesignDatasets"]["DatasetDefinitions"][ds]["Coordinates"] datasets[ds] = self._get_ds_data(ds, data) - except: + except Exception: pass return datasets @@ -3191,7 +3191,7 @@ def delete_design(self, name=None, fallback_design=None): ): try: self.set_active_design(fallback_design) - except: + except Exception: if is_windows: self._init_variables() self._odesign = None @@ -3793,7 +3793,7 @@ def get_evaluated_value(self, variable_name, units=None): try: variation_string = self._odesign.GetNominalVariation() val = self._odesign.GetVariationVariableValue(variation_string, variable_name) # pragma: no cover - except: + except Exception: val_units = app.GetVariableValue(variable_name) val, original_units = decompose_variable_value(val_units) try: @@ -3861,7 +3861,7 @@ def evaluate_expression(self, expression_string): # Extract the numeric value of the expression (in SI units!) self._variable_manager.delete_variable(variable_name) return eval_value - except: + except Exception: self.logger.warning("Invalid string expression {}".format(expression_string)) return expression_string @@ -3932,7 +3932,7 @@ def _assert_consistent_design_type(self, des_name): try: self._odesign = self._oproject.SetActiveDesign(des_name) return True - except: + except Exception: return des_name else: return des_name diff --git a/pyaedt/application/Variables.py b/pyaedt/application/Variables.py index d60260ef981..1da104d08ba 100644 --- a/pyaedt/application/Variables.py +++ b/pyaedt/application/Variables.py @@ -542,7 +542,7 @@ def post_processing_variables(self): """ try: all_post_vars = list(self._odesign.GetPostProcessingVariables()) - except: + except Exception: all_post_vars = [] out = self.design_variables post_vars = {} @@ -904,7 +904,7 @@ def get_expression(self, variable_name): # TODO: Should be renamed to "evaluate if variable_name not in invalid_names: try: return self.aedt_object(variable_name).GetVariableValue(variable_name) - except: + except Exception: return False else: return False @@ -1057,7 +1057,7 @@ def set_variable( desktop_object.Undo() self._logger.clear_messages() return - except: + except Exception: pass else: raise Exception("Unhandled input type to the design property or project variable.") # pragma: no cover @@ -1095,7 +1095,7 @@ def set_variable( ], ] ) - except: + except Exception: if ";" in desktop_object.GetName() and prop_type == "PostProcessingVariableProp": self._logger.info("PostProcessing Variable exists already. Changing value.") desktop_object.ChangeProperty( @@ -1189,7 +1189,7 @@ def delete_separator(self, separator_name): ] ) return True - except: + except Exception: pass return False @@ -1230,7 +1230,7 @@ def delete_variable(self, var_name): ], ] ) - except: # pragma: no cover + except Exception: # pragma: no cover pass else: self._cleanup_variables() @@ -1494,7 +1494,7 @@ def _set_prop_val(self, prop, val, n_times=10): if result: break i += 1 - except: + except Exception: pass @pyaedt_function_handler() @@ -1516,7 +1516,7 @@ def _get_prop_val(self, prop): else: name = "LocalVariables" return self._app.get_oo_object(self._aedt_obj, "{}/{}".format(name, self._variable_name)).GetPropValue(prop) - except: + except Exception: pass @property diff --git a/pyaedt/application/aedt_objects.py b/pyaedt/application/aedt_objects.py index 252bba97ea5..ace9bd1e616 100644 --- a/pyaedt/application/aedt_objects.py +++ b/pyaedt/application/aedt_objects.py @@ -73,7 +73,7 @@ def get_module(self, module_name): if self.design_type not in ["EMIT"] and self.odesign: try: return self.odesign.GetModule(module_name) - except: + except Exception: return None return None diff --git a/pyaedt/application/design_solutions.py b/pyaedt/application/design_solutions.py index 2b2c72b195a..01a6d25183e 100644 --- a/pyaedt/application/design_solutions.py +++ b/pyaedt/application/design_solutions.py @@ -567,7 +567,7 @@ def solution_type(self): elif self._odesign: try: self._solution_type = self._odesign.GetSolutionType() - except: + except Exception: self._solution_type = solutions_defaults[self._design_type] elif self._solution_type is None: self._solution_type = solutions_defaults[self._design_type] @@ -587,7 +587,7 @@ def solution_type(self, value): elif self._odesign: try: self._solution_type = self._odesign.GetSolutionType() - except: + except Exception: self._solution_type = solutions_defaults[self._design_type] else: self._solution_type = solutions_defaults[self._design_type] @@ -601,7 +601,7 @@ def solution_type(self, value): else: try: self._odesign.SetSolutionType(self._solution_options[value]["name"]) - except: + except Exception: self._odesign.SetSolutionType(self._solution_options[value]["name"], "") @property @@ -653,7 +653,7 @@ def solution_type(self): self._solution_type = "Modal" elif "Terminal" in self._solution_type: self._solution_type = "Terminal" - except: + except Exception: self._solution_type = solutions_defaults[self._design_type] elif self._solution_type is None: self._solution_type = solutions_defaults[self._design_type] @@ -674,7 +674,7 @@ def solution_type(self, value): else: try: self._odesign.SetSolutionType(self._solution_options[value]["name"]) - except: + except Exception: self._odesign.SetSolutionType(self._solution_options[value]["name"], "") elif value is None: if self._odesign: @@ -684,7 +684,7 @@ def solution_type(self, value): self._solution_type = "Modal" elif "Terminal" in self._solution_type: self._solution_type = "Terminal" - except: + except Exception: self._solution_type = solutions_defaults[self._design_type] else: self._solution_type = solutions_defaults[self._design_type] @@ -710,7 +710,7 @@ def solution_type(self, value): else: try: self._odesign.SetSolutionType(self._solution_options[value]["name"]) - except: + except Exception: self._odesign.SetSolutionType(self._solution_options[value]["name"], "") @property @@ -812,7 +812,7 @@ def solution_type(self): if self._odesign and "GetSolutionType": try: self._solution_type = self._odesign.GetSolutionType() - except: + except Exception: self._solution_type = solutions_defaults[self._design_type] return self._solution_type @@ -843,7 +843,7 @@ def solution_type(self, value): else: opts = "" self._odesign.SetSolutionType(self._solution_options[self._solution_type]["name"], opts) - except: + except Exception: pass @@ -894,7 +894,7 @@ def solution_type(self): if self._odesign: try: self._solution_type = self._odesign.GetSolutionType() - except: + except Exception: self._solution_type = solutions_defaults[self._design_type] return self._solution_type @@ -921,7 +921,7 @@ def solution_type(self, solution_type): ] try: self._odesign.SetSolutionType(options) - except: + except Exception: pass @@ -942,7 +942,7 @@ def solution_type(self, solution_type): try: self._odesign.SetDesignFlow(self._design_type, solution_type) self._solution_type = solution_type - except: + except Exception: pass @property diff --git a/pyaedt/circuit.py b/pyaedt/circuit.py index a9b1ac80009..29c595b3336 100644 --- a/pyaedt/circuit.py +++ b/pyaedt/circuit.py @@ -160,7 +160,7 @@ def _get_number_from_string(self, stringval): try: float(value) return value - except: + except Exception: return from_rkm_to_aedt(value) @pyaedt_function_handler() @@ -211,7 +211,7 @@ def create_schematic_from_netlist(self, file_to_import): pval = param_re[1] self[ppar] = pval xpos = 0.0254 - except: + except Exception: pass elif ".model" in line[:7].lower() or ".lib" in line[:4].lower(): model.append(line) @@ -254,7 +254,7 @@ def create_schematic_from_netlist(self, file_to_import): if len(fields) > 4 and "=" not in fields[4]: try: float(fields[4]) - except: + except Exception: self.logger.warning( "Component {} was not imported. Check it and manually import".format(name) ) @@ -1428,12 +1428,12 @@ def set_differential_pair( try: os.remove(tmpfile1) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("ERROR: Cannot remove temp files.") try: self.odesign.SetDiffPairs(arg) - except: # pragma: no cover + except Exception: # pragma: no cover return False return True @@ -1471,7 +1471,7 @@ def load_diff_pairs_from_file(self, filename): self.odesign.LoadDiffPairsFromFile(new_file) os.remove(new_file) - except: # pragma: no cover + except Exception: # pragma: no cover return False return True @@ -1627,7 +1627,7 @@ def connect_circuit_models_from_multi_zone_cutout( if model1: try: pin1 = next(pin for pin in model1.pins if pin.name == connection[0][1]) - except: + except Exception: print("failed to get pin1") model2 = next( cmp for cmp in list(self.modeler.schematic.components.values()) if connection[1][0] in cmp.name @@ -1635,7 +1635,7 @@ def connect_circuit_models_from_multi_zone_cutout( if model2: try: pin2 = next(pin for pin in model2.pins if pin.name == connection[1][1]) - except: + except Exception: print("failed to get pin2") if pin1 and pin2: pin1.connect_to_component(component_pin=pin2, use_wire=False) @@ -1676,7 +1676,7 @@ def import_edb_in_circuit(self, edb_path): setup_override_name=hfss.setup_names[0], sweep_override_name=hfss.existing_analysis_sweeps[0].split(":")[1].strip(" "), ) - except: + except Exception: self.logger.error( "Failed to setup co-simulation settings, make sure the simulation setup is properly defined" ) diff --git a/pyaedt/common_rpc.py b/pyaedt/common_rpc.py index 6fad2d21a6c..59d9c9483cf 100644 --- a/pyaedt/common_rpc.py +++ b/pyaedt/common_rpc.py @@ -294,7 +294,7 @@ def create_session(server_name, client_port=None, launch_aedt_on_server=False, a if cl.aedt_port is None: cl.aedt_port = aedt_port return cl - except: + except Exception: msg = "Error. No connection exists." msg += " Check if pyaedt_service_manager is running and if the port number is correct." logger.error(msg) @@ -344,6 +344,6 @@ def connect(server_name, aedt_client_port): if not os.path.exists(settings.remote_rpc_session_temp_folder): os.makedirs(settings.remote_rpc_session_temp_folder) return client - except: + except Exception: logger.error("Error. No connection exists. Check if AEDT is running and if the port number is correct.") return False diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index 1e0f4bc856d..87ee60c209a 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -213,7 +213,7 @@ def _delete_objects(): pyaedt_logger.remove_all_project_file_logger() try: del sys.modules["glob"] - except: + except Exception: pass gc.collect() @@ -253,7 +253,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): if pid in v.parent_desktop_id: del v.parent_desktop_id[v.parent_desktop_id.index(pid)] return True - except: # pragma: no cover + except Exception: # pragma: no cover warnings.warn("Something went wrong closing AEDT. Exception in `_main.oDesktop.QuitApplication()`.") pass elif _desktop_sessions and len(_desktop_sessions) > 1 and not desktop_class.parent_desktop_id: @@ -266,7 +266,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): if pid in v.parent_desktop_id: del v.parent_desktop_id[v.parent_desktop_id.index(pid)] return True - except: # pragma: no cover + except Exception: # pragma: no cover warnings.warn("Something went wrong closing AEDT. Exception in `_main.oDesktop.QuitApplication()`.") pass elif _desktop_sessions and len(_desktop_sessions) > 1: @@ -280,7 +280,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): # import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper python_grpc_wrapper.AedtAPI.ReleaseAll() return True - except: # pragma: no cover + except Exception: # pragma: no cover warnings.warn( "Something went wrong releasing AEDT. Exception in `StandalonePyScriptWrapper.Release()`." ) @@ -289,7 +289,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): if close_desktop: try: os.kill(pid, 9) - except: # pragma: no cover + except Exception: # pragma: no cover warnings.warn("Something went wrong closing AEDT. Exception in `os.kill(pid, 9)`.") return False else: @@ -298,7 +298,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): while scopeID <= 5: desktop_class.COMUtil.ReleaseCOMObjectScope(desktop_class.COMUtil.PInvokeProxyAPI, scopeID) scopeID += 1 - except: + except Exception: pyaedt_logger.warning( "Something went wrong releasing AEDT. Exception in `_main.COMUtil.ReleaseCOMObjectScope`." ) @@ -312,7 +312,7 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): try: os.kill(pid, 9) return True - except: # pragma: no cover + except Exception: # pragma: no cover warnings.warn("Something went wrong closing AEDT. Exception in `os.kill(pid, 9)` after timeout.") return False break @@ -470,7 +470,7 @@ def __new__(cls, *args, **kwargs): pyaedt_logger.info("Returning found Desktop session with PID {}!".format(process_id)) cls._invoked_from_design = False return _desktop_sessions[sessions[0]] - except: + except Exception: del _desktop_sessions[sessions[0]] pyaedt_logger.info("Initializing new Desktop session.") return object.__new__(cls) @@ -610,7 +610,7 @@ def __init__( self.close_on_exit = False try: self.non_graphical = self.odesktop.GetIsNonGraphical() - except: # pragma: no cover + except Exception: # pragma: no cover self.non_graphical = non_graphical self.is_grpc_api = False @@ -722,7 +722,7 @@ def install_path(self): version_key = settings.aedt_version try: return installed_versions()[version_key] - except: # pragma: no cover + except Exception: # pragma: no cover return installed_versions()[version_key + "CL"] @property @@ -794,7 +794,7 @@ def _assert_version(self, specified_version, student_version): try: version = "Ansoft.ElectronicsDesktop." + settings.remote_rpc_session.aedt_version[0:6] return settings.remote_rpc_session.student_version, settings.remote_rpc_session.aedt_version, version - except: + except Exception: return False, "", "" return student_version, specified_version, version @@ -970,12 +970,12 @@ def _init_grpc(self, non_graphical, new_aedt_session, version, student_version, if not self.machine: try: self.machine = settings.remote_rpc_session.server_name - except: + except Exception: pass if not self.port: try: self.port = settings.remote_rpc_session.port - except: + except Exception: pass if not self.machine or self.machine in [ "localhost", @@ -1476,7 +1476,7 @@ def release_desktop(self, close_projects=True, close_on_exit=True): for project in projects: try: self.odesktop.CloseProject(project) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("Failed to close Project {}".format(project)) result = _close_aedt_application(self, close_on_exit, self.aedt_process_id, self.is_grpc_api) if not result: @@ -1560,7 +1560,7 @@ def change_license_type(self, license_type="Pool"): try: self.odesktop.SetRegistryString("Desktop/Settings/ProjectOptions/HPCLicenseType", license_type) return True - except: + except Exception: return False def change_registry_key(self, key_full_name, key_value): @@ -1583,7 +1583,7 @@ def change_registry_key(self, key_full_name, key_value): self.odesktop.SetRegistryString(key_full_name, key_value) self.logger.info("Key %s correctly changed.", key_full_name) return True - except: + except Exception: self.logger.warning("Error setting up Key %s.", key_full_name) return False elif isinstance(key_value, int): @@ -1591,7 +1591,7 @@ def change_registry_key(self, key_full_name, key_value): self.odesktop.SetRegistryInt(key_full_name, key_value) self.logger.info("Key %s correctly changed.", key_full_name) return True - except: + except Exception: self.logger.warning("Error setting up Key %s.", key_full_name) return False else: @@ -1619,7 +1619,7 @@ def change_active_dso_config_name(self, product_name="HFSS", config_name="Local" self.change_registry_key("Desktop/ActiveDSOConfigurations/{}".format(product_name), config_name) self.logger.info("Configuration Changed correctly to %s for %s.", config_name, product_name) return True - except: + except Exception: self.logger.warning("Error Setting Up Configuration %s for %s.", config_name, product_name) return False @@ -1654,7 +1654,7 @@ def change_registry_from_file(self, registry_file, make_active=True): if design_type and config_name: self.change_registry_key(design_type[1], config_name[1]) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -2050,7 +2050,7 @@ def submit_ansys_cloud_job( try: id = self.odesktop.SubmitJob(destination_reg, project_file)[0] return id, job_name - except: + except Exception: self.logger.error("Failed to submit job. check parameters and credentials and retry") return "", "" diff --git a/pyaedt/downloads.py b/pyaedt/downloads.py index b792d0ced57..1e6110f245f 100644 --- a/pyaedt/downloads.py +++ b/pyaedt/downloads.py @@ -130,7 +130,7 @@ def _retrieve_folder(url, directory, destination=None, local_paths=None): else: dir_folder = os.path.split(item["path"]) _download_file(dir_folder[0], dir_folder[1], destination, local_paths) - except: + except Exception: return False diff --git a/pyaedt/generic/DataHandlers.py b/pyaedt/generic/DataHandlers.py index cae4e1f943b..52410bcacb5 100644 --- a/pyaedt/generic/DataHandlers.py +++ b/pyaedt/generic/DataHandlers.py @@ -312,7 +312,7 @@ def unique_string_list(element_list, only_string=True): error_message = "Invalid list data" try: error_message += " {}".format(element_list) - except: + except Exception: pass raise Exception(error_message) @@ -627,7 +627,7 @@ def float_units(val_str, units=""): b = loc.span()[0] var = [float(val_str[0:b]), val_str[b:]] val = var[0] * unit_val[var[1]] - except: + except Exception: val = float(val_str) val = val / unit_val[units] diff --git a/pyaedt/generic/clr_module.py b/pyaedt/generic/clr_module.py index 553a5357710..78ee75095d5 100644 --- a/pyaedt/generic/clr_module.py +++ b/pyaedt/generic/clr_module.py @@ -18,7 +18,7 @@ import dotnet runtime = os.path.join(os.path.dirname(dotnet.__path__)) - except: + except Exception: import dotnetcore2 runtime = os.path.join(os.path.dirname(dotnetcore2.__file__), "bin") @@ -48,7 +48,7 @@ load("coreclr") is_clr = True - except: + except Exception: pass diff --git a/pyaedt/generic/filesystem.py b/pyaedt/generic/filesystem.py index 5f1af71b88b..d6fbc2f661c 100644 --- a/pyaedt/generic/filesystem.py +++ b/pyaedt/generic/filesystem.py @@ -54,7 +54,7 @@ def __init__(self, local_path, permission=0o777, volatile=False): if os.path.exists(self._scratch_path): try: self.remove() - except: + except Exception: self._cleaned = False if self._cleaned: try: @@ -68,7 +68,7 @@ def remove(self): try: # TODO check why on Anaconda 3.7 get errors with os.path.exists shutil.rmtree(self._scratch_path, ignore_errors=True) - except: + except Exception: pass def copyfile(self, src_file, dst_filename=None): diff --git a/pyaedt/generic/general_methods.py b/pyaedt/generic/general_methods.py index c01df453d4d..0d36228f1f5 100644 --- a/pyaedt/generic/general_methods.py +++ b/pyaedt/generic/general_methods.py @@ -154,7 +154,7 @@ def _exception(ex_info, func, args, kwargs, message="Type Error"): _write_mes("Method arguments: ") first_time_log = False _write_mes(" {} = {} ".format(el, args_dict[el])) - except: + except Exception: pass args = [func.__name__] + [i for i in args_name if i not in ["self"]] if not func.__name__.startswith("_"): @@ -756,7 +756,7 @@ def _retry_ntimes(n, function, *args, **kwargs): try: if function.__name__ == "InvokeAedtObjMethod": func_name = args[1] - except: + except Exception: pass retry = 0 ret_val = None @@ -775,7 +775,7 @@ def _retry_ntimes(n, function, *args, **kwargs): while retry < n: try: ret_val = function(*args, **kwargs) - except: + except Exception: retry += 1 time.sleep(settings.retry_n_times_time_interval) else: @@ -1194,7 +1194,7 @@ def write_configuration_file(dict_in, full_path): # if non_graphical and "-ng" in cmd or not non_graphical: # if not version or (version and version in cmd[0]): # sessions.append(p.pid) -# except: +# except Exception: # pass # return sessions # @@ -1240,7 +1240,7 @@ def write_configuration_file(dict_in, full_path): # except (IndexError, ValueError): # # default desktop grpc port. # sessions.append(50051) -# except: +# except Exception: # pass # return sessions # @@ -1302,7 +1302,7 @@ def write_configuration_file(dict_in, full_path): # -1, # ] # ) -# except: +# except Exception: # pass # return sessions @@ -1355,7 +1355,7 @@ def active_sessions(version=None, student_version=False, non_graphical=False): if i.pid == p.pid and (i.laddr.port > 50050 and i.laddr.port < 50200): return_dict[p.pid] = i.laddr.port break - except: + except Exception: pass return return_dict @@ -1914,7 +1914,7 @@ def _dim_arg(value, units): if isinstance(value, int): val = value return str(val) + units - except: + except Exception: return value @@ -1941,7 +1941,7 @@ def _check_installed_version(install_path, long_version): install_version = f.readline().strip()[-6:] if install_version == long_version: return True - except: + except Exception: pass return False diff --git a/pyaedt/generic/grpc_plugin.py b/pyaedt/generic/grpc_plugin.py index 036185dcc64..025e259651f 100644 --- a/pyaedt/generic/grpc_plugin.py +++ b/pyaedt/generic/grpc_plugin.py @@ -120,7 +120,7 @@ def __Invoke__(self, funcName, argv): return _retry_ntimes( settings.number_of_grpc_api_retries, AedtAPI.InvokeAedtObjMethod, self.objectID, funcName, argv ) # Call C function - except: # pragma: no cover + except Exception: # pragma: no cover raise GrpcApiError("Failed to execute grpc AEDT command: {}".format(funcName)) def __dir__(self): @@ -141,7 +141,7 @@ def __getattr__(self, funcName): if funcName == "ScopeID": # backward compatible for IronPython wrapper. return self.objectID return self.__GetObjMethod__(funcName) - except: + except Exception: raise GrpcApiError("Failed to get grpc API AEDT attribute {}".format(funcName)) def __setattr__(self, attrName, val): diff --git a/pyaedt/generic/ibis_reader.py b/pyaedt/generic/ibis_reader.py index e74cabbdc23..4a9b4a0f7ed 100644 --- a/pyaedt/generic/ibis_reader.py +++ b/pyaedt/generic/ibis_reader.py @@ -251,7 +251,7 @@ def add(self): [], ], ) - except: + except Exception: logger.error("Error adding {} pin component.".format(self.short_name)) return False diff --git a/pyaedt/generic/plot.py b/pyaedt/generic/plot.py index c0449af1e33..20556436c8d 100644 --- a/pyaedt/generic/plot.py +++ b/pyaedt/generic/plot.py @@ -43,7 +43,7 @@ "The Matplotlib module is required to run some functionalities of PostProcess.\n" "Install with \n\npip install matplotlib\n\nRequires CPython." ) - except: + except Exception: pass @@ -1369,7 +1369,7 @@ def _read_mesh_files(self, read_frames=False): lines = list(dict.fromkeys(lines)) # decimate = 2 # del lines[decimate - 1 :: decimate] - except: + except Exception: lines = [] for line in lines: tmp = line.strip().split(delimiter) @@ -1392,7 +1392,7 @@ def _read_mesh_files(self, read_frames=False): if nodes: try: conv = 1 / AEDT_UNITS["Length"][self.units] - except: + except Exception: conv = 1 vertices = np.array(nodes) * conv filedata = pv.PolyData(vertices) @@ -1453,7 +1453,7 @@ def __init__(self, plot, actor, axes_color): def __call__(self, state): try: self.plot.button_widgets = [self.plot.button_widgets[0]] - except: + except Exception: self.plot.button_widgets = [] self.id += 1 k = 0 @@ -1820,7 +1820,7 @@ def p_callback(): start = time.time() try: self.pv.update(1, force_redraw=True) - except: + except Exception: pass if self.gif_file: first_loop = True diff --git a/pyaedt/hfss.py b/pyaedt/hfss.py index 8b68f560eb9..fbd191c88f6 100644 --- a/pyaedt/hfss.py +++ b/pyaedt/hfss.py @@ -158,7 +158,7 @@ class Hfss(FieldAnalysis3D, object): # return "HFSS {} {}. ProjectName:{} DesignName:{} ".format( # self._aedt_version, self.solution_type, self.project_name, self.design_name # ) - # except: + # except Exception: # return "HFSS Module" def __init__( @@ -440,7 +440,7 @@ def _create_port_terminal( ] try: self.odesign.ChangeProperty(properties) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("Failed to change terminal impedance.") if not renorm: properties = [ @@ -456,7 +456,7 @@ def _create_port_terminal( ] try: self.odesign.ChangeProperty(properties) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("Failed to change normalization.") if terminals_rename: new_name = portname + "_T" + str(count) @@ -471,7 +471,7 @@ def _create_port_terminal( ] try: self.odesign.ChangeProperty(properties) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("Failed to rename terminal {}.".format(terminal)) bound = BoundaryObject(self, terminal_name, props_terminal, "Terminal") self._boundaries[terminal_name] = bound @@ -4126,7 +4126,7 @@ def thicken_port_sheets(self, inputlist, value, internalExtr=True, internalvalue # abs(faceoriginal[0] - fc2[0]) > tol and abs(faceoriginal[1] - fc2[1]) < tol and abs( # faceoriginal[2] - fc2[2]) < tol): # ports_ID[el] = int(f) - except: + except Exception: pass if internalExtr: objID2 = self.modeler.oeditor.GetFaceIDs(el) @@ -4155,7 +4155,7 @@ def thicken_port_sheets(self, inputlist, value, internalExtr=True, internalvalue ], ], ) - except: + except Exception: self.logger.info("done") # self.modeler_oproject.ClearMessages() return ports_ID @@ -5853,7 +5853,7 @@ def set_material_threshold(self, threshold=100000): try: self.odesign.SetSolveInsideThreshold(threshold) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -5910,7 +5910,7 @@ def assign_symmetry(self, entity_list, symmetry_name=None, is_perfect_e=True): props = OrderedDict({"Name": symmetry_name, "Faces": entity_list, "IsPerfectE": is_perfect_e}) return self._create_boundary(symmetry_name, props, "Symmetry") - except: + except Exception: return False @pyaedt_function_handler() @@ -5951,7 +5951,7 @@ def set_impedance_multiplier(self, multiplier): return False self.oboundary.ChangeImpedanceMult(multiplier) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -6010,7 +6010,7 @@ def set_phase_center_per_port(self, coordinate_system=None): try: self.oboundary.SetPhaseCenterPerPort(arg) - except: + except Exception: return False return True @@ -6432,7 +6432,7 @@ def wave_port( # the name of the 3d object is returned. # TODO: Need to improve the way a FacePrimitive is handled. oname = self.modeler.oeditor.GetObjectNameByFaceID(sheet_name) - except: + except Exception: oname = "" if reference: reference = self.modeler.convert_to_selections(reference, True) diff --git a/pyaedt/hfss3dlayout.py b/pyaedt/hfss3dlayout.py index fd8adb2738b..5b4add8890c 100644 --- a/pyaedt/hfss3dlayout.py +++ b/pyaedt/hfss3dlayout.py @@ -1666,12 +1666,12 @@ def set_differential_pair( try: os.remove(tmpfile1) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("ERROR: Cannot remove temp files.") try: self.oexcitation.SetDiffPairs(arg) - except: # pragma: no cover + except Exception: # pragma: no cover return False return True @@ -1709,7 +1709,7 @@ def get_differential_pairs(self): try: os.remove(tmpfile1) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("ERROR: Cannot remove temp files.") return list_output @@ -1750,7 +1750,7 @@ def load_diff_pairs_from_file(self, filename): self.oexcitation.LoadDiffPairsFromFile(new_file) os.remove(new_file) - except: # pragma: no cover + except Exception: # pragma: no cover return False return True @@ -2254,7 +2254,7 @@ def show_extent(self, show=True): try: self.oeditor.SetHfssExtentsVisible(show) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -2287,5 +2287,5 @@ def change_options(self, color_by_net=True): oeditor = self.odesign.SetActiveEditor("Layout") oeditor.ChangeOptions(options) return True - except: + except Exception: return False diff --git a/pyaedt/icepak.py b/pyaedt/icepak.py index 626d01ec959..1e53b66e877 100644 --- a/pyaedt/icepak.py +++ b/pyaedt/icepak.py @@ -1089,7 +1089,7 @@ def assign_block_from_sherlock_file(self, csv_name): ) else: total_power += float(power) - except: + except Exception: pass i += 1 self.logger.info("Blocks inserted with total power %sW.", total_power) @@ -3183,7 +3183,7 @@ def assign_surface_material(self, obj, mat): ], ] ) - except: + except Exception: self.logger.warning("Warning. The material is not the database. Use add_surface_material.") return False if mat.lower() not in self.materials.surface_material_keys: diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index 1ed386e981e..d4e5e0606ea 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -1482,7 +1482,7 @@ def assign_symmetry(self, entity_list, symmetry_name=None, is_odd=True): self._boundaries[bound.name] = bound return bound return True - except: + except Exception: return False @pyaedt_function_handler() @@ -1614,7 +1614,7 @@ def assign_current_density( self._boundaries[bound.name] = bound return bound return True - except: + except Exception: self.logger.error("Couldn't assign current density to desired list of objects.") return False else: @@ -2302,7 +2302,7 @@ def assign_current_density_terminal(self, entities, current_density_name=None): self._boundaries[bound.name] = bound return bound return False - except: + except Exception: return False else: self.logger.error("Current density can only be applied to Eddy current or magnetostatic solution types.") @@ -2355,7 +2355,7 @@ def get_conduction_paths(self): for path in paths: conduction_paths[path] = list(self.oboundary.GetConductionPathObjects(path)) return conduction_paths - except: + except Exception: return conduction_paths @pyaedt_function_handler() @@ -2478,7 +2478,7 @@ def assign_master_slave( return bound, bound2 else: return bound, False - except: + except Exception: return False, False @pyaedt_function_handler diff --git a/pyaedt/maxwellcircuit.py b/pyaedt/maxwellcircuit.py index 105a9470f51..c5abfa9efcb 100644 --- a/pyaedt/maxwellcircuit.py +++ b/pyaedt/maxwellcircuit.py @@ -203,5 +203,5 @@ def export_netlist_from_schematic(self, file_to_export): try: self.odesign.ExportNetlist("", file_to_export) return file_to_export - except: + except Exception: return False diff --git a/pyaedt/misc/aedtlib_personalib_install.py b/pyaedt/misc/aedtlib_personalib_install.py index ccf718acb2a..2eb3b9740c6 100644 --- a/pyaedt/misc/aedtlib_personalib_install.py +++ b/pyaedt/misc/aedtlib_personalib_install.py @@ -95,7 +95,7 @@ def add_pyaedt_to_aedt( if pid and new_desktop_session: try: os.kill(pid, 9) - except: + except Exception: pass toolkits = ["Project"] diff --git a/pyaedt/misc/misc.py b/pyaedt/misc/misc.py index 9bdcb6a6072..e3668e7865c 100644 --- a/pyaedt/misc/misc.py +++ b/pyaedt/misc/misc.py @@ -56,7 +56,7 @@ def installed_versions(): else: v_key = "20{0}.{1}".format(version, release) return_dict[v_key] = os.environ[version_env_var] - except: # pragma: no cover + except Exception: # pragma: no cover pass return return_dict diff --git a/pyaedt/modeler/cad/Modeler.py b/pyaedt/modeler/cad/Modeler.py index 8883b46e315..56622395c8d 100644 --- a/pyaedt/modeler/cad/Modeler.py +++ b/pyaedt/modeler/cad/Modeler.py @@ -280,7 +280,7 @@ def _get_coordinates_data(self): props = iop["ObjectCSParameters"] self._props = CsProps(self, props) break - except: + except Exception: pass @pyaedt_function_handler() @@ -383,7 +383,7 @@ def delete(self): if cs.name not in coordinate_systems: self._modeler.coordinate_systems.pop(self._modeler.coordinate_systems.index(cs)) self._modeler.cleanup_objects() - except: + except Exception: self._modeler._app.logger.warning("Coordinate system does not exist") return True @@ -413,7 +413,7 @@ def __init__(self, modeler, props=None, name=None, face_id=None): try: # pragma: no cover if "KernelVersion" in self.props: del self.props["KernelVersion"] - except: + except Exception: pass @property @@ -639,7 +639,7 @@ def update(self): self._change_property( self.name, ["NAME:ChangedProps", ["NAME:Z Rotation angle", "Value:=", self.props["ZRotationAngle"]]] ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("'Z Rotation angle' parameter must be a string in the format '10deg'") try: @@ -650,12 +650,12 @@ def update(self): ["NAME:Position Offset XY", "X:=", self.props["XOffset"], "Y:=", self.props["YOffset"]], ], ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("'XOffset' and 'YOffset' parameters must be a string in the format '1.3mm'") try: self._change_property(self.name, ["NAME:ChangedProps", ["NAME:Axis", "Value:=", self.props["WhichAxis"]]]) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("'WhichAxis' parameter must be either 'X' or 'Y'") return True @@ -684,7 +684,7 @@ def __init__(self, modeler, props=None, name=None): try: # pragma: no cover if "KernelVersion" in self.props: del self.props["KernelVersion"] - except: + except Exception: pass self._ref_cs = None self._quaternion = None @@ -702,7 +702,7 @@ def mode(self): self._mode = "zxz" elif "ZYZ" in self.props["Mode"]: self._mode = "zyz" - except: + except Exception: pass return self._mode @@ -746,7 +746,7 @@ def ref_cs(self, value): try: obj1.SetPropValue("Reference CS", value) self._ref_cs = value - except: + except Exception: self._modeler.logger.error("Failed to set Coordinate CS Reference.") @pyaedt_function_handler() @@ -763,7 +763,7 @@ def update(self): try: self._change_property(self.name, ["NAME:ChangedProps", ["NAME:Mode", "Value:=", self.props["Mode"]]]) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError( "Mode must be 'Axis/Position', 'Euler Angle ZYZ' or 'Euler Angle ZXZ', not {}.".format( self.props["Mode"] @@ -1218,7 +1218,7 @@ def __init__(self, modeler, props=None, name=None, entity_id=None): try: # pragma: no cover if "KernelVersion" in self.props: del self.props["KernelVersion"] - except: + except Exception: pass self._ref_cs = None @@ -1245,7 +1245,7 @@ def ref_cs(self, value): try: obj1.SetPropValue("Reference CS", value) self._ref_cs = value - except: + except Exception: self._modeler.logger.error("Failed to set Coordinate CS Reference.") @property @@ -1543,28 +1543,28 @@ def update(self): ["NAME:Reference CS", "Value:=", self.ref_cs], ], ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update of property reference coordinate system failed.") try: self._change_property( self.name, ["NAME:ChangedProps", ["NAME:Always Move CS To End", "Value:=", self.props["MoveToEnd"]]] ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update of property move to end failed.") try: self._change_property( self.name, ["NAME:ChangedProps", ["NAME:Reverse X Axis", "Value:=", self.props["ReverseXAxis"]]] ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update of property reverse x axis failed.") try: self._change_property( self.name, ["NAME:ChangedProps", ["NAME:Reverse Y Axis", "Value:=", self.props["ReverseYAxis"]]] ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update of property reverse y axis failed.") if self.props["Origin"]["PositionType"] == "AbsolutePosition": @@ -1587,7 +1587,7 @@ def update(self): ], ], ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update origin properties failed.") if "xAxis" in self.props: @@ -1610,7 +1610,7 @@ def update(self): ], ], ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update x axis properties failed.") if "yAxis" in self.props: @@ -1633,7 +1633,7 @@ def update(self): ], ], ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Update y axis properties failed.") return True @@ -1658,7 +1658,7 @@ def _get_type_from_id(self, obj_id): def _position_parser(self, pos): try: return self._dim_arg(float(pos), self.model_units) - except: + except Exception: return pos @@ -1706,7 +1706,7 @@ def update(self): ] try: self._modeler.oeditor.EditEntityList(argument1, argument2) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Input List not correct for the type " + self.props["Type"]) return True diff --git a/pyaedt/modeler/cad/Primitives.py b/pyaedt/modeler/cad/Primitives.py index 343e5f83db5..0886b74ae9d 100644 --- a/pyaedt/modeler/cad/Primitives.py +++ b/pyaedt/modeler/cad/Primitives.py @@ -273,28 +273,28 @@ def __init__(self, *args): if len(args) == 1 and type(args[0]) is list: try: self.X = args[0][0] - except: + except Exception: self.X = 0 try: self.Y = args[0][1] - except: + except Exception: self.Y = 0 try: self.Z = args[0][2] - except: + except Exception: self.Z = 0 else: try: self.X = args[0] - except: + except Exception: self.X = 0 try: self.Y = args[1] - except: + except Exception: self.Y = 0 try: self.Z = args[2] - except: + except Exception: self.Z = 0 class SweepOptions(object): @@ -444,7 +444,7 @@ def dimension(self): return "2D" else: return "3D" - except: + except Exception: if self.design_type == "2D Extractor": return "2D" else: @@ -655,7 +655,7 @@ def user_defined_component_names(self): if "UserDefinedModels" in self.oeditor.GetChildTypes(): try: udm = list(self.oeditor.GetChildNames("UserDefinedModels")) - except: # pragma: no cover + except Exception: # pragma: no cover udm = [] obs3d = list(set(udm + obs3d)) new_obs3d = copy.deepcopy(obs3d) @@ -787,7 +787,7 @@ def refresh(self): def _get_commands(self, name): try: return self.oeditor.GetChildObject(name).GetChildNames() - except: + except Exception: return [] @pyaedt_function_handler() @@ -846,12 +846,12 @@ def _refresh_all_ids_from_aedt_file(self): if operations and isinstance(operations.get("Operation", None), (OrderedDict, dict)): try: pid = operations["Operation"]["ParentPartID"] - except: # pragma: no cover + except Exception: # pragma: no cover pass elif operations and isinstance(operations.get("Operation", None), list): try: pid = operations["Operation"][0]["ParentPartID"] - except: + except Exception: pass is_polyline = False @@ -876,7 +876,7 @@ def _refresh_all_ids_from_aedt_file(self): o._m_groupName = groupname try: o._color = tuple(int(x) for x in attribs["Color"][1:-1].split(" ")) - except: + except Exception: o._color = None o._surface_material = attribs.get("SurfaceMaterialValue", None) if o._surface_material: @@ -1010,7 +1010,7 @@ def add_new_solids(self): if obj_name not in self._object_names_to_ids: try: pid = self.oeditor.GetObjectIDByName(obj) - except: + except Exception: pid = 0 self._create_object(obj_name, pid=pid, use_cached=True) added_objects.append(obj_name) @@ -1018,7 +1018,7 @@ def add_new_solids(self): if obj_name not in self._object_names_to_ids: try: pid = self.oeditor.GetObjectIDByName(obj) - except: + except Exception: pid = 0 self._create_object(obj_name, pid=pid, use_cached=True) added_objects.append(obj_name) @@ -1230,13 +1230,13 @@ def _get_coordinates_data(self): # pragma: no cover props = iop["FaceCSParameters"] coord.append(FaceCoordinateSystem(self, props, name)) break - except: + except Exception: pass for cs in coord: if isinstance(cs, CoordinateSystem): try: cs._ref_cs = id2name[name2refid[cs.name]] - except: + except Exception: pass coord.reverse() return coord @@ -1274,7 +1274,7 @@ def _get_lists_data(self): else: props["List"] = data["GeometryEntityListParameters"]["EntityList"] design_lists.append(Lists(self, props, name)) - except: + except Exception: self.logger.info("Lists were not retrieved from AEDT file") return design_lists @@ -1670,7 +1670,7 @@ def global_to_cs(self, point, ref_cs): raise AttributeError("Point must be in format [x, y, z].") try: point = [float(i) for i in point] - except: + except Exception: raise AttributeError("Point must be in format [x, y, z].") if isinstance(ref_cs, BaseCoordinateSystem): ref_cs_name = ref_cs.name @@ -2011,7 +2011,7 @@ def set_objects_deformation(self, objects): self.logger.info("Enabling deformation feedback") try: self._odesign.SetObjectDeformation(["EnabledObjects:=", objects]) - except: + except Exception: self.logger.error("Failed to enable the deformation dependence") return False else: @@ -2071,7 +2071,7 @@ def set_objects_temperature(self, objects, ambient_temp=22, create_project_var=F vargs1.append(vargs2) try: self._odesign.SetObjectTemperature(vargs1) - except: + except Exception: self.logger.error("Failed to enable the temperature dependence") return False else: @@ -2298,7 +2298,7 @@ def _get_faceid_on_axis(self, objname, axisdir): elif axisdir > 2 and c[axisdir - 3] > center[axisdir - 3]: face = f center = c - except: + except Exception: pass return face @@ -3270,7 +3270,7 @@ def separate_bodies(self, object_list, create_group=False): if obj.name == new_obj: new_objects_list.append(obj) return new_objects_list - except: + except Exception: return False @pyaedt_function_handler() @@ -3734,7 +3734,7 @@ def connect(self, theList): if obj.name == sel ] return objects_list_after_connection - except: + except Exception: return False @pyaedt_function_handler() @@ -3854,7 +3854,7 @@ def check_plane(self, obj, faceposition, offset=1): else: plane = "YZ" found = True - except: + except Exception: i = i + 1 if i > 11: found = True @@ -4413,7 +4413,7 @@ def get_line_ids(self): # TODO Problem with GetObjectIDByName try: line_ids[line_object] = str(self.oeditor.GetObjectIDByName(line_object)) - except: + except Exception: self.logger.warning("Line {} has an invalid ID!".format(line_object)) return line_ids @@ -4463,7 +4463,7 @@ def get_object_name_from_edge_id(self, edge_id): oEdgeIDs = self.oeditor.GetEdgeIDsFromObject(object) if str(edge_id) in oEdgeIDs: return object - except: + except Exception: return False return False @@ -5158,7 +5158,7 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal ], ], ) - except: + except Exception: self.logger.info("done") # self.modeler_oproject.ClearMessages() return True @@ -5740,7 +5740,7 @@ def simplify_objects( try: self.oeditor.Simplify(selections_args, simplify_parameters, groups_for_new_object) return True - except: + except Exception: self.logger.error("Simplify objects failed.") return False @@ -6800,7 +6800,7 @@ def delete(self, objects=None): arg = ["NAME:Selections", "Selections:=", objects_str] try: self.oeditor.Delete(arg) - except: + except Exception: self.logger.warning("Failed to delete {}.".format(objects_str)) remaining -= slice if remaining > 0: @@ -7303,7 +7303,7 @@ def get_face_vertices(self, face_id): """ try: oVertexIDs = self.oeditor.GetVertexIDsFromFace(face_id) - except: + except Exception: oVertexIDs = [] else: oVertexIDs = [int(i) for i in oVertexIDs] @@ -7356,7 +7356,7 @@ def get_edge_vertices(self, edgeID): """ try: oVertexIDs = self.oeditor.GetVertexIDsFromEdge(edgeID) - except: + except Exception: oVertexIDs = [] else: oVertexIDs = [int(i) for i in oVertexIDs] @@ -7384,7 +7384,7 @@ def get_vertex_position(self, vertex_id): """ try: pos = self.oeditor.GetVertexPosition(vertex_id) - except: + except Exception: position = [] else: position = [float(i) for i in pos] @@ -7437,7 +7437,7 @@ def get_face_center(self, face_id): """ try: c = self.oeditor.GetFaceCenter(face_id) - except: + except Exception: self.logger.warning("Non Planar Faces doesn't provide any Face Center") return False center = [float(i) for i in c] @@ -7500,7 +7500,7 @@ def get_edge_midpoint(self, partID): else: try: vertices = self.get_edge_vertices(partID) - except: + except Exception: vertices = [] if len(vertices) == 2: vertex1 = self.get_vertex_position(vertices[0]) @@ -7589,7 +7589,7 @@ def get_edgeid_from_position(self, position, obj_name=None, units=None): try: edgeID = int(self.oeditor.GetEdgeByPosition(vArg1)) return edgeID - except: + except Exception: pass @pyaedt_function_handler() @@ -7666,7 +7666,7 @@ def get_faceid_from_position(self, position, obj_name=None, units=None): try: face_id = self.oeditor.GetFaceByPosition(vArg1) return face_id - except: + except Exception: # Not Found, keep looking pass @@ -8276,7 +8276,7 @@ def _create_object(self, name, pid=0, use_cached=False, is_polyline=False, **kwa if k in props: # Only try to set valid properties. try: setattr(o, k, val) - except: + except Exception: self.logger.warning("Unable to assign " + str(k) + " to object " + o.name + ".") else: self.logger.error("'" + str(k) + "' is not a valid property of the primitive ") @@ -8295,7 +8295,7 @@ def _default_object_attributes(self, name=None, matname=None, flags=""): name = _uname() try: color = str(tuple(self._app.materials.material_keys[material].material_appearance)).replace(",", " ") - except: + except Exception: color = "(132 132 193)" if material in ["vacuum", "air", "glass", "water_distilled", "water_fresh", "water_sea"]: transparency = 0.8 @@ -8388,7 +8388,7 @@ def _arg_with_dim(self, value, units=None): try: float(value) val = "{0}{1}".format(value, units) - except: + except Exception: val = value else: val = "{0}{1}".format(value, units) @@ -8481,7 +8481,7 @@ def _get_native_component_properties(self, name): if native_comp_name == component_name: native_comp_properties = data break - except: + except Exception: return native_comp_properties return native_comp_properties diff --git a/pyaedt/modeler/cad/Primitives3D.py b/pyaedt/modeler/cad/Primitives3D.py index 1e56c708362..c48a057d16c 100644 --- a/pyaedt/modeler/cad/Primitives3D.py +++ b/pyaedt/modeler/cad/Primitives3D.py @@ -2954,7 +2954,7 @@ def check_choke_values(self, json_file, create_another_file=True): core_name = str(values["Core"]["Name"]) if len(core_name) > 0: values["Core"]["Name"] = core_name - except: + except Exception: self.logger.warning("Core Name must be a non-null string. A default name Core has been set.") values["Core"]["Name"] = "Core" @@ -2969,7 +2969,7 @@ def check_choke_values(self, json_file, create_another_file=True): " It can be add using the method add_material" % core_material ) values["Core"]["Material"] = "ferrite" - except: + except Exception: self.logger.warning("Core Material must be a non-null string. A default material Core has been set.") values["Core"]["Material"] = "ferrite" @@ -2977,7 +2977,7 @@ def check_choke_values(self, json_file, create_another_file=True): winding_name = str(values["Outer Winding"]["Name"]) if len(winding_name) > 0: values["Outer Winding"]["Name"] = winding_name - except: + except Exception: self.logger.warning("Outer Winding Name must be a non-null string. A default name Winding has been set.") values["Outer Winding"]["Name"] = "Winding" @@ -2992,7 +2992,7 @@ def check_choke_values(self, json_file, create_another_file=True): " It can be add using the method add_material" % winding_material ) values["Outer Winding"]["Material"] = "copper" - except: + except Exception: self.logger.warning( "Outer Winding Material must be a non-null string." " A default material Winding has been set." ) @@ -3024,7 +3024,7 @@ def check_choke_values(self, json_file, create_another_file=True): "The character entered is invalid. Chamfer must be a positive float." " It must be changed" ) are_inequations_checkable = False - except: + except Exception: self.logger.error( "The character entered is invalid. Chamfer must be a positive float." " It must be changed" ) @@ -3309,7 +3309,7 @@ def _check_value_type(self, taken_value, value_type, are_inequations_checkable, + ". It must be changed" ) are_inequations_checkable = False - except: + except Exception: receiving_variable = None self.logger.error( "The character entered is invalid. " @@ -3331,7 +3331,7 @@ def _check_value_type(self, taken_value, value_type, are_inequations_checkable, + ". It must be changed" ) are_inequations_checkable = False - except: + except Exception: receiving_variable = None self.logger.error( "The character entered is invalid. " diff --git a/pyaedt/modeler/cad/components_3d.py b/pyaedt/modeler/cad/components_3d.py index 7df24b8429b..89fe4271804 100644 --- a/pyaedt/modeler/cad/components_3d.py +++ b/pyaedt/modeler/cad/components_3d.py @@ -27,7 +27,7 @@ def __setitem__(self, key, value): ] ) dict.__setitem__(self, key, value) - except: + except Exception: self._component._logger.warning("Property %s has not been edited.Check if readonly", key) def __init__(self, component, *args, **kw): @@ -205,7 +205,7 @@ def history(self): try: child_object = self._primitives.oeditor.GetChildObject(self.name) return BinaryTreeNode(list(child_object.GetChildNames("Operations"))[0], child_object, True, "Operations") - except: + except Exception: return False @property diff --git a/pyaedt/modeler/cad/elements3d.py b/pyaedt/modeler/cad/elements3d.py index 82282569e4b..577aa1940bc 100644 --- a/pyaedt/modeler/cad/elements3d.py +++ b/pyaedt/modeler/cad/elements3d.py @@ -270,7 +270,7 @@ def segment_info(self): autosave = self._object3d._primitives._app.odesktop.GetAutosaveEnabled() try: self.oeditor.GetChildNames() - except: # pragma: no cover + except Exception: # pragma: no cover return {} self._object3d._primitives._app.autosave_disable() ll = list(self.oeditor.GetObjectsInGroup("Lines")) @@ -363,7 +363,7 @@ def length(self): """ try: return float(self.oeditor.GetEdgeLength(self.id)) - except: + except Exception: return False def __str__(self): @@ -518,7 +518,7 @@ def vertices(self): vertices = [] try: v = [i for i in self.oeditor.GetVertexIDsFromFace(self.id)] - except: + except Exception: v = [] if not v: for el in self.edges: @@ -553,7 +553,7 @@ def center_from_aedt(self): """ try: c = self.oeditor.GetFaceCenter(self.id) - except: + except Exception: self.logger.warning("Non-planar face does not provide a face center.") return False center = [float(i) for i in c] @@ -573,7 +573,7 @@ def is_planar(self): self.oeditor.GetFaceCenter(self.id) self._is_planar = True return True - except: + except Exception: self.logger.clear_messages() self._is_planar = False return False @@ -662,7 +662,7 @@ def top_edge_z(self): result = [(float(edge.midpoint[2]), edge) for edge in self.edges] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -678,7 +678,7 @@ def bottom_edge_z(self): result = [(float(edge.midpoint[2]), edge) for edge in self.edges] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -694,7 +694,7 @@ def top_edge_x(self): result = [(float(edge.midpoint[0]), edge) for edge in self.edges] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -710,7 +710,7 @@ def bottom_edge_x(self): result = [(float(edge.midpoint[0]), edge) for edge in self.edges] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -726,7 +726,7 @@ def top_edge_y(self): result = [(float(edge.midpoint[1]), edge) for edge in self.edges] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -742,7 +742,7 @@ def bottom_edge_y(self): result = [(float(edge.midpoint[1]), edge) for edge in self.edges] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @pyaedt_function_handler() @@ -1405,7 +1405,7 @@ def __init__(self, node, child_object, first_level=False, get_child_obj_arg=None for p in self.child_object.GetPropNames(): try: self.props[p] = self.child_object.GetPropValue(p) - except: + except Exception: self.props[p] = None self.props = HistoryProps(self, self.props) self.command = self.props.get("Command", "") @@ -1428,7 +1428,7 @@ def update_property(self, prop_name, prop_value): try: self.child_object.SetPropValue(prop_name, prop_value) return True - except: # pragma: no cover + except Exception: # pragma: no cover return False @pyaedt_function_handler diff --git a/pyaedt/modeler/cad/object3d.py b/pyaedt/modeler/cad/object3d.py index da0f3420f36..7753901dfd3 100644 --- a/pyaedt/modeler/cad/object3d.py +++ b/pyaedt/modeler/cad/object3d.py @@ -161,7 +161,7 @@ def _bounding_box_sat(self): try: for i in range(1, 7): bb.append(float(m.group(i))) - except: + except Exception: return False else: return False @@ -170,7 +170,7 @@ def _bounding_box_sat(self): try: os.remove(filename) - except: + except Exception: self.logger.warning("ERROR: Cannot remove temp file.") return bb @@ -498,7 +498,7 @@ def top_face_z(self): result = [(float(face.center[2]), face) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -519,7 +519,7 @@ def bottom_face_z(self): result = [(float(face.center[2]), face) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -540,7 +540,7 @@ def top_face_x(self): result = [(float(face.center[0]), face) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -561,7 +561,7 @@ def bottom_face_x(self): result = [(float(face.center[0]), face) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -582,7 +582,7 @@ def top_face_y(self): result = [(float(face.center[1]), face) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -603,7 +603,7 @@ def bottom_face_y(self): result = [(float(face.center[1]), face) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -624,7 +624,7 @@ def top_edge_z(self): result = [(float(face.top_edge_z.midpoint[2]), face.top_edge_z) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -640,7 +640,7 @@ def bottom_edge_z(self): result = [(float(face.bottom_edge_z.midpoint[2]), face.bottom_edge_z) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -656,7 +656,7 @@ def top_edge_x(self): result = [(float(face.top_edge_x.midpoint[0]), face.top_edge_x) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -672,7 +672,7 @@ def bottom_edge_x(self): result = [(float(face.bottom_edge_x.midpoint[0]), face.bottom_edge_x) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -688,7 +688,7 @@ def top_edge_y(self): result = [(float(face.top_edge_y.midpoint[1]), face.top_edge_y) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[-1][1] - except: + except Exception: return None @property @@ -704,7 +704,7 @@ def bottom_edge_y(self): result = [(float(face.bottom_edge_y.midpoint[1]), face.bottom_edge_y) for face in self.faces] result = sorted(result, key=lambda tup: tup[0]) return result[0][1] - except: + except Exception: return None @property @@ -936,7 +936,7 @@ def surface_material_name(self, mat): vMaterial = ["NAME:Surface Material", "Value:=", '"' + mat + '"'] self._change_property(vMaterial) self._surface_material = mat - except: + except Exception: self.logger.warning("Material %s does not exist", mat) @property @@ -957,7 +957,7 @@ def id(self): if not self._id: try: self._id = self._primitives.oeditor.GetObjectIDByName(self._m_name) - except: + except Exception: return None return self._id @@ -1195,7 +1195,7 @@ def transparency(self): transp = self._oeditor.GetPropertyValue("Geometry3DAttributeTab", self._m_name, "Transparent") try: self._transparency = float(transp) - except: + except Exception: self._transparency = 0.3 return self._transparency @@ -1339,7 +1339,7 @@ def history(self): child_object = self._oeditor.GetChildObject(self.name) parent = BinaryTreeNode(self.name, child_object, True) return parent - except: + except Exception: return False @property diff --git a/pyaedt/modeler/cad/polylines.py b/pyaedt/modeler/cad/polylines.py index 7018f40dcc5..ac22aa2b203 100644 --- a/pyaedt/modeler/cad/polylines.py +++ b/pyaedt/modeler/cad/polylines.py @@ -387,7 +387,7 @@ def _convert_points(p_in, dest_unit): try: history = self.history() h_segments = history.segments - except: # pragma: no cover + except Exception: # pragma: no cover history = None h_segments = None if h_segments: @@ -809,7 +809,7 @@ def remove_point(self, position, abstol=1e-9): at_start, ] ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Invalid edge ID {} is specified on polyline {}.".format(seg_id, self.name)) else: i_start, i_end = self._get_point_slice_from_segment_id(seg_id, at_start) @@ -873,7 +873,7 @@ def remove_segments(self, segment_id): True, ] ) - except: # pragma: no cover + except Exception: # pragma: no cover raise ValueError("Invalid segment ID {} is specified on polyline {}.".format(segment_id, self.name)) else: segment_id.reverse() diff --git a/pyaedt/modeler/circuits/PrimitivesCircuit.py b/pyaedt/modeler/circuits/PrimitivesCircuit.py index 6548ebeae57..d8639bf017a 100644 --- a/pyaedt/modeler/circuits/PrimitivesCircuit.py +++ b/pyaedt/modeler/circuits/PrimitivesCircuit.py @@ -1210,7 +1210,7 @@ def create_wire(self, points_array, wire_name=""): w.id = int(wire_id) self.wires[w.id] = w return w - except: + except Exception: return False diff --git a/pyaedt/modeler/circuits/object3dcircuit.py b/pyaedt/modeler/circuits/object3dcircuit.py index 29bc419c2e4..d93f50df5ac 100644 --- a/pyaedt/modeler/circuits/object3dcircuit.py +++ b/pyaedt/modeler/circuits/object3dcircuit.py @@ -256,7 +256,7 @@ def connect_to_component(self, component_pin, page_name=None, use_wire=False, wi if "Port" in self._circuit_comp.composed_name: try: page_name = self._circuit_comp.name.split("@")[1].replace(";", "_") - except: + except Exception: pass else: for cmp in component_pin: @@ -264,13 +264,13 @@ def connect_to_component(self, component_pin, page_name=None, use_wire=False, wi try: page_name = cmp._circuit_comp.name.split("@")[1].replace(";", "_") break - except: + except Exception: continue try: x_loc = AEDT_UNITS["Length"][decompose_variable_value(self._circuit_comp.location[0])[1]] * float( decompose_variable_value(self._circuit_comp.location[1])[0] ) - except: + except Exception: x_loc = float(self._circuit_comp.location[0]) if self.location[0] < x_loc: angle = comp_angle @@ -282,7 +282,7 @@ def connect_to_component(self, component_pin, page_name=None, use_wire=False, wi x_loc = AEDT_UNITS["Length"][decompose_variable_value(cmp._circuit_comp.location[0])[1]] * float( decompose_variable_value(cmp._circuit_comp.location[0])[0] ) - except: + except Exception: x_loc = float(cmp._circuit_comp.location[0]) comp_pin_angle = cmp._circuit_comp.angle * math.pi / 180 if len(cmp._circuit_comp.pins) == 2: @@ -333,7 +333,7 @@ def __setitem__(self, key, value): "Property %s has not been edited.Check if readonly", key ) dict.__setitem__(self, key, value) - except: + except Exception: self._component._circuit_components.logger.warning( "Property %s has not been edited. Check if read-only.", key ) @@ -341,7 +341,7 @@ def __setitem__(self, key, value): try: self._component._oeditor.SetPropertyValue(self._tab, self._component.composed_name, key, str(value)) dict.__setitem__(self, key, value) - except: + except Exception: self._component._circuit_components.logger.warning( "Property %s has not been edited.Check if readonly", key ) @@ -369,7 +369,7 @@ def update(self): _dict2arg(self.props, arg) self._component._circuit_components.o_model_manager.EditWithComps(self.name, arg, []) return True - except: + except Exception: self._component._circuit_components.logger.warning("Failed to update model %s ", self.name) return False @@ -434,7 +434,7 @@ def refdes(self): """Reference designator.""" try: return self._oeditor.GetPropertyValue("Component", self.composed_name, "RefDes") - except: + except Exception: return "" @property @@ -447,7 +447,7 @@ def _property_data(self): """Property Data List.""" try: return list(self._circuit_components.o_component_manager.GetData(self.name.split("@")[1])) - except: + except Exception: return [] @property @@ -499,7 +499,7 @@ def parameters(self): tab = "Quantities" try: proparray = self._oeditor.GetProperties(tab, self.composed_name) - except: + except Exception: proparray = [] for j in proparray: @@ -605,7 +605,7 @@ def location(self): self._location = [ round(i[0] * AEDT_UNITS["Length"][i[1]] / AEDT_UNITS["Length"][self.units], 10) for i in loc ] - except: + except Exception: self._location = [] return self._location @@ -688,7 +688,7 @@ def mirror(self): self._mirror = ( self._oeditor.GetPropertyValue("BaseElementTab", self.composed_name, "Component Mirror") == "true" ) - except: + except Exception: self._mirror = False return self._mirror diff --git a/pyaedt/modeler/modeler3d.py b/pyaedt/modeler/modeler3d.py index a80ad83d5be..0830c547e29 100644 --- a/pyaedt/modeler/modeler3d.py +++ b/pyaedt/modeler/modeler3d.py @@ -274,7 +274,7 @@ def create_3dcomponent( meshregions = [mr.name for mr in self._app.mesh.meshregions] try: meshregions.remove("Global") - except: + except Exception: pass if meshregions: arg2.append("MeshRegions:="), arg2.append(meshregions) @@ -515,7 +515,7 @@ def replace_3dcomponent( meshregions = [mr.name for mr in self._app.mesh.meshregions] try: meshregions.remove("Global") - except: + except Exception: pass if meshregions: arg2.append("MeshRegions:="), arg2.append(meshregions) diff --git a/pyaedt/modeler/modelerpcb.py b/pyaedt/modeler/modelerpcb.py index 0523da5227a..7689ebd47bf 100644 --- a/pyaedt/modeler/modelerpcb.py +++ b/pyaedt/modeler/modelerpcb.py @@ -152,7 +152,7 @@ def fit_all(self): try: self._desktop.RestoreWindow() self.oeditor.ZoomToFit() - except: + except Exception: self._desktop.RestoreWindow() @property @@ -217,7 +217,7 @@ def _arg_with_dim(self, value, units=None): try: float(value) val = "{0}{1}".format(value, units) - except: + except Exception: val = value else: val = "{0}{1}".format(value, units) @@ -348,7 +348,7 @@ def merge_design(self, merged_design=None, pos_x="0.0", pos_y="0.0", pos_z="0.0" if cmp_info and des_name in cmp_info[0]: comp_name = str(i) break - except: + except Exception: continue if not comp_name: return False @@ -834,7 +834,7 @@ def set_temperature_dependence( ] try: self._odesign.SetTemperatureSettings(vargs1) - except: + except Exception: self.logger.error("Failed to enable the temperature dependence.") return False else: @@ -1022,6 +1022,6 @@ def geometry_check_and_fix_all( ) self.logger.info("Geometry check succeed") return True - except: + except Exception: self.logger.error("Geometry check Failed.") return False diff --git a/pyaedt/modeler/pcb/Primitives3DLayout.py b/pyaedt/modeler/pcb/Primitives3DLayout.py index bac1307a91c..8541a0ae6cd 100644 --- a/pyaedt/modeler/pcb/Primitives3DLayout.py +++ b/pyaedt/modeler/pcb/Primitives3DLayout.py @@ -747,7 +747,7 @@ def padstacks(self): try: if p[0] == "NAME:psd": props = p - except: + except Exception: pass self._padstacks[name] = Padstack(name, self.opadstackmanager, self.model_units) @@ -799,7 +799,7 @@ def padstacks(self): self._padstacks[name].layers[lay_name].connectiondir = lay[16] i += 1 pass - except: + except Exception: pass return self._padstacks @@ -863,7 +863,7 @@ def change_net_visibility(self, netlist=None, visible=False): args.append(nets_dictionary[key]) self.oeditor.SetNetVisible(args) return True - except: + except Exception: self.logger.error("Couldn't change nets visibility.") return False diff --git a/pyaedt/modeler/pcb/object3dlayout.py b/pyaedt/modeler/pcb/object3dlayout.py index 602d0e480b0..63f53f469ec 100644 --- a/pyaedt/modeler/pcb/object3dlayout.py +++ b/pyaedt/modeler/pcb/object3dlayout.py @@ -884,7 +884,7 @@ def name(self, value): self.change_property(vMaterial) self._name = value self._primitives._lines[self._name] = self - except: + except Exception: pass @property diff --git a/pyaedt/modeler/schematic.py b/pyaedt/modeler/schematic.py index e8c0a597848..cdd05a11613 100644 --- a/pyaedt/modeler/schematic.py +++ b/pyaedt/modeler/schematic.py @@ -150,7 +150,7 @@ def connect_schematic_components(self, firstcomponent, secondcomponent, pinnum_f try: self.schematic.create_wire([pos1, pos2]) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -323,7 +323,7 @@ def create_text( self.change_text_property(str(text_id), "Rectangle BorderColor", [r3, g3, b3]) self.change_text_property(str(text_id), "Rectangle FillStyle", fill[rect_fill]) return text_out - except: + except Exception: return False @pyaedt_function_handler @@ -450,7 +450,7 @@ def _arg_with_dim(self, value, units=None): try: float(value) val = "{0}{1}".format(value, units) - except: + except Exception: val = value else: val = "{0}{1}".format(value, units) diff --git a/pyaedt/modules/Boundary.py b/pyaedt/modules/Boundary.py index 2d3f0b7bb13..c32f37e690c 100644 --- a/pyaedt/modules/Boundary.py +++ b/pyaedt/modules/Boundary.py @@ -112,7 +112,7 @@ def _get_boundary_data(self, ds): "MaxwellParameterType" ], ] - except: + except Exception: pass try: if "MotionSetupList" in self._app.design_properties["ModelSetup"]: @@ -124,7 +124,7 @@ def _get_boundary_data(self, ds): self._app.design_properties["ModelSetup"]["MotionSetupList"][ds], self._app.design_properties["ModelSetup"]["MotionSetupList"][ds]["MotionType"], ] - except: + except Exception: pass try: if ds in self._app.design_properties["BoundarySetup"]["Boundaries"]: @@ -138,7 +138,7 @@ def _get_boundary_data(self, ds): self._app.design_properties["BoundarySetup"]["Boundaries"][ds], self._app.design_properties["BoundarySetup"]["Boundaries"][ds]["BoundType"], ] - except: + except Exception: return [] @@ -1019,7 +1019,7 @@ def _create_matrix_reduction(self, red_type, sources, matrix_name=None, join_nam ["NAME:" + join_name, "Type:=", "Join in " + red_type, "Sources:=", ",".join(sources)], ) return matrix_name, join_name - except: + except Exception: self._app.logger.error("Failed to create Matrix Reduction") return False, False diff --git a/pyaedt/modules/CableModeling.py b/pyaedt/modules/CableModeling.py index 9ed69a2ae1a..17b0f41ccc6 100644 --- a/pyaedt/modules/CableModeling.py +++ b/pyaedt/modules/CableModeling.py @@ -225,7 +225,7 @@ def create_cable(self): ["NAME:TwistedPairAttribs", "Name:=", self.cable_name], ) return True - except: + except Exception: self._app.logger.error("Cable creation was unsuccessful.") return False @@ -298,7 +298,7 @@ def update_cable_properties(self): ] ) return True - except: + except Exception: self._app.logger.error("Cable properties not updated.") return False @@ -345,7 +345,7 @@ def update_shielding(self): ] ) return True - except: + except Exception: self._app.logger.error("Cable shielding properties not updated.") return False @@ -369,7 +369,7 @@ def remove_cables(self): try: self._omodule.RemoveCable(cable_to_remove) return True - except: + except Exception: self._app.logger.error("Remove cable failed.") return False @@ -392,7 +392,7 @@ def add_cable_to_bundle(self): ["NAME:CableInstAttribs", "Name:=", cable_to_add], ) return True - except: + except Exception: self._app.logger.error("Add cable to Bundle failed. Please check the provided cable names.") return False else: @@ -427,7 +427,7 @@ def create_clock_source(self): ["NAME:TDSourceAttribs", "Name:=", self.source_name], ) return True - except: + except Exception: self._app.logger.error("Clock source not created.") return False @@ -460,7 +460,7 @@ def update_clock_source(self): ] ) return True - except: + except Exception: self._app.logger.error("Clock source not created.") return False @@ -475,7 +475,7 @@ def remove_source(self): try: self._omodule.RemoveTimeDomainSource(self.source_to_remove) return True - except: + except Exception: self._app.logger.error("Source could not be removed.") return False @@ -492,7 +492,7 @@ def remove_all_sources(self): for source in self.existing_sources_names: self._omodule.RemoveTimeDomainSource(source) return True - except: + except Exception: self._app.logger.error("Source could not be removed.") return False @@ -518,7 +518,7 @@ def create_pwl_source(self): ["NAME:TDSourceAttribs", "Name:=", self.pwl_source_name], ) return True - except: + except Exception: self._app.logger.error("PWL source not created.") return False @@ -535,7 +535,7 @@ def create_pwl_source_from_file(self): self.pwl_source_file_path, ["NAME:TDSourceAttribs", "Name:=", generate_unique_name("pwl")] ) return True - except: + except Exception: self._app.logger.error("PWL source from file not created.") return False @@ -576,7 +576,7 @@ def update_pwl_source(self): ] ) return True - except: + except Exception: self._app.logger.error("PWL source not created.") return False @@ -688,7 +688,7 @@ def create_cable_harness(self): ) return True - except: + except Exception: self._app.logger.error("Couldn't create cable harness.") return False diff --git a/pyaedt/modules/DesignXPloration.py b/pyaedt/modules/DesignXPloration.py index 86036445c82..e2566253a47 100644 --- a/pyaedt/modules/DesignXPloration.py +++ b/pyaedt/modules/DesignXPloration.py @@ -334,7 +334,7 @@ def _add_calculation( for f in self._app.field_setups: if context == f.name: report_type = "Far Fields" - except: + except Exception: pass sweepdefinition = self._get_context( calculation, @@ -355,7 +355,7 @@ def _add_calculation( for el in list(variables): try: dx_variables[el] = self._app[el] - except: + except Exception: pass for v in list(dx_variables.keys()): self._activate_variable(v) @@ -1092,7 +1092,7 @@ def __init__(self, p_app): and setups_data[data]["SetupType"] == "OptiParametric" ): self.setups.append(SetupParam(p_app, data, setups_data[data], setups_data[data]["SetupType"])) - except: + except Exception: pass @property @@ -1300,7 +1300,7 @@ def __init__(self, p_app): "OptiStatistical", ]: self.setups.append(SetupOpti(p_app, data, setups_data[data], setups_data[data]["SetupType"])) - except: + except Exception: pass @property @@ -1434,7 +1434,7 @@ def add( for f in self._app.field_setups: if context == f.name: report_type = "Far Fields" - except: + except Exception: pass sweepdefinition = setup._get_context( calculation, @@ -1457,7 +1457,7 @@ def add( for el in variables: try: dx_variables[el] = self._app[el] - except: + except Exception: pass for v in list(dx_variables.keys()): if optim_type in ["OptiOptimization", "OptiDXDOE", "OptiDesignExplorer", "optiSLang"]: diff --git a/pyaedt/modules/LayerStackup.py b/pyaedt/modules/LayerStackup.py index d4d2d9fc014..b3b9bca69d6 100644 --- a/pyaedt/modules/LayerStackup.py +++ b/pyaedt/modules/LayerStackup.py @@ -54,12 +54,12 @@ def _conv_number(number, typen=float): if typen is float: try: return float(number) - except: + except Exception: return number elif typen is int: try: return int(number) - except: + except Exception: return number @@ -912,7 +912,7 @@ def _arg_with_dim(self, value, units=None): try: float(value) val = "{0}{1}".format(value, units) - except: + except Exception: val = value else: val = "{0}{1}".format(value, units) diff --git a/pyaedt/modules/Material.py b/pyaedt/modules/Material.py index 776dd174e88..5969dadf6c2 100644 --- a/pyaedt/modules/Material.py +++ b/pyaedt/modules/Material.py @@ -1190,7 +1190,7 @@ def _update_props(self, propname, propvalue, update_aedt=True): try: material_props = getattr(self, propname) material_props_type = material_props.type - except: + except Exception: material_props_type = None if isinstance(propvalue, list) and material_props_type and material_props_type in ["tensor", "anisotropic"]: @@ -1231,7 +1231,7 @@ def _update_props(self, propname, propvalue, update_aedt=True): self._props[propname]["BHCoordinates"] = bh try: self._props[propname]["BHCoordinates"]["Temperatures"] = self.__dict__["_" + propname].temperatures - except: + except Exception: self._props[propname]["BHCoordinates"]["Temperatures"] = OrderedDict({}) else: bh = OrderedDict({"DimUnits": [self.__dict__["_" + propname]._unit]}) @@ -2556,7 +2556,7 @@ def is_conductor(self, threshold=100000): try: if float(cond) >= threshold: return True - except: + except Exception: return False return False diff --git a/pyaedt/modules/MaterialLib.py b/pyaedt/modules/MaterialLib.py index 262d4644310..9dd029cc04b 100644 --- a/pyaedt/modules/MaterialLib.py +++ b/pyaedt/modules/MaterialLib.py @@ -209,7 +209,7 @@ def _get_surface_materials(self): self._app.project_properties["AnsoftProject"]["Definitions"]["SurfaceMaterials"][ds], material_update=False, ) - except: + except Exception: pass return mats @@ -381,14 +381,14 @@ def _create_mat_project_vars(self, matlist): for mat in matlist: try: matprop[prop].append(float(mat.__dict__["_" + prop].value)) - except: + except Exception: self.logger.warning("Warning. Wrong parsed property. Reset to 0") matprop[prop].append(0) try: a = sum(matprop[prop]) if a < tol: del matprop[prop] - except: + except Exception: pass return matprop diff --git a/pyaedt/modules/Mesh.py b/pyaedt/modules/Mesh.py index 93b9d0c5d5e..fe043e28c4a 100644 --- a/pyaedt/modules/Mesh.py +++ b/pyaedt/modules/Mesh.py @@ -197,7 +197,7 @@ def update(self, key_name=None, value=None): key_name = mesh_props[key_name] mesh_obj.SetPropValue(key_name, value) return True - except: + except Exception: self._app.logger.info("Failed to use Child Object. Trying with legacy update.") if self.type == "SurfApproxBased": @@ -459,7 +459,7 @@ def _get_design_global_mesh(self): props = None try: props = self._app.design_properties["MeshSetup"]["MeshSettings"] - except: + except Exception: temp_name = generate_unique_name("temp_prj") temp_proj = os.path.join(self._app.working_directory, temp_name + ".aedt") oproject_target = self._app.odesktop.NewProject(temp_name) @@ -478,7 +478,7 @@ def _get_design_global_mesh(self): props = _project_dictionary["AnsoftProject"][model_names[self._app.design_type]]["MeshSetup"][ "MeshSettings" ] - except: + except Exception: pass if os.path.exists(temp_proj): os.remove(temp_proj) @@ -532,7 +532,7 @@ def _get_design_mesh_operations(self): continue meshops.append(MeshOperation(self, ds, props, props["Type"])) - except: + except Exception: pass return meshops @@ -1458,5 +1458,5 @@ def assign_cylindrical_gap( mesh_operation.create() self.meshoperations.append(mesh_operation) return mesh_operation - except: + except Exception: return False diff --git a/pyaedt/modules/Mesh3DLayout.py b/pyaedt/modules/Mesh3DLayout.py index cded8db2a18..1ae1601947a 100644 --- a/pyaedt/modules/Mesh3DLayout.py +++ b/pyaedt/modules/Mesh3DLayout.py @@ -220,7 +220,7 @@ def _get_design_mesh_operations(self): for ops in self._app.design_properties["Setup"]["Data"][ds]["MeshOps"]: props = self._app.design_properties["Setup"]["Data"][ds]["MeshOps"][ops] meshops.append(Mesh3DOperation(self, ds, ops, props)) - except: + except Exception: pass return meshops diff --git a/pyaedt/modules/MeshIcepak.py b/pyaedt/modules/MeshIcepak.py index f4c1e03ec17..5ddfcdff78b 100644 --- a/pyaedt/modules/MeshIcepak.py +++ b/pyaedt/modules/MeshIcepak.py @@ -1010,6 +1010,7 @@ def _get_design_mesh_operations(self): ) except Exception as e: self._app.logger.error(e) + return meshops @pyaedt_function_handler() @@ -1046,6 +1047,7 @@ def _get_design_mesh_regions(self): meshops.append(meshop) except Exception as e: self._app.logger.error(e) + return meshops @pyaedt_function_handler() diff --git a/pyaedt/modules/PostProcessor.py b/pyaedt/modules/PostProcessor.py index 949bc22a783..2a4e22eda24 100644 --- a/pyaedt/modules/PostProcessor.py +++ b/pyaedt/modules/PostProcessor.py @@ -1149,7 +1149,7 @@ def delete_report(self, plot_name=None): else: self.plots.clear() return True - except: + except Exception: return False @pyaedt_function_handler() @@ -1179,7 +1179,7 @@ def rename_report(self, plot_name, new_name): if plot.plot_name == plot_name: plot.plot_name = self.oreportsetup.GetChildObject(new_name).GetPropValue("Name") return True - except: + except Exception: return False @pyaedt_function_handler() @@ -1230,7 +1230,7 @@ def get_solution_data_per_variation( ) self.logger.info("Solution Data Correctly Loaded.") return SolutionData(data) - except: + except Exception: self.logger.warning("Solution Data failed to load. Check solution, context or expression.") return None @@ -2238,7 +2238,7 @@ def _get_cs_plane_ids(self): name2refid[cs_id] = name + ":XY" name2refid[cs_id + 1] = name + ":YZ" name2refid[cs_id + 2] = name + ":XZ" - except: + except Exception: pass return name2refid @@ -2294,7 +2294,7 @@ def _get_fields_plot(self): plots[plot_name].MinArrowSpacing = arrow_setts["MinArrowSpacing"] plots[plot_name].MaxArrowSpacing = arrow_setts["MaxArrowSpacing"] plots[plot_name].GridColor = surf_setts["GridColor"] - except: + except Exception: pass return plots @@ -2432,7 +2432,7 @@ def get_scalar_field_value( if isvector: try: self.ofieldsreporter.EnterQty(quantity_name) - except: + except Exception: self.ofieldsreporter.CopyNamedExprToStack(quantity_name) self.ofieldsreporter.CalcOp("Smooth") self.ofieldsreporter.EnterScalar(0) @@ -2441,7 +2441,7 @@ def get_scalar_field_value( else: try: self.ofieldsreporter.EnterQty(quantity_name) - except: + except Exception: self.logger.info("Quantity {} not present. Trying to get it from Stack".format(quantity_name)) self.ofieldsreporter.CopyNamedExprToStack(quantity_name) obj_list = object_name @@ -2603,7 +2603,7 @@ def export_field_file_on_grid( self.ofieldsreporter.CalcStack("clear") try: self.ofieldsreporter.EnterQty(quantity_name) - except: + except Exception: self.ofieldsreporter.CopyNamedExprToStack(quantity_name) if isvector: self.ofieldsreporter.CalcOp("Smooth") @@ -2772,7 +2772,7 @@ def export_field_file( self.ofieldsreporter.CalcStack("clear") try: self.ofieldsreporter.EnterQty(quantity_name) - except: + except Exception: self.ofieldsreporter.CopyNamedExprToStack(quantity_name) if not variation_dict: @@ -2889,7 +2889,7 @@ def export_field_plot(self, plotname, filepath, filename="", file_format="aedtpl local_path = os.path.join(settings.remote_rpc_session_temp_folder, filename + "." + file_format) filepath = check_and_download_file(local_path, filepath) return filepath - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.error("{} file format is not supported for this plot.".format(file_format)) return False @@ -2967,7 +2967,7 @@ def _create_fieldplot( self._desktop.CloseAllWindows() try: self._app.modeler.fit_all() - except: + except Exception: pass self._desktop.TileWindows(0) self._oproject.SetActiveDesign(self._app.design_name) @@ -3051,7 +3051,7 @@ def _create_fieldplot_line_traces( self._desktop.CloseAllWindows() try: self._app._modeler.fit_all() - except: + except Exception: pass self._desktop.TileWindows(0) self._oproject.SetActiveDesign(self._app.design_name) diff --git a/pyaedt/modules/SolveSetup.py b/pyaedt/modules/SolveSetup.py index da7e9f80ce6..b5e18865b83 100644 --- a/pyaedt/modules/SolveSetup.py +++ b/pyaedt/modules/SolveSetup.py @@ -167,7 +167,7 @@ def _init_props(self, isnewsetup=False): self.sweeps.append(SweepMatrix(self, el, props=app[el])) setup_data.pop("Sweeps", None) self.props = SetupProps(self, OrderedDict(setup_data)) - except: + except Exception: self.props = SetupProps(self, OrderedDict()) @property @@ -884,7 +884,7 @@ def add_mesh_link( self.update() self.auto_update = auto_update return True - except: + except Exception: self.auto_update = auto_update return False @@ -1005,7 +1005,7 @@ def start_continue_from_previous_setup( self.update() self.auto_update = auto_update return True - except: + except Exception: self.auto_update = auto_update return False @@ -1047,7 +1047,7 @@ def _init_props(self, isnewsetup=False): setup_data = setup setup_data.pop("Sweeps", None) self.props = SetupProps(self, setup_data) - except: + except Exception: self.props = SetupProps(self, OrderedDict()) self.props["Name"] = self.name @@ -1737,7 +1737,7 @@ def _init_props(self, isnewsetup=False): self.sweeps.append(SweepHFSS3DLayout(self, el, props=app[el])) self.props = SetupProps(self, OrderedDict(setup_data)) - except: + except Exception: self.props = SetupProps(self, OrderedDict()) settings.logger.error("Unable to set props.") @@ -1986,7 +1986,7 @@ def _get_net_names(self, app, file_fullname): net_name = re.sub("[^a-zA-Z0-9 .\n]", "_", net) aedtapp.modeler.objects[obj_ind].name = net_name aedtapp.modeler.objects[obj_ind].color = [randrange(255), randrange(255), randrange(255)] - except: + except Exception: pass if aedtapp.design_type == "Q3D Extractor": aedtapp.auto_identify_nets() diff --git a/pyaedt/modules/SolveSweeps.py b/pyaedt/modules/SolveSweeps.py index 3b626a4392a..1a28cde82d6 100644 --- a/pyaedt/modules/SolveSweeps.py +++ b/pyaedt/modules/SolveSweeps.py @@ -505,7 +505,7 @@ def add_subrange(self, rangetype, start, end=None, count=None, unit="GHz"): ) self.props["Sweeps"]["Data"] += sweep_range return self.update() - except: + except Exception: return False @pyaedt_function_handler() diff --git a/pyaedt/modules/monitor_icepak.py b/pyaedt/modules/monitor_icepak.py index 607073815e9..78585984bb2 100644 --- a/pyaedt/modules/monitor_icepak.py +++ b/pyaedt/modules/monitor_icepak.py @@ -306,7 +306,7 @@ def assign_point_monitor(self, point_position, monitor_quantity="Temperature", m monitor_names = self._generate_monitor_names(monitor_name, len(point_names)) for i, mn in enumerate(monitor_names): self._point_monitors[mn] = PointMonitor(mn, "Point", point_names[i], monitor_quantity, self._app) - except: # pragma: no cover + except Exception: # pragma: no cover return False if len(monitor_names) == 1: return monitor_names[0] @@ -354,7 +354,7 @@ def assign_point_monitor_to_vertex(self, vertex_id, monitor_quantity="Temperatur monitor_names = self._generate_monitor_names(monitor_name, len(vertex_id)) for i, mn in enumerate(monitor_names): self._point_monitors[mn] = PointMonitor(mn, "Vertex", vertex_id[i], monitor_quantity, self._app) - except: # pragma: no cover + except Exception: # pragma: no cover return False if len(monitor_names) == 1: return monitor_names[0] @@ -410,7 +410,7 @@ def assign_surface_monitor(self, surface_name, monitor_quantity="Temperature", m monitor_names = self._generate_monitor_names(monitor_name, len(surface_name)) for i, mn in enumerate(monitor_names): self._face_monitors[mn] = FaceMonitor(mn, "Surface", surface_name[i], monitor_quantity, self._app) - except: # pragma: no cover + except Exception: # pragma: no cover return False if len(monitor_names) == 1: return monitor_names[0] @@ -457,7 +457,7 @@ def assign_face_monitor(self, face_id, monitor_quantity="Temperature", monitor_n monitor_names = self._generate_monitor_names(monitor_name, len(face_id)) for i, mn in enumerate(monitor_names): self._face_monitors[mn] = FaceMonitor(mn, "Face", face_id[i], monitor_quantity, self._app) - except: # pragma: no cover + except Exception: # pragma: no cover return False if len(monitor_names) == 1: return monitor_names[0] @@ -524,7 +524,7 @@ def assign_point_monitor_in_object(self, name, monitor_quantity="Temperature", m self._point_monitors[mn] = PointMonitor( mn, "Object", existing_names[i], monitor_quantity, self._app ) - except: # pragma: no cover + except Exception: # pragma: no cover return False if len(monitor_names) == 1: return monitor_names[0] @@ -560,7 +560,7 @@ def delete_monitor(self, monitor_name): except KeyError: del self._point_monitors[monitor_name] return True - except: + except Exception: return False @pyaedt_function_handler() diff --git a/pyaedt/modules/report_templates.py b/pyaedt/modules/report_templates.py index 41d61b14f39..d26c98e1091 100644 --- a/pyaedt/modules/report_templates.py +++ b/pyaedt/modules/report_templates.py @@ -488,7 +488,7 @@ def traces(self): try: oo = self._post.oreportsetup.GetChildObject(self.plot_name) oo_names = self._post.oreportsetup.GetChildObject(self.plot_name).GetChildNames() - except: + except Exception: return _traces for el in oo_names: if el in ["Legend", "Grid", "AxisX", "AxisY1", "Header", "General", "CartesianDisplayTypeProperty"]: @@ -498,7 +498,7 @@ def traces(self): for i in oo1: _traces.append(Trace(self._post.oreportsetup, "{}:{}:{}".format(self.plot_name, el, i))) - except: + except Exception: pass return _traces @@ -833,7 +833,7 @@ def notes(self): _notes = [] try: oo_names = self._post.oreportsetup.GetChildObject(self.plot_name).GetChildNames() - except: + except Exception: return _notes for el in oo_names: if "Note" in el: @@ -1559,7 +1559,7 @@ def hide_legend(self, solution_name=True, trace_name=True, variation_key=True, f legend.SetPropValue("Font/Height", font_height) legend.SetPropValue("Header Row Font/Height", font_height) return True - except: + except Exception: self._post._app.logger.error("Failed to hide legend.") return False @@ -1894,7 +1894,7 @@ def import_traces(self, file_path, plot_name): else: self._post.oreportsetup.ImportIntoReport(self.plot_name, file_path) return True - except: + except Exception: return False @pyaedt_function_handler @@ -1921,7 +1921,7 @@ def delete_traces(self, plot_name, traces_list): try: self._post.oreportsetup.DeleteTraces(props) return True - except: + except Exception: return False @pyaedt_function_handler @@ -1953,7 +1953,7 @@ def add_trace_to_report(self, traces, setup_name=None, variations=None, context= self._trace_info, ) return True - except: + except Exception: return False finally: self.expressions = expr @@ -1986,7 +1986,7 @@ def update_trace_in_report(self, traces, setup_name=None, variations=None, conte self._trace_info, ) return True - except: + except Exception: return False finally: self.expressions = expr diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index 37844785cfd..a0c910f4cad 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -73,7 +73,7 @@ def __init__(self, aedtdata): for intrinsic in self.intrinsics: try: self.units_sweeps[intrinsic] = self.nominal_variation.GetSweepUnits(intrinsic) - except: + except Exception: self.units_sweeps[intrinsic] = None self.init_solutions_data() self._ifft = None @@ -2361,7 +2361,7 @@ def _get_port_index(self, port_name=None): try: str1 = port.split("[", 1)[1].split("]", 1)[0] port_index[port] = [int(i) - index_offset for i in str1.split(",")] - except: + except Exception: return False else: if not port_index: @@ -2495,7 +2495,7 @@ def _export_all_ffd(self): self.setup_name, ] ) - except: + except Exception: self._app.logger.error("Failed to export one element pattern.") self._app.logger.error(export_path + exported_name_base + ".ffd") @@ -2738,7 +2738,7 @@ def plotGeomInfo(self): model_faces.append(str(index)) else: nonmodel_faces.append(str(index)) - except: + except Exception: pass info.append("Surface") if model_faces: @@ -3083,7 +3083,7 @@ def create(self): else: self.oField.CreateFieldPlot(self.surfacePlotInstruction, "Field") return True - except: + except Exception: return False @pyaedt_function_handler() @@ -3138,7 +3138,7 @@ def update(self): else: self.oField.ModifyFieldPlot(self.name, self.surfacePlotInstruction) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -3538,7 +3538,7 @@ def create(self): else: self._ofield.CreateFieldPlot(self._create_args(), "VRT") return True - except: + except Exception: return False @pyaedt_function_handler() @@ -3557,7 +3557,7 @@ def update(self): else: self._ofield.ModifyFieldPlot(self.name, self._create_args()) return True - except: + except Exception: return False @pyaedt_function_handler() diff --git a/pyaedt/q3d.py b/pyaedt/q3d.py index fc37b502f3f..ea6253555dd 100644 --- a/pyaedt/q3d.py +++ b/pyaedt/q3d.py @@ -706,7 +706,7 @@ def export_matrix_data( use_sci_notation, ) return True - except: + except Exception: self.logger.error("Export of matrix data was unsuccessful.") return False else: @@ -729,7 +729,7 @@ def export_matrix_data( use_sci_notation, ) return True - except: + except Exception: self.logger.error("Export of matrix data was unsuccessful.") return False @@ -1150,7 +1150,7 @@ def export_equivalent_circuit( freq, ) return True - except: + except Exception: self.logger.error("Export of equivalent circuit was unsuccessful.") return False else: @@ -1188,7 +1188,7 @@ def export_equivalent_circuit( freq, ) return True - except: + except Exception: self.logger.error("Export of equivalent circuit was unsuccessful.") return False @@ -1971,7 +1971,7 @@ def set_material_thresholds( self.oboundary.SetMaterialThresholds(insulator_threshold, perfect_conductor_threshold, magnetic_threshold) return True - except: + except Exception: return False @pyaedt_function_handler() @@ -2415,7 +2415,7 @@ def export_w_elements(self, analyze=False, export_folder=None): ) exported_files.append(export_path) self.logger.info("Exported W-element: %s", export_path) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("Export W-element failed") else: varCount = 0 @@ -2459,7 +2459,7 @@ def export_w_elements(self, analyze=False, export_folder=None): ) exported_files.append(export_path) self.logger.info("Exported W-element: %s", export_path) - except: # pragma: no cover + except Exception: # pragma: no cover self.logger.warning("Export W-element failed") return exported_files @@ -2486,7 +2486,7 @@ def toggle_conductor_type(self, conductor_name, new_type): bound.type = new_type self.logger.info("Conductor type correctly updated") return True - except: + except Exception: self.logger.error("Error in updating conductor type") return False diff --git a/pyaedt/rpc/rpyc_services.py b/pyaedt/rpc/rpyc_services.py index c48d3932972..7c782bd90af 100644 --- a/pyaedt/rpc/rpyc_services.py +++ b/pyaedt/rpc/rpyc_services.py @@ -1086,7 +1086,7 @@ def on_disconnect(self, connection): for edb in self._edb: try: edb.close_edb() - except: + except Exception: pass def start_service(self, port): @@ -1120,7 +1120,7 @@ def start_service(self, port): time.sleep(2) self._processes[port] = p return port - except: + except Exception: logger.error("Error. No connection exists. Check if AEDT is running and if the port number is correct.") return False @@ -1140,7 +1140,7 @@ def exposed_stop_service(self, port): try: self._processes[port].terminate() return True - except: + except Exception: return False return True diff --git a/pyaedt/sbrplus/plot.py b/pyaedt/sbrplus/plot.py index 44d0c732dbd..9fae5a4b4c3 100644 --- a/pyaedt/sbrplus/plot.py +++ b/pyaedt/sbrplus/plot.py @@ -125,7 +125,7 @@ def plot_rays(self, snapshot_path=None): points, lines, depths = self._add_rays() try: conv = 1 / AEDT_UNITS["Length"][self.units] - except: + except Exception: conv = 1 points = [i * conv for i in points] depth1 = pv.PolyData(points, lines=lines) @@ -190,7 +190,7 @@ def plot_first_bounce_currents(self, snapshot_path=None): self._add_objects() try: conv = 1 / AEDT_UNITS["Length"][self.units] - except: + except Exception: conv = 1 points = [i * conv for i in points] fb = pv.PolyData(points, faces=faces) From 2b46970defe1913c99310f3b153d0fd8b9197abc Mon Sep 17 00:00:00 2001 From: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:01:21 +0100 Subject: [PATCH 03/23] create_region fix for 2d extractor (#4413) Co-authored-by: maxcapodi78 Co-authored-by: gmalinve <103059376+gmalinve@users.noreply.github.com> --- _unittest/test_09_Primitives2D.py | 21 +++++++++++++++++++++ pyaedt/modeler/cad/Primitives2D.py | 22 ++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/_unittest/test_09_Primitives2D.py b/_unittest/test_09_Primitives2D.py index 166d379f34b..9951658bc03 100644 --- a/_unittest/test_09_Primitives2D.py +++ b/_unittest/test_09_Primitives2D.py @@ -2,6 +2,7 @@ import pytest from pyaedt import Maxwell2d +from pyaedt import Q2d from pyaedt.modeler.cad.polylines import Polyline @@ -17,6 +18,12 @@ def axisymmetrical(add_app): return app +@pytest.fixture(scope="class") +def q2d_app(add_app): + app = add_app(design_name="2d_extr", application=Q2d) + return app + + class TestClass: @pytest.fixture(autouse=True) def init(self, aedtapp, axisymmetrical, local_scratch): @@ -108,3 +115,17 @@ def test_07_assign_material_ceramic(self, material="Ceramic_material"): def test_07_assign_material(self, material="steel_stainless"): self.aedtapp.assign_material(["Rectangle1"], material) assert self.aedtapp.modeler["Rectangle1"].material_name == material + + def test_08_region(self, q2d_app): + if q2d_app.modeler["Region"]: + q2d_app.modeler.delete("Region") + assert "Region" not in q2d_app.modeler.object_names + assert not q2d_app.modeler.create_region(["100%", "50%", "20%", "10%"]) + assert q2d_app.modeler.create_region([100, 50, 20, 20]) + q2d_app.modeler["Region"].delete() + assert q2d_app.modeler.create_region(100) + q2d_app.modeler["Region"].delete() + assert q2d_app.modeler.create_region("200") + q2d_app.modeler["Region"].delete() + assert q2d_app.modeler.create_region([100, "50mm", 20, 10], False) + q2d_app.modeler["Region"].delete() diff --git a/pyaedt/modeler/cad/Primitives2D.py b/pyaedt/modeler/cad/Primitives2D.py index b70edcfe437..6efc7737b99 100644 --- a/pyaedt/modeler/cad/Primitives2D.py +++ b/pyaedt/modeler/cad/Primitives2D.py @@ -304,16 +304,18 @@ def create_region(self, pad_percent=300, is_percentage=True): >>> oEditor.CreateRegion """ if not isinstance(pad_percent, list): - if self._app.design_type == "2D Extractor" or self._app.design_type == "Maxwell 2D": - if self._app.odesign.GetGeometryMode() == "XY": - pad_percent = [pad_percent, pad_percent, pad_percent, pad_percent, 0, 0] - else: - pad_percent = [pad_percent, 0, 0, 0, pad_percent, pad_percent] + pad_percent = [pad_percent] * 4 + if self._app.design_type == "2D Extractor" or ( + self._app.design_type == "Maxwell 2D" and self._app.odesign.GetGeometryMode() == "XY" + ): + if len(pad_percent) != 4: + self.logger.error("Wrong padding list provided. Four values have to be provided.") + return False + pad_percent = [pad_percent[0], pad_percent[2], pad_percent[1], pad_percent[3], 0, 0] else: - if self._app.design_type == "2D Extractor" or self._app.design_type == "Maxwell 2D": - if self._app.odesign.GetGeometryMode() == "XY": - pad_percent = [pad_percent[0], pad_percent[2], pad_percent[1], pad_percent[3], 0, 0] - else: - pad_percent = [pad_percent[0], 0, 0, 0, pad_percent[1], pad_percent[2]] + if len(pad_percent) < 3: + self.logger.error("Wrong padding list provided. Three values have to be provided for RZ geometry.") + return False + pad_percent = [pad_percent[0], 0, 0, 0, pad_percent[1], pad_percent[2]] return self._create_region(pad_percent, ["Absolute Offset", "Percentage Offset"][int(is_percentage)]) From 6124683f9654678b20e122e643db8545452fb7bf Mon Sep 17 00:00:00 2001 From: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:46:22 +0100 Subject: [PATCH 04/23] right now Insertion loss is computed on first frequency point. (#4416) Co-authored-by: maxcapodi78 --- pyaedt/generic/touchstone_parser.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyaedt/generic/touchstone_parser.py b/pyaedt/generic/touchstone_parser.py index bbd6e271698..0083430f499 100644 --- a/pyaedt/generic/touchstone_parser.py +++ b/pyaedt/generic/touchstone_parser.py @@ -105,13 +105,16 @@ def get_insertion_loss_index(self, threshold=-3): """ temp_list = [] - freq_idx = 0 - s_db = self.s_db[freq_idx, :, :] + s_db = self.s_db[0:2, :, :] for i in self.port_tuples: if i[0] != i[1]: - loss = s_db[i[0], i[1]] + loss = s_db[0, i[0], i[1]] if loss > threshold: temp_list.append(i) + elif loss < -90: + loss = s_db[1, i[0], i[1]] + if loss > threshold: + temp_list.append(i) return temp_list def plot_insertion_losses(self, threshold=-3, plot=True): From cfa37de9e98cd0f81f255ef42334105425b7d5b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 07:22:22 +0100 Subject: [PATCH 05/23] MAINT: Update pyedb requirement from <0.5,>=0.4.0 to >=0.4.0,<0.8 (#4422) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6b5ae46f890..5e52e3b362a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ tests = [ "pytest-cov>=4.0.0,<4.2", "pytest-xdist>=3.5.0,<3.6", "pyedb>=0.4.0,<0.5; python_version == '3.7'", - "pyedb>=0.5.0,<0.6; python_version > '3.7'", + "pyedb>=0.5.0,<0.8; python_version > '3.7'", "pyvista>=0.38.0,<0.44", "scikit-learn>=1.0.0,<1.5", "scikit-rf>=0.30.0,<0.33", From 1198b79c70aff464d9337d8c493f65416974d786 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 06:25:19 +0000 Subject: [PATCH 06/23] MAINT: Update pytest-cov requirement from <4.2,>=4.0.0 to >=4.0.0,<5.1 Updates the requirements on [pytest-cov](https://github.com/pytest-dev/pytest-cov) to permit the latest version. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v4.0.0...v5.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5e52e3b362a..60f4f958935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ tests = [ "osmnx>=1.1.0,<1.10", "pandas>=1.1.0,<2.3", "pytest>=7.4.0,<8.2", - "pytest-cov>=4.0.0,<4.2", + "pytest-cov>=4.0.0,<5.1", "pytest-xdist>=3.5.0,<3.6", "pyedb>=0.4.0,<0.5; python_version == '3.7'", "pyedb>=0.5.0,<0.8; python_version > '3.7'", From ae85d9280fdce8733b581a307bb6baf2a69d5446 Mon Sep 17 00:00:00 2001 From: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> Date: Thu, 28 Mar 2024 08:12:03 +0100 Subject: [PATCH 07/23] Remove unnecessary f-string. (#4418) --- pyaedt/generic/compliance.py | 10 +++++----- pyaedt/generic/touchstone_parser.py | 5 ++--- pyaedt/modeler/cad/Primitives3D.py | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pyaedt/generic/compliance.py b/pyaedt/generic/compliance.py index 9f95df5b475..ad22ce2e9ce 100644 --- a/pyaedt/generic/compliance.py +++ b/pyaedt/generic/compliance.py @@ -491,7 +491,7 @@ def _create_aedt_reports(self, pdf_report): if ( pass_fail and report_type in ["frequency", "time"] and local_config.get("limitLines", None) ): # pragma: no cover - _design.logger.info(f"Checking lines violations") + _design.logger.info("Checking lines violations") table = self._add_lna_violations(aedt_report, pdf_report, image_name, local_config) write_csv(os.path.join(self._output_folder, f"{name}_pass_fail.csv"), table) if self.local_config.get("delete_after_export", True): @@ -541,18 +541,18 @@ def _create_aedt_reports(self, pdf_report): sleep_time -= 1 if pass_fail: if report_type in ["frequency", "time"] and local_config.get("limitLines", None): - _design.logger.info(f"Checking lines violations") + _design.logger.info("Checking lines violations") table = self._add_lna_violations(aedt_report, pdf_report, image_name, local_config) elif report_type == "statistical eye" and local_config["eye_mask"]: - _design.logger.info(f"Checking eye violations") + _design.logger.info("Checking eye violations") table = self._add_statistical_violations( aedt_report, pdf_report, image_name, local_config ) elif report_type == "eye diagram" and local_config["eye_mask"]: - _design.logger.info(f"Checking eye violations") + _design.logger.info("Checking eye violations") table = self._add_eye_diagram_violations(aedt_report, pdf_report, image_name) elif report_type == "contour eye diagram": - _design.logger.info(f"Checking eye violations") + _design.logger.info("Checking eye violations") table = self._add_contour_eye_diagram_violations( aedt_report, pdf_report, image_name, local_config ) diff --git a/pyaedt/generic/touchstone_parser.py b/pyaedt/generic/touchstone_parser.py index 0083430f499..0a3cc8d6ab1 100644 --- a/pyaedt/generic/touchstone_parser.py +++ b/pyaedt/generic/touchstone_parser.py @@ -148,14 +148,13 @@ def plot(self, index_couples=None, show=True): index_couples : list, optional List of indexes couple to plot. Default is ``None`` to plot all ``port_tuples``. show: bool - Whether to plot. + Whether to plot. Default is ``True``. Returns ------- :class:`matplotlib.plt` """ - temp_list = [] - freq_idx = 0 + if not index_couples: index_couples = self.port_tuples[:] diff --git a/pyaedt/modeler/cad/Primitives3D.py b/pyaedt/modeler/cad/Primitives3D.py index c48a057d16c..2f59e049176 100644 --- a/pyaedt/modeler/cad/Primitives3D.py +++ b/pyaedt/modeler/cad/Primitives3D.py @@ -2559,7 +2559,6 @@ def _make_winding(self, name, material, in_rad, out_rad, height, teta, turns, ch ] positions = [i for i in points[:]] - import math angle = -2 * teta * math.pi / 180 for i in range(1, turns): From aa81e076dd310537fda4e72c89a3bf368af7ad81 Mon Sep 17 00:00:00 2001 From: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:06:11 +0100 Subject: [PATCH 08/23] Remove useless pass statements. (#4421) Co-authored-by: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> --- _unittest/test_02_3D_modeler.py | 2 -- _unittest/test_08_Primitives3D.py | 10 ---------- _unittest/test_09_VariableManager.py | 1 - _unittest/test_12_1_PostProcessing.py | 2 -- _unittest/test_20_HFSS.py | 1 - _unittest/test_21_Circuit.py | 1 - _unittest/test_41_3dlayout_modeler.py | 2 -- _unittest/test_98_Icepak.py | 1 - _unittest_solvers/test_31_Q3D.py | 1 - pyaedt/application/Variables.py | 2 -- pyaedt/desktop.py | 4 ---- pyaedt/generic/configurations.py | 1 - pyaedt/modeler/circuits/PrimitivesCircuit.py | 1 - pyaedt/modules/DesignXPloration.py | 5 ----- pyaedt/modules/Material.py | 2 -- 15 files changed, 36 deletions(-) diff --git a/_unittest/test_02_3D_modeler.py b/_unittest/test_02_3D_modeler.py index c8128e75e52..dbe348469d1 100644 --- a/_unittest/test_02_3D_modeler.py +++ b/_unittest/test_02_3D_modeler.py @@ -326,7 +326,6 @@ def test_30_create_waveguide(self): position, self.aedtapp.AXIS.Z, wgmodel="MYMODEL", wg_length=2000, parametrize_h=True ) assert not wgfail - pass def test_31_set_objects_unmodel(self): assert self.aedtapp.modeler.set_object_model_state("Second_airbox", False) @@ -663,7 +662,6 @@ def test_45_sweep_along_path(self): def test_46_section_object(self): box1 = self.aedtapp.modeler.create_box([-10, -10, -10], [20, 20, 20], "box_to_split") assert self.aedtapp.modeler.section(box1, 0, create_new=True, section_cross_object=False) - pass def test_47_sweep_along_vector(self): sweep_vector = [5, 0, 0] diff --git a/_unittest/test_08_Primitives3D.py b/_unittest/test_08_Primitives3D.py index 5a803019c78..fbccb275aeb 100644 --- a/_unittest/test_08_Primitives3D.py +++ b/_unittest/test_08_Primitives3D.py @@ -98,8 +98,6 @@ def create_copper_box(self, name=None): name = "MyBox" if self.aedtapp.modeler[name]: self.aedtapp.modeler.delete(name) - else: - pass new_object = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], name, "Copper") return new_object @@ -241,8 +239,6 @@ def test_03_create_polyhedron(self): matname="Aluminum", ) - pass - def test_05_center_and_centroid(self): o = self.create_copper_box() tol = 1e-9 @@ -334,7 +330,6 @@ def test_15_create_cylinder(self): assert o.is3d is True assert not self.aedtapp.modeler.create_cylinder(axis, [2, 2], radius, height, 8, "MyCyl", "Copper") assert not self.aedtapp.modeler.create_cylinder(axis, udp, -0.1, height, 8, "MyCyl", "Copper") - pass def test_16_create_ellipse(self): udp = self.aedtapp.modeler.Position(5, 3, 8) @@ -378,7 +373,6 @@ def test_17_create_object_from_edge(self): of = self.aedtapp.modeler.create_object_from_edge([o4.edges[0], o3.edges[1], o4.edges[1]]) assert of assert len(of) == 3 - pass def test_18_create_object_from_face(self): o = self.create_copper_cylinder() @@ -400,7 +394,6 @@ def test_18_create_object_from_face(self): of = self.aedtapp.modeler.create_object_from_face([o3.faces[0], o4.faces[1], o4.faces[1], o3.faces[2]]) assert of assert len(of) == 4 - pass def test_19_create_polyline(self): udp1 = [0, 0, 0] @@ -868,8 +861,6 @@ def test_48_insert_polylines_segments_test2(self): P.insert_segment(position_list=[start_point, insert_point1, insert_point2], segment="Arc") - pass - def test_49_modify_crossection(self): P = self.aedtapp.modeler.create_polyline( position_list=[[34.1004, 14.1248, 0], [27.646, 16.7984, 0], [24.9725, 10.3439, 0]], @@ -1157,7 +1148,6 @@ def test_60_get_edges_on_bounding_box(self): def test_61_get_closest_edge_to_position(self): my_box = self.create_copper_box("test_closest_edge") assert isinstance(self.aedtapp.modeler.get_closest_edgeid_to_position([0.2, 0, 0]), int) - pass @pytest.mark.skipif(config["NonGraphical"], reason="Not running in non-graphical mode") def test_62_import_space_claim(self): diff --git a/_unittest/test_09_VariableManager.py b/_unittest/test_09_VariableManager.py index 166f644eeca..df4adad7f8d 100644 --- a/_unittest/test_09_VariableManager.py +++ b/_unittest/test_09_VariableManager.py @@ -119,7 +119,6 @@ def test_02_test_formula(self): v = self.aedtapp.variable_manager for var_name in v.variable_names: print("{} = {}".format(var_name, self.aedtapp[var_name])) - pass tol = 1e-9 c2pi = math.pi * 2.0 assert abs(v["$PrjVar1"].numeric_value - c2pi) < tol diff --git a/_unittest/test_12_1_PostProcessing.py b/_unittest/test_12_1_PostProcessing.py index 609f128c44c..d08731659e0 100644 --- a/_unittest/test_12_1_PostProcessing.py +++ b/_unittest/test_12_1_PostProcessing.py @@ -459,7 +459,6 @@ def test_09n_add_line_from_point(self): # pragma: no cover 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) ) - pass @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." @@ -479,7 +478,6 @@ def test_09o_add_note(self): # pragma: no cover font_size=10, color=(255, 0, 0), ) - pass def test_10_delete_report(self): plots_number = len(self.aedtapp.post.plots) diff --git a/_unittest/test_20_HFSS.py b/_unittest/test_20_HFSS.py index 6cafedfc5f7..111c53630ee 100644 --- a/_unittest/test_20_HFSS.py +++ b/_unittest/test_20_HFSS.py @@ -844,7 +844,6 @@ def test_24_create_curvilinear(self): ).GetPropValue("Apply Curvilinear Elements") mesh.delete() assert len(self.aedtapp.mesh.meshoperations) == 2 - pass def test_30_assign_initial_mesh(self): assert self.aedtapp.mesh.assign_initial_mesh_from_slider(6) diff --git a/_unittest/test_21_Circuit.py b/_unittest/test_21_Circuit.py index 06948314a1c..be0a6a5a264 100644 --- a/_unittest/test_21_Circuit.py +++ b/_unittest/test_21_Circuit.py @@ -118,7 +118,6 @@ def test_06a_create_setup(self): def test_08_import_mentor_netlist(self): self.aedtapp.insert_design("MentorSchematicImport") assert self.aedtapp.create_schematic_from_mentor_netlist(self.netlist_file2) - pass def test_09_import_netlist(self): self.aedtapp.insert_design("SchematicImport") diff --git a/_unittest/test_41_3dlayout_modeler.py b/_unittest/test_41_3dlayout_modeler.py index 69ec0c416c3..0c1e5a85229 100644 --- a/_unittest/test_41_3dlayout_modeler.py +++ b/_unittest/test_41_3dlayout_modeler.py @@ -580,7 +580,6 @@ def test_33_set_temperature_dependence(self): ambient_temp=27, create_project_var=True, ) - pass def test_34_create_additional_setup(self): setup_name = "SiwaveDC" @@ -651,7 +650,6 @@ def test_39_import_ipc(self): def test_40_test_flex(self, add_app): flex = add_app(project_name=test_rigid_flex, application=Hfss3dLayout, subfolder=test_subfolder) assert flex.enable_rigid_flex() - pass def test_41_test_create_polygon(self): points = [[100, 100], [100, 200], [200, 200]] diff --git a/_unittest/test_98_Icepak.py b/_unittest/test_98_Icepak.py index 625c1a5e91d..70ed2b6338f 100644 --- a/_unittest/test_98_Icepak.py +++ b/_unittest/test_98_Icepak.py @@ -226,7 +226,6 @@ def test_10_DesignSettings(self): def test_11_mesh_level(self): assert self.aedtapp.mesh.assign_mesh_level({"USB_Shiels": 2}) - pass def test_12a_AssignMeshOperation(self): self.aedtapp.oproject = test_project_name diff --git a/_unittest_solvers/test_31_Q3D.py b/_unittest_solvers/test_31_Q3D.py index fdb5ad0aeae..5869c08eca5 100644 --- a/_unittest_solvers/test_31_Q3D.py +++ b/_unittest_solvers/test_31_Q3D.py @@ -191,7 +191,6 @@ def test_08_create_faceted_bondwire(self): "bondwire_example", self.aedtapp.AXIS.Z, min_size=0.2, numberofsegments=8 ) assert test - pass def test_11_assign_net(self): box = self.aedtapp.modeler.create_box([30, 30, 30], [10, 10, 10], name="mybox") diff --git a/pyaedt/application/Variables.py b/pyaedt/application/Variables.py index 1da104d08ba..0bc9681e3e7 100644 --- a/pyaedt/application/Variables.py +++ b/pyaedt/application/Variables.py @@ -146,8 +146,6 @@ def __init__( for quantity_name in self._header: self._data[quantity_name] = [] - pass - @pyaedt_function_handler() def __getitem__(self, item): variable_list = item.split(",") diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index 87ee60c209a..a90d6c07966 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -255,7 +255,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): return True except Exception: # pragma: no cover warnings.warn("Something went wrong closing AEDT. Exception in `_main.oDesktop.QuitApplication()`.") - pass elif _desktop_sessions and len(_desktop_sessions) > 1 and not desktop_class.parent_desktop_id: pyaedt_logger.error("Release is not allowed when multiple desktop sessions are available.") pyaedt_logger.error("Closing Desktop session.") @@ -268,7 +267,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): return True except Exception: # pragma: no cover warnings.warn("Something went wrong closing AEDT. Exception in `_main.oDesktop.QuitApplication()`.") - pass elif _desktop_sessions and len(_desktop_sessions) > 1: pyaedt_logger.error("A child desktop session is linked to this session.") pyaedt_logger.error("Multiple desktop sessions must be released in reverse order.") @@ -284,7 +282,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): warnings.warn( "Something went wrong releasing AEDT. Exception in `StandalonePyScriptWrapper.Release()`." ) - pass elif not inside_desktop: if close_desktop: try: @@ -302,7 +299,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): pyaedt_logger.warning( "Something went wrong releasing AEDT. Exception in `_main.COMUtil.ReleaseCOMObjectScope`." ) - pass if not settings.remote_rpc_session and not is_ironpython and close_desktop: timeout = 10 while pid in active_sessions(): diff --git a/pyaedt/generic/configurations.py b/pyaedt/generic/configurations.py index 14ba767c84e..0afef57ae35 100644 --- a/pyaedt/generic/configurations.py +++ b/pyaedt/generic/configurations.py @@ -1685,7 +1685,6 @@ def _export_mesh_operations(self, dict_out): } dict_out["mesh"][mesh.name] = mop[mesh.name] self._map_object(mop, dict_out) - pass @pyaedt_function_handler() def update_monitor(self, m_case, m_object, m_quantity, m_name): diff --git a/pyaedt/modeler/circuits/PrimitivesCircuit.py b/pyaedt/modeler/circuits/PrimitivesCircuit.py index d8639bf017a..ff46a7c9e99 100644 --- a/pyaedt/modeler/circuits/PrimitivesCircuit.py +++ b/pyaedt/modeler/circuits/PrimitivesCircuit.py @@ -64,7 +64,6 @@ def __init__(self, modeler): self.current_position = [0, 0] self.increment_mils = [1000, 1000] self.limits_mils = 20000 - pass @property def o_definition_manager(self): diff --git a/pyaedt/modules/DesignXPloration.py b/pyaedt/modules/DesignXPloration.py index e2566253a47..8c8d870ac64 100644 --- a/pyaedt/modules/DesignXPloration.py +++ b/pyaedt/modules/DesignXPloration.py @@ -860,11 +860,6 @@ def __init__(self, p_app, name, dictinputs=None, optim_type="OptiParametric"): def delete(self): """Delete a defined Optimetrics Setup. - Parameters - ---------- - setup_name : str - Name of optimetrics setup to delete. - Returns ------- bool diff --git a/pyaedt/modules/Material.py b/pyaedt/modules/Material.py index 5969dadf6c2..7e1c28a1edb 100644 --- a/pyaedt/modules/Material.py +++ b/pyaedt/modules/Material.py @@ -1363,7 +1363,6 @@ def _update_material(self): self._props[property] if property in self._props else MatProperties.get_defaultvalue(aedtname=property) ) self.__dict__["_" + property] = MatProperty(self, property, property_value, tmods, smods) - pass @property def material_appearance(self): @@ -2704,7 +2703,6 @@ def __init__(self, materiallib, name, props=None, material_update=True): self.__dict__["_" + property] = MatProperty( self, property, SurfMatProperties.get_defaultvalue(aedtname=property) ) - pass @property def emissivity(self): From 8ee9c9fd3a4b5f9e1993084e6f795bc645116919 Mon Sep 17 00:00:00 2001 From: Lorenzo Vecchietti <58366962+lorenzovecchietti@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:10:31 +0100 Subject: [PATCH 09/23] Fix for subregion with multiple objects (#4424) --- _unittest/test_98_Icepak.py | 6 +++++- pyaedt/modeler/cad/Primitives.py | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/_unittest/test_98_Icepak.py b/_unittest/test_98_Icepak.py index 70ed2b6338f..767323cb0c5 100644 --- a/_unittest/test_98_Icepak.py +++ b/_unittest/test_98_Icepak.py @@ -131,7 +131,11 @@ def test_03_AssignPCBRegion(self): pcb_mesh_region.assignment.padding_types = "Absolute Offset" assert pcb_mesh_region.assignment.padding_values == ["2mm"] * 6 assert pcb_mesh_region.assignment.padding_types == ["Absolute Offset"] * 6 - subregion = self.aedtapp.modeler.create_subregion([50, 50, 50, 50, 100, 100], "Percentage Offset", "PCB") + assert self.aedtapp.modeler.create_subregion([50, 50, 50, 50, 100, 100], "Percentage Offset", "PCB") + box = self.aedtapp.modeler.create_box([0, 0, 0], [1, 2, 3]) + assert self.aedtapp.modeler.create_subregion( + [50, 50, 50, 50, 100, 100], "Percentage Offset", ["PCB", box.name] + ) else: box = self.aedtapp.modeler.create_box([0, 0, 0], [1, 2, 3]) pcb_mesh_region.Objects = box.name diff --git a/pyaedt/modeler/cad/Primitives.py b/pyaedt/modeler/cad/Primitives.py index 0886b74ae9d..06fef74617e 100644 --- a/pyaedt/modeler/cad/Primitives.py +++ b/pyaedt/modeler/cad/Primitives.py @@ -6144,9 +6144,7 @@ def _parse_region_args(self, pad_value, pad_type, region_name, parts, region_typ parts = [parts] normal_parts = [p for p in parts if p in self._app.modeler.objects_by_name] submodel_parts = [p for p in parts if p in self._app.modeler.user_defined_components] - normal_parts = ",".join(normal_parts) - submodel_parts = ",".join(submodel_parts) - arg += [["NAME:SubRegionPartNames", normal_parts], ["NAME:SubRegionSubmodelNames", submodel_parts]] + arg += [["NAME:SubRegionPartNames"] + normal_parts, ["NAME:SubRegionSubmodelNames"] + submodel_parts] flags = "NonModel#Wireframe" arg2 = [ "NAME:Attributes", From 01dcd4eadc46d1324442c23cd39d3cbcdd8bd82f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:53:07 +0100 Subject: [PATCH 10/23] MAINT: Update pyedb requirement from <0.5,>=0.4.0 to >=0.4.0,<0.8 (#4428) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e52e3b362a..3d03de8ddf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "fpdf2", "jsonschema", "psutil", - "pyedb>=0.4.0,<0.5; python_version == '3.7'", + "pyedb>=0.4.0,<0.8; python_version == '3.7'", "pyedb>=0.5.0; python_version > '3.7'", "pytomlpp; python_version < '3.12'", "rpyc>=6.0.0,<6.1", @@ -49,7 +49,7 @@ tests = [ "pytest>=7.4.0,<8.2", "pytest-cov>=4.0.0,<4.2", "pytest-xdist>=3.5.0,<3.6", - "pyedb>=0.4.0,<0.5; python_version == '3.7'", + "pyedb>=0.4.0,<0.8; python_version == '3.7'", "pyedb>=0.5.0,<0.8; python_version > '3.7'", "pyvista>=0.38.0,<0.44", "scikit-learn>=1.0.0,<1.5", From 01f95173d2220da949289ccf9ddc21ae8299823a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:27:04 +0000 Subject: [PATCH 11/23] MAINT: Update numpydoc requirement from <1.7,>=1.5.0 to >=1.5.0,<1.8 (#4429) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3d03de8ddf2..f8f1b7aa0f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ doc = [ "jupyterlab>=4.0.0,<4.3", "matplotlib>=3.5.0,<3.9", "nbsphinx>=0.9.0,<0.10", - "numpydoc>=1.5.0,<1.7", + "numpydoc>=1.5.0,<1.8", "openpyxl>=3.0.0,<3.2", "osmnx>=1.1.0,<1.10", "pypandoc>=1.10.0,<1.14", @@ -105,7 +105,7 @@ doc-noexamples = [ "ansys-sphinx-theme>=0.10.0,<0.15", "imageio>=2.30.0,<2.35", #"imageio-ffmpeg", - "numpydoc>=1.5.0,<1.7", + "numpydoc>=1.5.0,<1.8", # "recommonmark", "Sphinx==5.3.0; python_version == '3.7'", "Sphinx>=7.1.0,<7.3; python_version > '3.7'", From cde17da5f6a8de34e13a57993b983a7dbd9fc648 Mon Sep 17 00:00:00 2001 From: Sebastien Morais Date: Fri, 29 Mar 2024 10:34:05 +0100 Subject: [PATCH 12/23] MAINT: Update pyedb requirement This reverts commit 01dcd4eadc46d1324442c23cd39d3cbcdd8bd82f. --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f8f1b7aa0f8..140e9118b32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "fpdf2", "jsonschema", "psutil", - "pyedb>=0.4.0,<0.8; python_version == '3.7'", + "pyedb>=0.4.0,<0.5; python_version == '3.7'", "pyedb>=0.5.0; python_version > '3.7'", "pytomlpp; python_version < '3.12'", "rpyc>=6.0.0,<6.1", @@ -49,7 +49,7 @@ tests = [ "pytest>=7.4.0,<8.2", "pytest-cov>=4.0.0,<4.2", "pytest-xdist>=3.5.0,<3.6", - "pyedb>=0.4.0,<0.8; python_version == '3.7'", + "pyedb>=0.4.0,<0.5; python_version == '3.7'", "pyedb>=0.5.0,<0.8; python_version > '3.7'", "pyvista>=0.38.0,<0.44", "scikit-learn>=1.0.0,<1.5", From 992a642d3896fb457db1cf1d0ad53d7f8df32e81 Mon Sep 17 00:00:00 2001 From: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:02:33 +0100 Subject: [PATCH 13/23] Do not redefine built-in. (#4417) --- pyaedt/application/Analysis3DLayout.py | 6 +++--- pyaedt/application/AnalysisNexxim.py | 6 +++--- pyaedt/application/Variables.py | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pyaedt/application/Analysis3DLayout.py b/pyaedt/application/Analysis3DLayout.py index e62a71e73d8..d90148023d4 100644 --- a/pyaedt/application/Analysis3DLayout.py +++ b/pyaedt/application/Analysis3DLayout.py @@ -329,15 +329,15 @@ def get_next_xtalk_list(self, trlist=[], tx_prefix=""): >>> oModule.GetAllPorts """ - next = [] + next_xtalks = [] if not trlist: trlist = [i for i in self.excitations if tx_prefix in i] for i in trlist: k = trlist.index(i) + 1 while k < len(trlist): - next.append("S({},{})".format(i, trlist[k])) + next_xtalks.append("S({},{})".format(i, trlist[k])) k += 1 - return next + return next_xtalks @pyaedt_function_handler() def get_fext_xtalk_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix="", skip_same_index_couples=True): diff --git a/pyaedt/application/AnalysisNexxim.py b/pyaedt/application/AnalysisNexxim.py index 64c65c6e8e8..229bffc7f08 100644 --- a/pyaedt/application/AnalysisNexxim.py +++ b/pyaedt/application/AnalysisNexxim.py @@ -483,15 +483,15 @@ def get_next_xtalk_list(self, trlist=[], tx_prefix=""): >>> oEditor.GetAllPorts """ - next = [] + next_xtalks = [] if not trlist: trlist = [i for i in list(self.excitations.keys()) if tx_prefix in i] for i in trlist: k = trlist.index(i) + 1 while k < len(trlist): - next.append("S({},{})".format(i, trlist[k])) + next_xtalks.append("S({},{})".format(i, trlist[k])) k += 1 - return next + return next_xtalks @pyaedt_function_handler() def get_fext_xtalk_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix="", skip_same_index_couples=True): diff --git a/pyaedt/application/Variables.py b/pyaedt/application/Variables.py index 0bc9681e3e7..19d91b51156 100644 --- a/pyaedt/application/Variables.py +++ b/pyaedt/application/Variables.py @@ -784,26 +784,26 @@ def __init__(self, app): @property def _independent_variables(self): - all = {} - all.update(self._independent_project_variables) - all.update(self._independent_design_variables) - return all + all_independent = {} + all_independent.update(self._independent_project_variables) + all_independent.update(self._independent_design_variables) + return all_independent @property def _dependent_variables(self): - all = {} + all_dependent = {} for k, v in self._dependent_project_variables.items(): - all[k] = v + all_dependent[k] = v for k, v in self._dependent_design_variables.items(): - all[k] = v - return all + all_dependent[k] = v + return all_dependent @property def _all_variables(self): - all = {} - all.update(self._independent_variables) - all.update(self._dependent_variables) - return all + all_variables = {} + all_variables.update(self._independent_variables) + all_variables.update(self._dependent_variables) + return all_variables @pyaedt_function_handler() def __delitem__(self, key): From cb3ce4d7136fdafe284827917977c575e05713fb Mon Sep 17 00:00:00 2001 From: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> Date: Mon, 1 Apr 2024 09:45:00 +0200 Subject: [PATCH 14/23] Various maintainability fixes. (#4425) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Morais <146729917+SMoraisAnsys@users.noreply.github.com> --- .../03-Maxwell/Maxwell_Control_Program.py | 2 +- examples/07-Circuit/Circuit_Transient.py | 2 +- examples/07-EMIT/interference_gui.py | 2 +- pyaedt/modeler/cad/Primitives.py | 25 ++++++++++--------- pyaedt/modeler/cad/Primitives3D.py | 4 +-- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/03-Maxwell/Maxwell_Control_Program.py b/examples/03-Maxwell/Maxwell_Control_Program.py index 586c719cdac..035f1f8db69 100644 --- a/examples/03-Maxwell/Maxwell_Control_Program.py +++ b/examples/03-Maxwell/Maxwell_Control_Program.py @@ -83,7 +83,7 @@ # ~~~~~~~~~~~~ # Plot Solved Results. -sols = m2d.post.get_solution_data("FluxLinkage(Winding1)",variations={"Time":["All"]}, primary_sweep_variable="Time") +sols = m2d.post.get_solution_data("FluxLinkage(Winding1)", variations={"Time":["All"]}, primary_sweep_variable="Time") sols.plot() ################################################################################### diff --git a/examples/07-Circuit/Circuit_Transient.py b/examples/07-Circuit/Circuit_Transient.py index f133bc79d35..6ecb283abf7 100644 --- a/examples/07-Circuit/Circuit_Transient.py +++ b/examples/07-Circuit/Circuit_Transient.py @@ -172,7 +172,7 @@ bn = np.array(b) cellst = np.append(cellst, an) cellsv = np.append(cellsv, bn) -plt.plot(cellst.T, cellsv.T, zorder=0) +plt.plot(cellst.T, cellsv.T, zorder=0) plt.show() ############################################################################### diff --git a/examples/07-EMIT/interference_gui.py b/examples/07-EMIT/interference_gui.py index 57b28716a62..592b3b53eeb 100644 --- a/examples/07-EMIT/interference_gui.py +++ b/examples/07-EMIT/interference_gui.py @@ -612,7 +612,7 @@ def closeEvent(self, event): # Launch the GUI. If you want to run the GUI, uncomment the ``window.show()`` and # ``app.exec_()`` method calls. -if __name__ == '__main__' and os.getenv("PYAEDT_DOC_GENERATION", "False") != "1": +if __name__ == '__main__' and os.getenv("PYAEDT_DOC_GENERATION", "False") != "1": app = QtWidgets.QApplication([]) window = MainWindow() window.show() diff --git a/pyaedt/modeler/cad/Primitives.py b/pyaedt/modeler/cad/Primitives.py index 06fef74617e..dca244e91b0 100644 --- a/pyaedt/modeler/cad/Primitives.py +++ b/pyaedt/modeler/cad/Primitives.py @@ -4651,16 +4651,17 @@ def import_spaceclaim_document(self, SCFile): >>> oEditor.CreateUserDefinedModel """ - environlist = os.environ - latestversion = "" - for l in environlist: - if "AWP_ROOT" in l: - if l > latestversion: - latestversion = l - if not latestversion: + env_var = os.environ + latest_version = "" + for variable in env_var: + if "AWP_ROOT" in variable: + if variable > latest_version: + latest_version = variable + break + if not latest_version: self.logger.error("SpaceClaim is not found.") else: - scdm_path = os.path.join(os.environ[latestversion], "scdm") + scdm_path = os.path.join(os.environ[latest_version], "scdm") self.oeditor.CreateUserDefinedModel( [ "NAME:UserDefinedModelParameters", @@ -5094,11 +5095,11 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal objID = self.oeditor.GetFaceIDs(el) faceCenter = self.oeditor.GetFaceCenter(int(objID[0])) directionfound = False - l = 10 + thickness = 10 while not directionfound: self.oeditor.ThickenSheet( ["NAME:Selections", "Selections:=", el, "NewPartsModelFlag:=", "Model"], - ["NAME:SheetThickenParameters", "Thickness:=", str(l) + "mm", "BothSides:=", False], + ["NAME:SheetThickenParameters", "Thickness:=", str(thickness) + "mm", "BothSides:=", False], ) aedt_bounding_box2 = self.get_model_bounding_box() self._odesign.Undo() @@ -5107,7 +5108,7 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal directionfound = True self.oeditor.ThickenSheet( ["NAME:Selections", "Selections:=", el, "NewPartsModelFlag:=", "Model"], - ["NAME:SheetThickenParameters", "Thickness:=", "-" + str(l) + "mm", "BothSides:=", False], + ["NAME:SheetThickenParameters", "Thickness:=", "-" + str(thickness) + "mm", "BothSides:=", False], ) aedt_bounding_box2 = self.get_model_bounding_box() @@ -5117,7 +5118,7 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal directions[el] = "Internal" directionfound = True else: - l = l + 10 + thickness = thickness + 10 for el in inputlist: objID = self.oeditor.GetFaceIDs(el) faceCenter = self.oeditor.GetFaceCenter(int(objID[0])) diff --git a/pyaedt/modeler/cad/Primitives3D.py b/pyaedt/modeler/cad/Primitives3D.py index 2f59e049176..f92ea1afb97 100644 --- a/pyaedt/modeler/cad/Primitives3D.py +++ b/pyaedt/modeler/cad/Primitives3D.py @@ -552,8 +552,8 @@ def create_torus(self, center, major_radius, minor_radius, axis=None, name=None, # fmt: off @pyaedt_function_handler() - def create_bondwire(self, start_position, end_position, h1=0.2, h2=0, alpha=80, beta=5, bond_type=0, - diameter=0.025, facets=6, name=None, matname=None, cs_axis="Z", **kwargs): # fmt: on + def create_bondwire(self, start_position, end_position, h1=0.2, h2=0, alpha=80, beta=5, bond_type=0, + diameter=0.025, facets=6, name=None, matname=None, cs_axis="Z", **kwargs): # fmt: on # type : (list, list, float|str=0.2, float|str=0, float=80, float=5, int=0, float|str=0.025, int=6, str=None, # str=None) -> Object3d """Create a bondwire. From 610521b7b2e9b2c469c28dc68cc4cc026dc4ea06 Mon Sep 17 00:00:00 2001 From: gmalinve <103059376+gmalinve@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:58:47 +0200 Subject: [PATCH 15/23] enhance assign_voltage maxwell (#4433) --- _unittest/test_28_Maxwell3D.py | 1 + pyaedt/maxwell.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/_unittest/test_28_Maxwell3D.py b/_unittest/test_28_Maxwell3D.py index 535016b875b..ca6ce69196a 100644 --- a/_unittest/test_28_Maxwell3D.py +++ b/_unittest/test_28_Maxwell3D.py @@ -469,6 +469,7 @@ def test_32_matrix(self, add_app): rectangle4 = m3d.modeler.create_rectangle(0, [32.5, 1.5, 0], [2.5, 5], name="Sheet4") m3d.assign_voltage(rectangle1.faces[0], amplitude=1, name="Voltage1") + m3d.assign_voltage("Sheet1", amplitude=1, name="Voltage5") m3d.assign_voltage(rectangle2.faces[0], amplitude=1, name="Voltage2") m3d.assign_voltage(rectangle3.faces[0], amplitude=1, name="Voltage3") m3d.assign_voltage(rectangle4.faces[0], amplitude=1, name="Voltage4") diff --git a/pyaedt/maxwell.py b/pyaedt/maxwell.py index d4e5e0606ea..158b444cebb 100644 --- a/pyaedt/maxwell.py +++ b/pyaedt/maxwell.py @@ -966,7 +966,13 @@ def assign_voltage(self, face_list, amplitude=1, name=None): if self.design_type == "Maxwell 2D": props = OrderedDict({"Objects": face_list, "Value": amplitude}) else: - props = OrderedDict({"Faces": face_list, "Voltage": amplitude}) + if len(face_list) == 1: + if isinstance(face_list[0], str) and face_list[0] in self.modeler.object_names: + props = OrderedDict({"Objects": face_list, "Voltage": amplitude}) + else: + props = OrderedDict({"Faces": face_list, "Value": amplitude}) + else: + props = OrderedDict({"Faces": face_list, "Voltage": amplitude}) bound = BoundaryObject(self, name, props, "Voltage") if bound.create(): self._boundaries[bound.name] = bound From a324b9d6dd83e8e223d256c31c309e440a8fadd9 Mon Sep 17 00:00:00 2001 From: gmalinve <103059376+gmalinve@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:32:16 +0200 Subject: [PATCH 16/23] rename objects 3d (#4431) Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> --- _unittest/test_07_Object3D.py | 2 ++ pyaedt/modeler/cad/object3d.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/_unittest/test_07_Object3D.py b/_unittest/test_07_Object3D.py index 22ec8213312..ce038e5dd3a 100644 --- a/_unittest/test_07_Object3D.py +++ b/_unittest/test_07_Object3D.py @@ -226,6 +226,8 @@ def test_07_object_clone_and_get_properties(self): assert len(new_object.faces) == 6 assert len(new_object.edges) == 12 assert new_object.display_wireframe == initial_object.display_wireframe + new_object.name = "Properties_Box" + assert not new_object.name == "Properties_Box" def test_08_set_model(self): o = self.create_copper_box() diff --git a/pyaedt/modeler/cad/object3d.py b/pyaedt/modeler/cad/object3d.py index 7753901dfd3..ce8fd8a3cc4 100644 --- a/pyaedt/modeler/cad/object3d.py +++ b/pyaedt/modeler/cad/object3d.py @@ -1089,7 +1089,7 @@ def name(self, obj_name): self._primitives.add_new_objects() self._primitives.cleanup_objects() else: - pass + self.logger.warning("{} is already used in current design.".format(obj_name)) @property def valid_properties(self): From 94f237784847338dbfdac1dc39785aeee221003e Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Tue, 2 Apr 2024 08:25:57 +0200 Subject: [PATCH 17/23] Change deprecated attibute (#4439) --- pyaedt/modules/solutions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyaedt/modules/solutions.py b/pyaedt/modules/solutions.py index a0c910f4cad..866836f4be7 100644 --- a/pyaedt/modules/solutions.py +++ b/pyaedt/modules/solutions.py @@ -2598,7 +2598,7 @@ def _update_both(self): self.ff.mesh = self.ff.get_far_field_mesh(self.farfield_quantity, self.quantity_format) - self.output.overwrite(self.ff.mesh) + self.output.copy_from(self.ff.mesh) return @pyaedt_function_handler() From f4dbec55e6ea920a9d530edf688576e070342d43 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:11:49 +0200 Subject: [PATCH 18/23] Fix/issue 4427 (#4437) --- pyaedt/generic/configurations.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pyaedt/generic/configurations.py b/pyaedt/generic/configurations.py index 0afef57ae35..c8197437066 100644 --- a/pyaedt/generic/configurations.py +++ b/pyaedt/generic/configurations.py @@ -3,7 +3,6 @@ from datetime import datetime import json import os -import pkgutil import tempfile import pyaedt @@ -692,12 +691,23 @@ def __init__(self, app): self.options = ConfigurationsOptions() self.results = ImportResults() - # Read the default configuration schema from pyaedt - schema_bytes = pkgutil.get_data( - __name__, os.path.join(os.path.dirname(pyaedt.__file__), "misc", "config.schema.json") - ) - schema_string = schema_bytes.decode("utf-8") - self._schema = json.loads(schema_string) + pyaedt_installed_path = os.path.dirname(pyaedt.__file__) + + schema_bytes = None + + config_schema_path = os.path.join(pyaedt_installed_path, "misc", "config.schema.json") + + if os.path.isfile(config_schema_path): + with open(config_schema_path, "rb") as schema: + schema_bytes = schema.read() + + if schema_bytes: + # Read the default configuration schema from pyaedt + schema_string = schema_bytes.decode("utf-8") + self._schema = json.loads(schema_string) + else: # pragma: no cover + self._app.logger.error("Failed to load configuration schema.") + self._schema = None @staticmethod @pyaedt_function_handler() From 0e6a6cd3db087b71cf8ea6de01954311c7b4de09 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 08:03:09 +0000 Subject: [PATCH 19/23] [pre-commit.ci] pre-commit autoupdate (#4442) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxime Rey <87315832+MaxJPRey@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b75dc54d20e..40b1fcafcc6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: # validate GitHub workflow files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.28.0 + rev: 0.28.1 hooks: - id: check-github-workflows From 59d99bebd0c9a92d039b26b6ef85fd3f5583ee44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:02:28 +0000 Subject: [PATCH 20/23] MAINT: Update ipython requirement from <8.23,>=7.30.0 to >=7.30.0,<8.24 (#4443) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 140e9118b32..d2eec9db464 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ doc = [ "imageio>=2.30.0,<2.35", #"imageio-ffmpeg>=0.4.0,<0.5", "ipython>=7.34.0; python_version == '3.7'", - "ipython>=8.13.0,<8.23; python_version > '3.7'", + "ipython>=8.13.0,<8.24; python_version > '3.7'", #"ipywidgets>=8.0.0,<8.2", "joblib>=1.3.0,<1.4", "jupyterlab>=4.0.0,<4.3", From 17541a4b5fdcc90228a80914a405b60bc137779d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:39:59 +0000 Subject: [PATCH 21/23] MAINT: Update imageio requirement from <2.34,>=2.30.0 to >=2.30.0,<2.35 (#4404) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d2eec9db464..0ad299d5f4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ dependencies = [ [project.optional-dependencies] tests = [ - "imageio>=2.30.0,<2.34", + "imageio>=2.30.0,<2.35", "ipython>=7.30.0,<8.23", "joblib>=1.0.0,<1.4", "matplotlib>=3.5.0,<3.9", From 10e267ad974e3dd2e33d7a76217d46e80e035279 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:30:33 +0000 Subject: [PATCH 22/23] MAINT: Update ansys-sphinx-theme requirement from <0.15,>=0.10.0 to >=0.10.0,<0.16 (#4441) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0ad299d5f4f..bfaf1e3c905 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ dotnet = [ "pywin32>=303; platform_system=='Windows'", ] doc = [ - "ansys-sphinx-theme>=0.10.0,<0.15", + "ansys-sphinx-theme>=0.10.0,<0.16", "imageio>=2.30.0,<2.35", #"imageio-ffmpeg>=0.4.0,<0.5", "ipython>=7.34.0; python_version == '3.7'", @@ -102,7 +102,7 @@ doc = [ "vtk==9.2.6", ] doc-noexamples = [ - "ansys-sphinx-theme>=0.10.0,<0.15", + "ansys-sphinx-theme>=0.10.0,<0.16", "imageio>=2.30.0,<2.35", #"imageio-ffmpeg", "numpydoc>=1.5.0,<1.8", From 37d8b7f188fc09c2f8cd5abd0c5e221affa24a5b Mon Sep 17 00:00:00 2001 From: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:49:11 +0200 Subject: [PATCH 23/23] remove __import__ (#4445) Co-authored-by: maxcapodi78 --- pyaedt/desktop.py | 15 ++++----------- pyaedt/generic/configurations.py | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index a90d6c07966..dc086fbdb90 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -58,8 +58,6 @@ modules = [tup[1] for tup in pkgutil.iter_modules()] -python_grpc_wrapper = None - @pyaedt_function_handler() def launch_aedt(full_path, non_graphical, port, student_version, first_run=True): @@ -239,7 +237,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): ``True`` when successful, ``False`` when failed. """ - global python_grpc_wrapper if settings.remote_rpc_session or (settings.aedt_version >= "2022.2" and is_grpc_api and not is_ironpython): if close_desktop and desktop_class.parent_desktop_id: pyaedt_logger.error("A child desktop session is linked to this session.") @@ -273,9 +270,8 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api): return False else: try: - if not python_grpc_wrapper: - python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin") - # import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper + import pyaedt.generic.grpc_plugin as python_grpc_wrapper + python_grpc_wrapper.AedtAPI.ReleaseAll() return True except Exception: # pragma: no cover @@ -911,7 +907,6 @@ def _initialize( version=None, is_grpc=True, ): - global python_grpc_wrapper if not is_grpc: from pyaedt.generic.clr_module import _clr @@ -934,10 +929,8 @@ def _initialize( os.environ["DesktopPluginPyAEDT"] = os.path.join(settings.aedt_install_dir, "PythonFiles", "DesktopPlugin") launch_msg = "AEDT installation Path {}".format(base_path) self.logger.info(launch_msg) - if not python_grpc_wrapper: - python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin") - python_grpc_wrapper = python_grpc_wrapper.generic.grpc_plugin - # import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper + import pyaedt.generic.grpc_plugin as python_grpc_wrapper + if _desktop_sessions: last_session = list(_desktop_sessions.values())[-1] all_desktop = [i for i in last_session.odesktop.GetRunningInstancesMgr().GetAllRunningInstances()] diff --git a/pyaedt/generic/configurations.py b/pyaedt/generic/configurations.py index c8197437066..ad1dcaf5a03 100644 --- a/pyaedt/generic/configurations.py +++ b/pyaedt/generic/configurations.py @@ -697,7 +697,7 @@ def __init__(self, app): config_schema_path = os.path.join(pyaedt_installed_path, "misc", "config.schema.json") - if os.path.isfile(config_schema_path): + if os.path.exists(config_schema_path): with open(config_schema_path, "rb") as schema: schema_bytes = schema.read()