From bbacd607e8027cf5180db84bbc2a72318ffb3141 Mon Sep 17 00:00:00 2001 From: Samuel Lopez <85613111+Samuelopez-ansys@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:21:06 +0200 Subject: [PATCH] REFACT: Add deprecation waning in Q3D sink methods (#4562) --- _unittest/test_30_Q2D.py | 48 +++++++-------- _unittest_solvers/test_31_Q3D.py | 54 ++++++---------- pyaedt/q3d.py | 102 ++++++++++++++++++------------- 3 files changed, 102 insertions(+), 102 deletions(-) diff --git a/_unittest/test_30_Q2D.py b/_unittest/test_30_Q2D.py index 61683934358..ec88160bca7 100644 --- a/_unittest/test_30_Q2D.py +++ b/_unittest/test_30_Q2D.py @@ -200,79 +200,79 @@ def test_15_export_equivalent_circuit(self, add_app): assert q2d.export_equivalent_circuit(os.path.join(self.local_scratch.path, "test_export_circuit.cir")) assert not q2d.export_equivalent_circuit(os.path.join(self.local_scratch.path, "test_export_circuit.doc")) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - setup_name="Setup1", + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + setup="Setup1", sweep="LastAdaptive", ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), setup_name="Setup2" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), setup="Setup2" ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - setup_name="Setup1", + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + setup="Setup1", sweep="LastAdaptive", variations=["r1:0.3mm"], ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - setup_name="Setup1", + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + setup="Setup1", sweep="LastAdaptive", variations=[" r1 : 0.3 mm "], ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - setup_name="Setup1", + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + setup="Setup1", sweep="LastAdaptive", variations="r1:0.3mm", ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix_name="Original" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix="Original" ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix_name="Test1" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix="Test1" ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=2 + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=2 ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=0 + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=0 ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=1 + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=1 ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=0, - res_limit="6Mohm", ind_limit="12nH", + res_limit="6Mohm", ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), lumped_length="34mm" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), lumped_length="34mm" ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), lumped_length="34nounits" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), lumped_length="34nounits" ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), rise_time_value="1e-6", rise_time_unit="s", ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), rise_time_value="23", rise_time_unit="m", ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), file_type="WELement" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), file_type="WELement" ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), file_type="test" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), file_type="test" ) assert q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model_name=q2d_q3d + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model=q2d_q3d ) assert not q2d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model_name="test" + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model="test" ) self.aedtapp.close_project(q2d.project_name, save_project=False) diff --git a/_unittest_solvers/test_31_Q3D.py b/_unittest_solvers/test_31_Q3D.py index 9f071d5e61e..66b83cb7bcc 100644 --- a/_unittest_solvers/test_31_Q3D.py +++ b/_unittest_solvers/test_31_Q3D.py @@ -373,58 +373,38 @@ def test_16_export_equivalent_circuit(self, add_app): q3d["d"] = "10mm" q3d.modeler.duplicate_along_line(objid="Box1", vector=[0, "d", 0]) q3d.analyze_setup(q3d.active_setup, cores=6) - assert q3d.export_equivalent_circuit( - os.path.join(self.local_scratch.path, "test_export_circuit.cir"), variations=["d: 10mm"] - ) + assert q3d.export_equivalent_circuit(os.path.join(self.local_scratch.path, "test_export_circuit.cir"), + variations=["d: 10mm"]) assert not q3d.export_equivalent_circuit(os.path.join(self.local_scratch.path, "test_export_circuit.doc")) assert not q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - setup_name="Setup1", - sweep="LastAdaptive", - variations=["c: 10mm", "d: 20mm"], - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), setup="Setup1", + sweep="LastAdaptive", variations=["c: 10mm", "d: 20mm"]) assert not q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), setup_name="Setup2" - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), setup="Setup2") assert not q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - setup_name="Setup1", - sweep="Sweep1", - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), setup="Setup1", + sweep="Sweep1") assert q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix_name="Original" - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix="Original") assert q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix_name="JointTest" - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix="JointTest") assert not q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix_name="JointTest1" - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), matrix="JointTest1") assert not q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=2 - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=2) assert q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=0 - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=0) assert q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=1 - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=1) assert q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), - coupling_limit_type=0, - cond_limit="3Sie", - cap_limit="4uF", - ind_limit="9uH", - res_limit="2ohm", - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), coupling_limit_type=0, + cap_limit="4uF", ind_limit="9uH", res_limit="2ohm", cond_limit="3Sie") assert q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model_name="test_14" - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model="test_14") assert not q3d.export_equivalent_circuit( - file_name=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model_name="test" - ) + output_file=os.path.join(self.local_scratch.path, "test_export_circuit.cir"), model="test") self.aedtapp.close_project(q3d.project_name, save_project=False) def test_17_export_results_q3d(self, add_app): diff --git a/pyaedt/q3d.py b/pyaedt/q3d.py index dfb66ee6d19..51c9c714a0d 100644 --- a/pyaedt/q3d.py +++ b/pyaedt/q3d.py @@ -733,14 +733,22 @@ def export_matrix_data( self.logger.error("Export of matrix data was unsuccessful.") return False + @pyaedt_function_handler( + file_name="output_file", + setup_name="setup", + matrix_name="matrix", + num_cells="cells", + freq="frequency", + model_name="model", + ) def export_equivalent_circuit( self, - file_name, - setup_name=None, + output_file, + setup=None, sweep=None, variations=None, - matrix_name=None, - num_cells=2, + matrix=None, + cells=2, user_changed_settings=True, include_cap=True, include_cond=True, @@ -761,8 +769,8 @@ def export_equivalent_circuit( ind_limit=None, res_limit=None, cond_limit=None, - model_name=None, - freq=0, + model=None, + frequency=0, file_type="HSPICE", include_cpp=False, ): @@ -770,11 +778,11 @@ def export_equivalent_circuit( Parameters ---------- - file_name : str + output_file : str Full path for saving the matrix data to. Options for file extensions are CIR, SML, SP, PKG, SPC, LIB, CKT, BSP, DML, and ICM. - setup_name : str, optional + setup : str, optional Setup name. The default value is ``None``, in which case the first analysis setup is used. sweep : str, optional @@ -784,9 +792,9 @@ def export_equivalent_circuit( Design variation. The default is ``None``, in which case the current nominal variation is used. If you provide a design variation, use the format ``{Name}:{Value}``. - matrix_name : str, optional + matrix : str, optional Name of the matrix to show. The default is ``"Original"``. - num_cells : int, optional + cells : int, optional Number of cells in export. Default value is 2. user_changed_settings : bool, optional @@ -855,10 +863,10 @@ def export_equivalent_circuit( Inductance limit. Default value is 1nH if coupling_limit_type is 0. Default value is 0.01 if coupling_limit_type is 1. - model_name : str, optional + model : str, optional Model name or name of the sub circuit (Optional). If None then file_name is considered as model name. - freq : str, optional + frequency : str, optional Sweep frequency in Hz. Default value is 0. file_type : str, optional @@ -896,12 +904,10 @@ def export_equivalent_circuit( >>> aedtapp.modeler.duplicate_along_line(objid="Box1",vector=[0, "d", 0]) >>> mysetup = aedtapp.create_setup() >>> aedtapp.analyze_setup(mysetup.name) - >>> aedtapp.export_equivalent_circuit(file_name="test_export_circuit.cir", - ... setup_name=mysetup.name, - ... sweep="LastAdaptive", - ... variations=["d: 20mm"] + >>> aedtapp.export_equivalent_circuit(output_file="test_export_circuit.cir", + ... setup=mysetup.name,sweep="LastAdaptive", variations=["d: 20mm"]) """ - if os.path.splitext(file_name)[1] not in [ + if os.path.splitext(output_file)[1] not in [ ".cir", ".sml", ".sp", @@ -919,10 +925,10 @@ def export_equivalent_circuit( ) return False - if setup_name is None: - setup_name = self.active_setup - elif setup_name != self.active_setup: - self.logger.error("Setup named: %s is invalid. Provide a valid analysis setup name.", setup_name) + if setup is None: + setup = self.active_setup + elif setup != self.active_setup: + self.logger.error("Setup named: %s is invalid. Provide a valid analysis setup name.", setup) return False if sweep is None: sweep = self.design_solutions.default_adaptive @@ -931,7 +937,7 @@ def export_equivalent_circuit( if sweep.replace(" ", "") not in sweep_array: self.logger.error("Sweep is invalid. Provide a valid sweep.") return False - analysis_setup = setup_name + " : " + sweep.replace(" ", "") + analysis_setup = setup + " : " + sweep.replace(" ", "") if variations is None: if not self.available_variations.nominal_w_values_dict: @@ -962,11 +968,11 @@ def export_equivalent_circuit( variations_list.append(variation) variations = ",".join(variations_list) - if matrix_name is None: - matrix_name = "Original" + if matrix is None: + matrix = "Original" else: if self.matrices: - if not [matrix for matrix in self.matrices if matrix.name == matrix_name]: + if not [matrix_object for matrix_object in self.matrices if matrix_object.name == matrix]: self.logger.error("Matrix doesn't exist. Provide an existing matrix.") return False else: @@ -1047,9 +1053,9 @@ def export_equivalent_circuit( coupling_limit_value = "None" coupling_limits.append(coupling_limit_value) - if model_name is None: - model_name = self.project_name - elif model_name != self.project_name: + if model is None: + model = self.project_name + elif model != self.project_name: self.logger.error("Invalid project name.") return False @@ -1092,6 +1098,7 @@ def export_equivalent_circuit( self.logger.error("Invalid file type, possible solutions are Hspice, Welement, RLGC.") return False + cpp_settings = [] if include_cpp: if settings.aedt_version >= "2023.2": if not [x for x in [include_dcr, include_dcl, include_acr, include_acl, add_resistance] if x]: @@ -1106,22 +1113,19 @@ def export_equivalent_circuit( if isinstance(setting, tuple): if setting[0] == "NAME:CPPInfo": cpp_settings = setting - else: - include_cpp = False - cpp_settings = [] if self.modeler._is3d: try: self.oanalysis.ExportCircuit( analysis_setup, variations, - file_name, + output_file, [ "NAME:CircuitData", "MatrixName:=", - matrix_name, + matrix, "NumberOfCells:=", - str(num_cells), + str(cells), "UserHasChangedSettings:=", user_changed_settings, "IncludeCap:=", @@ -1145,8 +1149,8 @@ def export_equivalent_circuit( include_cpp, cpp_settings, ], - model_name, - freq, + model, + frequency, ) return True except Exception: @@ -1157,13 +1161,13 @@ def export_equivalent_circuit( self.oanalysis.ExportCircuit( analysis_setup, variations, - file_name, + output_file, [ "NAME:CircuitData", "MatrixName:=", - matrix_name, + matrix, "NumberOfCells:=", - str(num_cells), + str(cells), "UserHasChangedSettings:=", user_changed_settings, "IncludeCap:=", @@ -1182,9 +1186,9 @@ def export_equivalent_circuit( "RiseTime:=", rise_time, ], - model_name, + model, file_type, - freq, + frequency, ) return True except Exception: @@ -1614,6 +1618,9 @@ def _assign_source_or_sink(self, assignment, direction, name, net_name, terminal def assign_sink_to_objectface(self, assignment, direction=0, name=None, net_name=None): """Generate a sink on a face of an object. + .. deprecated:: 0.8.9 + This method is deprecated. Use the ``sink()`` method instead. + The face ID is selected based on the axis direction. It is the face that has the maximum or minimum in this axis direction. @@ -1638,6 +1645,11 @@ def assign_sink_to_objectface(self, assignment, direction=0, name=None, net_name >>> oModule.AssignSink """ + warnings.warn( + "This method is deprecated in 0.8.9. Use the ``sink()`` method.", + DeprecationWarning, + ) + assignment = self.modeler.convert_to_selections(assignment, True)[0] if isinstance(assignment, int): a = assignment @@ -1664,6 +1676,9 @@ def assign_sink_to_sheet( ): """Generate a sink on a sheet. + .. deprecated:: 0.8.9 + This method is deprecated. Use the ``sink()`` method instead. + Parameters ---------- assignment : @@ -1687,6 +1702,11 @@ def assign_sink_to_sheet( >>> oModule.AssignSink """ + warnings.warn( + "This method is deprecated in 0.8.9. Use the ``sink()`` method.", + DeprecationWarning, + ) + if not sink_name: sink_name = generate_unique_name("Sink") assignment = self.modeler.convert_to_selections(assignment, True)[0]