Skip to content

Remove the mutable from the defaults argument. #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyaedt/application/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ def generate_unique_setup_name(self, setup_name=None):
return setup_name

@pyaedt_function_handler()
def create_setup(self, setupname="MySetupAuto", setuptype=None, props={}):
def create_setup(self, setupname="MySetupAuto", setuptype=None, props=None):
"""Create a setup.

Parameters
Expand Down Expand Up @@ -1205,6 +1205,9 @@ def create_setup(self, setupname="MySetupAuto", setuptype=None, props={}):
...
pyaedt info: Sweep was created correctly.
"""
if props == None:
props = {}

if setuptype is None:
setuptype = self.design_solutions.default_setup
name = self.generate_unique_setup_name(setupname)
Expand Down
8 changes: 7 additions & 1 deletion pyaedt/application/Analysis3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def export3DModel(self, fileName, filePath, fileFormat=".step", object_list=[],
return self.export_3d_model(fileName, filePath, fileFormat, object_list, removed_objects)

@pyaedt_function_handler()
def export_3d_model(self, fileName, filePath, fileFormat=".step", object_list=[], removed_objects=[]):
def export_3d_model(self, fileName, filePath, fileFormat=".step", object_list=None, removed_objects=None):
"""Export the 3D model.

Parameters
Expand All @@ -452,6 +452,12 @@ def export_3d_model(self, fileName, filePath, fileFormat=".step", object_list=[]

>>> oEditor.Export
"""

if object_list == None:
object_list = []
if removed_objects == None:
removed_objects = []

if not object_list:
allObjects = self.modeler.object_names
if removed_objects:
Expand Down
19 changes: 16 additions & 3 deletions pyaedt/application/AnalysisNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def get_all_sparameter_list(self, excitation_names=[]):
return spar

@pyaedt_function_handler()
def get_all_return_loss_list(self, excitation_names=[], excitation_name_prefix=""):
def get_all_return_loss_list(self, excitation_names=None, excitation_name_prefix=""):
"""Retrieve a list of all return losses for a list of exctitations.

Parameters
Expand All @@ -198,6 +198,9 @@ def get_all_return_loss_list(self, excitation_names=[], excitation_name_prefix="

>>> oEditor.GetAllPorts
"""
if excitation_names == None:
excitation_names = []

if not excitation_names:
excitation_names = self.excitations
if excitation_name_prefix:
Expand All @@ -208,7 +211,7 @@ def get_all_return_loss_list(self, excitation_names=[], excitation_name_prefix="
return spar

@pyaedt_function_handler()
def get_all_insertion_loss_list(self, trlist=[], reclist=[], tx_prefix="", rx_prefix=""):
def get_all_insertion_loss_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix=""):
"""Retrieve a list of all insertion losses from two lists of excitations (driver and receiver).

Parameters
Expand All @@ -234,6 +237,11 @@ def get_all_insertion_loss_list(self, trlist=[], reclist=[], tx_prefix="", rx_pr

>>> oEditor.GetAllPorts
"""
if trlist == None:
trlist = []
if reclist == None:
reclist = []

spar = []
if not trlist:
trlist = [i for i in self.excitations if tx_prefix in i]
Expand Down Expand Up @@ -280,7 +288,7 @@ def get_next_xtalk_list(self, trlist=[], tx_prefix=""):
return next

@pyaedt_function_handler()
def get_fext_xtalk_list(self, trlist=[], reclist=[], tx_prefix="", rx_prefix="", skip_same_index_couples=True):
def get_fext_xtalk_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix="", skip_same_index_couples=True):
"""Retrieve a list of all the far end XTalks from two lists of exctitations (driver and receiver).

Parameters
Expand Down Expand Up @@ -312,6 +320,11 @@ def get_fext_xtalk_list(self, trlist=[], reclist=[], tx_prefix="", rx_prefix="",

>>> oEditor.GetAllPorts
"""
if trlist == None:
trlist = []
if reclist == None:
reclist = []

fext = []
if not trlist:
trlist = [i for i in self.excitations if tx_prefix in i]
Expand Down
7 changes: 6 additions & 1 deletion pyaedt/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def import_touchstone_solution(self, filename, solution_name="Imported_Data"):
return portnames

