Skip to content

Commit

Permalink
CHORE: mutable args (#4805)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmalinve authored Jun 14, 2024
1 parent 2b58f5a commit a170167
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 54 deletions.
7 changes: 4 additions & 3 deletions pyaedt/application/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def get_traces_for_plot(
first_element_filter=None,
second_element_filter=None,
category="dB(S",
differential_pairs=[],
differential_pairs=None,
):
# type: (bool, bool, str, str, str, list) -> list
"""Retrieve a list of traces of specified designs ready to use in plot reports.
Expand All @@ -557,9 +557,9 @@ def get_traces_for_plot(
This parameter accepts ``*`` and ``?`` as special characters. The default is ``None``.
category : str, optional
Plot category name as in the report (including operator).
The default is ``"dB(S"``, which is the plot category name for capacitance.
The default is ``"dB(S)"``, which is the plot category name for capacitance.
differential_pairs : list, optional
Differential pairs defined. The default is ``[]``.
Differential pairs defined. The default is ``None`` in which case an empty list is set.
Returns
-------
Expand All @@ -576,6 +576,7 @@ def get_traces_for_plot(
... first_element_filter="*_U1_data?",
... second_element_filter="*_U0_*", category="dB(S")
"""
differential_pairs = [] if differential_pairs is None else differential_pairs
if not first_element_filter:
first_element_filter = "*"
if not second_element_filter:
Expand Down
6 changes: 4 additions & 2 deletions pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -3767,7 +3767,7 @@ def archive_project(
project_path=None,
include_external_files=True,
include_results_file=True,
additional_files=[],
additional_files=None,
notes="",
):
"""Archive the AEDT project and add a message.
Expand All @@ -3781,7 +3781,8 @@ def archive_project(
include_results_file : bool, optional
Whether to include simulation results files in the archive. The default is ``True``.
additional_files : list, optional
List of additional files to add to the archive. The default is ``[]``.
List of additional files to add to the archive.
The default is ``None`` in which case an empty list is set.
notes : str, optional
Simulation notes to add to the archive. The default is ``""``.
Expand All @@ -3796,6 +3797,7 @@ def archive_project(
>>> oProject.Save
>>> oProject.SaveProjectArchive
"""
additional_files = [] if additional_files is None else additional_files
msg_text = "Saving {0} Project".format(self.project_name)
self.logger.info(msg_text)
if not project_path:
Expand Down
6 changes: 4 additions & 2 deletions pyaedt/modeler/circuits/PrimitivesCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,16 @@ def create_interface_port(self, name, location=None, angle=0):
return False

@pyaedt_function_handler()
def create_page_port(self, name, location=[], angle=0):
def create_page_port(self, name, location=None, angle=0):
"""Create a page port.
Parameters
----------
name : str
Name of the port.
location : list, optional
Position on the X and Y axis. The default is ``None``.
Position on the X and Y axis.
If not provided the default is ``None``, in which case an empty list is set.
angle : optional
Angle rotation in degrees. The default is ``0``.
Expand All @@ -364,6 +365,7 @@ def create_page_port(self, name, location=[], angle=0):
>>> oEditor.CreatePagePort
"""
location = [] if location is None else location
xpos, ypos = self._get_location(location)

id = self.create_unique_id()
Expand Down
12 changes: 8 additions & 4 deletions pyaedt/modeler/circuits/PrimitivesNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,8 +1241,8 @@ def create_new_component_from_symbol(
time_stamp=1591858313,
description="",
refbase="x",
parameters=[],
values=[],
parameters=None,
values=None,
gref="",
):
"""Create a component from a symbol.
Expand All @@ -1260,9 +1260,11 @@ def create_new_component_from_symbol(
refbase : str, optional
Reference base. The default is ``"U"``.
parameters : list
List of parameters. The default is ``[]``.
List of parameters.
If not provided the default is ``None``, in which case an empty list is set.
values : list
List of parameter values. The default is ``[]``.
List of parameter values.
If not provided the default is ``None``, in which case an empty list is set.
gref : str, optional
Global Reference
Expand All @@ -1277,6 +1279,8 @@ def create_new_component_from_symbol(
>>> oModelManager.Add
>>> oComponentManager.Add
"""
parameters = [] if parameters is None else parameters
values = [] if values is None else values
arg = [
"NAME:" + name,
"Info:=",
Expand Down
66 changes: 23 additions & 43 deletions pyaedt/modules/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3159,29 +3159,29 @@ class FieldPlot:
def __init__(
self,
postprocessor,
objects=[],
surfaces=[],
lines=[],
cutplanes=[],
objects=None,
surfaces=None,
lines=None,
cutplanes=None,
solution="",
quantity="",
intrinsics={},
seeding_faces=[],
layer_nets=[],
intrinsics=None,
seeding_faces=None,
layer_nets=None,
layer_plot_type="LayerNetsExtFace",
):
self._postprocessor = postprocessor
self.oField = postprocessor.ofieldsreporter
self.volumes = objects
self.surfaces = surfaces
self.lines = lines
self.cutplanes = cutplanes
self.layer_nets = layer_nets
self.volumes = [] if objects is None else objects
self.surfaces = [] if surfaces is None else surfaces
self.lines = [] if lines is None else lines
self.cutplanes = [] if cutplanes is None else cutplanes
self.layer_nets = [] if layer_nets is None else layer_nets
self.layer_plot_type = layer_plot_type
self.seeding_faces = seeding_faces
self.seeding_faces = [] if seeding_faces is None else seeding_faces
self.solution = solution
self.quantity = quantity
self.intrinsics = intrinsics
self.intrinsics = {} if intrinsics is None else intrinsics
self.name = "Field_Plot"
self.plot_folder = "Field_Plot"
self.Filled = False
Expand Down Expand Up @@ -3308,21 +3308,11 @@ def intrinsicVar(self):
Returns
-------
list or dict
List or dictionary of the variables for the field plot.
Variables for the field plot.
"""
var = ""
if isinstance(self.intrinsics, list):
l = 0
while l < len(self.intrinsics):
val = self.intrinsics[l + 1]
if ":=" in self.intrinsics[l] and isinstance(self.intrinsics[l + 1], list):
val = self.intrinsics[l + 1][0]
ll = self.intrinsics[l].split(":=")
var += ll[0] + "='" + str(val) + "' "
l += 2
else:
for a in self.intrinsics:
var += a + "='" + str(self.intrinsics[a]) + "' "
for a in self.intrinsics:
var += a + "='" + str(self.intrinsics[a]) + "' "
return var

@property
Expand Down Expand Up @@ -3911,13 +3901,13 @@ def __init__(
max_frequency="1GHz",
ray_density=2,
bounces=5,
intrinsics={},
intrinsics=None,
):
self.is_creeping_wave = is_creeping_wave
self._postprocessor = postprocessor
self._ofield = postprocessor.ofieldsreporter
self.quantity = quantity
self.intrinsics = intrinsics
self.intrinsics = {} if intrinsics is None else intrinsics
self.name = "Field_Plot"
self.plot_folder = "Field_Plot"
self.max_frequency = max_frequency
Expand Down Expand Up @@ -3949,22 +3939,12 @@ def intrinsicVar(self):
Returns
-------
list or dict
List or dictionary of the variables for the field plot.
str
Variables for the field plot.
"""
var = ""
if isinstance(self.intrinsics, list):
l = 0
while l < len(self.intrinsics):
val = self.intrinsics[l + 1]
if ":=" in self.intrinsics[l] and isinstance(self.intrinsics[l + 1], list):
val = self.intrinsics[l + 1][0]
ll = self.intrinsics[l].split(":=")
var += ll[0] + "='" + str(val) + "' "
l += 2
else:
for a in self.intrinsics:
var += a + "='" + str(self.intrinsics[a]) + "' "
for a in self.intrinsics:
var += a + "='" + str(self.intrinsics[a]) + "' "
return var

@pyaedt_function_handler()
Expand Down

0 comments on commit a170167

Please sign in to comment.