@pyaedt_function_handler()
def export_touchstone(self, solutionname, sweepname, filename=None, variation=[], variations_value=[]):
def export_touchstone(self, solutionname, sweepname, filename=None, variation=None, variations_value=None):
"""Export the Touchstone file to a local folder.

Parameters
Expand Down Expand Up @@ -778,6 +778,11 @@ def export_touchstone(self, solutionname, sweepname, filename=None, variation=[]

>>> oDesign.ExportNetworkData
"""
if variation == None:
variation = []
if variations_value == None:
variations_value = []

# Normalize the save path
if not filename:
appendix = ""
Expand Down
5 changes: 4 additions & 1 deletion pyaedt/edb_core/padstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def get_pad_parameters(self, pin, layername, pad_type=0):
return geom_type, parameters, offset_x, offset_y, rot

@pyaedt_function_handler()
def get_via_instance_from_net(self, net_list=[]):
def get_via_instance_from_net(self, net_list=None):
"""Get the list for Edb vias from net name list.

Parameters
Expand All @@ -339,6 +339,9 @@ def get_via_instance_from_net(self, net_list=[]):
list of Edb.Cell.Primitive.PadstackInstance
list of EDB vias.
"""
if net_list == None:
net_list = []

if not isinstance(net_list, list):
net_list = [net_list]
layout_lobj_collection = self._active_layout.GetLayoutInstance().GetAllLayoutObjInstances()
Expand Down
18 changes: 14 additions & 4 deletions pyaedt/icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,10 +1432,10 @@ def assign_em_losses(
setupname="Setup1",
sweepname="LastAdaptive",
map_frequency=None,
surface_objects=[],
surface_objects=None,
source_project_name=None,
paramlist=[],
object_list=[],
paramlist=None,
object_list=None,
):
"""Map EM losses to an Icepak design.

Expand Down Expand Up @@ -1470,6 +1470,13 @@ def assign_em_losses(

>>> oModule.AssignEMLoss
"""
if surface_objects == None:
surface_objects = []
if paramlist == None:
paramlist = []
if object_list == None:
object_list = []

self.logger.info("Mapping HFSS EM losses.")
oName = self.project_name
if oName == source_project_name or source_project_name is None:
Expand Down Expand Up @@ -1730,7 +1737,7 @@ def export_summary(
geometryType="Volume",
quantity="Temperature",
variation="",
variationlist=[],
variationlist=None,
):
"""Export a fields summary of all objects.

Expand Down Expand Up @@ -1764,6 +1771,9 @@ def export_summary(
>>> oModule.EditFieldsSummarySetting
>>> oModule.ExportFieldsSummary
"""
if variationlist == None:
variationlist = []

all_objs = list(self.modeler.oeditor.GetObjectsInGroup("Solids"))
all_objs_NonModeled = list(self.modeler.oeditor.GetObjectsInGroup("Non Model"))
all_objs_model = [item for item in all_objs if item not in all_objs_NonModeled]
Expand Down
5 changes: 4 additions & 1 deletion pyaedt/modeler/PrimitivesEmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _add_property(self, property_name, property_value):
self.__dict__[property_name] = property_value
return True

def get_prop_nodes(self, property_filter={}):
def get_prop_nodes(self, property_filter=None):
"""Get all property nodes that match a set of key,value pairs.

Args:
Expand All @@ -423,6 +423,9 @@ def get_prop_nodes(self, property_filter={}):
Returns:
list: All matching nodes (EmitComponentPropNode).
"""
if property_filter == None:
property_filter = {}

filtered_nodes = []
nodes_to_expand = [self.root_prop_node]
while nodes_to_expand:
Expand Down
15 changes: 12 additions & 3 deletions pyaedt/modeler/PrimitivesMaxwellCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, modeler):
pass

@pyaedt_function_handler()
def create_resistor(self, compname=None, value=50, location=[], angle=0, use_instance_id_netlist=False):
def create_resistor(self, compname=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create a resistor.

Parameters
Expand All @@ -83,6 +83,9 @@ def create_resistor(self, compname=None, value=50, location=[], angle=0, use_ins

>>> oEditor.CreateComponent
"""
if location == None:
location = []

id = self.create_component(
compname,
component_library="Passive Elements",
Expand All @@ -97,7 +100,7 @@ def create_resistor(self, compname=None, value=50, location=[], angle=0, use_ins
return id

@pyaedt_function_handler()
def create_inductor(self, compname=None, value=50, location=[], angle=0, use_instance_id_netlist=False):
def create_inductor(self, compname=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create an inductor.

Parameters
Expand All @@ -123,6 +126,9 @@ def create_inductor(self, compname=None, value=50, location=[], angle=0, use_ins

>>> oEditor.CreateComponent
"""
if location == None:
location = []

id = self.create_component(
compname,
component_library="Passive Elements",
Expand Down Expand Up @@ -175,7 +181,7 @@ def create_capacitor(self, compname=None, value=50, location=[], angle=0, use_in
return id

@pyaedt_function_handler()
def create_diode(self, compname=None, location=[], angle=0, use_instance_id_netlist=False):
def create_diode(self, compname=None, location=None, angle=0, use_instance_id_netlist=False):
"""Create a diode.

Parameters
Expand All @@ -199,6 +205,9 @@ def create_diode(self, compname=None, location=[], angle=0, use_instance_id_netl

>>> oEditor.CreateComponent
"""
if location == None:
location = []

id = self.create_component(
compname,
component_library="Passive Elements",
Expand Down
18 changes: 15 additions & 3 deletions pyaedt/modeler/PrimitivesNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def create_inductor(self, compname=None, value=50, location=[], angle=0, use_ins
return cmpid

@pyaedt_function_handler()
def create_capacitor(self, compname=None, value=50, location=[], angle=0, use_instance_id_netlist=False):
def create_capacitor(self, compname=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create a capacitor.

Parameters
Expand All @@ -557,6 +557,10 @@ def create_capacitor(self, compname=None, value=50, location=[], angle=0, use_in

>>> oEditor.CreateComponent
"""

if location == None:
location = []

cmpid = self.create_component(
compname,
component_library="Capacitors",
Expand All @@ -570,7 +574,7 @@ def create_capacitor(self, compname=None, value=50, location=[], angle=0, use_in
return cmpid

@pyaedt_function_handler()
def create_voltage_dc(self, compname=None, value=1, location=[], angle=0, use_instance_id_netlist=False):
def create_voltage_dc(self, compname=None, value=1, location=None, angle=0, use_instance_id_netlist=False):
"""Create a voltage DC source.

Parameters
Expand All @@ -597,6 +601,9 @@ def create_voltage_dc(self, compname=None, value=1, location=[], angle=0, use_in

>>> oEditor.CreateComponent
"""
if location == None:
location = []

cmpid = self.create_component(
compname,
component_library="Independent Sources",
Expand Down Expand Up @@ -757,7 +764,9 @@ def create_current_dc(self, compname=None, value=1, location=[], angle=0, use_in
cmpid.set_property("DC", value)
return cmpid

def create_coupling_inductors(self, compname, l1, l2, value=1, location=[], angle=0, use_instance_id_netlist=False):
def create_coupling_inductors(
self, compname, l1, l2, value=1, location=None, angle=0, use_instance_id_netlist=False
):
"""Create a coupling inductor.

Parameters
Expand Down Expand Up @@ -788,6 +797,9 @@ def create_coupling_inductors(self, compname, l1, l2, value=1, location=[], angl

>>> oEditor.CreateComponent
"""
if location == None:
location = []

cmpid = self.create_component(
compname,
component_library="Inductors",
Expand Down
5 changes: 4 additions & 1 deletion pyaedt/modeler/PrimitivesTwinBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def create_resistor(self, compname=None, value=50, location=[], angle=0, use_ins
return id

@pyaedt_function_handler()
def create_inductor(self, compname=None, value=50, location=[], angle=0, use_instance_id_netlist=False):
def create_inductor(self, compname=None, value=50, location=None, angle=0, use_instance_id_netlist=False):
"""Create an inductor.

Parameters
Expand All @@ -146,6 +146,9 @@ def create_inductor(self, compname=None, value=50, location=[], angle=0, use_ins

>>> oEditor.CreateComponent
"""
if location == None:
location = []

id = self.create_component(
compname,
component_library="Basic Elements\\Circuit\\Passive Elements",
Expand Down