MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _updateParDefs

Function _updateParDefs

SLiCAP/SLiCAPyacc.py:1064–1137  ·  view source on GitHub ↗

The parameter definitions of the parent circuit will be updated: Parameters of the child circuit as well as parameters in their expressions will be treated as follows: #. If the parameter is a parameter of the parent circuit, then the child needs to obtain the value given

(parentParDefs, childParDefs, parentParams, prototypeParams, parentRefDes)

Source from the content-addressed store, hash-verified

1062 return newElement, newParDefs
1063
1064def _updateParDefs(parentParDefs, childParDefs, parentParams, prototypeParams, parentRefDes):
1065 """
1066 The parameter definitions of the parent circuit will be updated:
1067
1068 Parameters of the child circuit as well as parameters in their expressions
1069 will be treated as follows:
1070
1071 #. If the parameter is a parameter of the parent circuit, then the child
1072 needs to obtain the value given with the parent circuit.
1073 #. Else if the parameter is a parameter of the prototype circuit, then the
1074 child needs to obtain the value given with the prototype circuit
1075 #. Else if the parameter is defined in a user library (in _USERPARAMS),
1076 then the definition from this library needs to be added to the parameter
1077 definitions of the parent circuit.
1078 #. Else if the parameter is defined in a system library (in SLiCAPPARAMS),
1079 then the definition from this library needs to be added to the parameter
1080 definitions of the parent circuit.
1081 #. Else: the parameter name will receive the postfix: _<parentRefDes)>.
1082
1083 :param newElement: Element of the subciorcuit that needs to be connected to
1084 the parent circuit.
1085 :type newElement: SLiCAPprotos.element
1086
1087 :param parentParams: Dictionary with key-value pairs of parameters of the
1088 parent element:
1089
1090 - key *str*: name of the parameter
1091 - value: *SympyExpression*: value or expression of
1092 this parameter
1093
1094 :param prototypeParams: Dictionary with key-value pairs of parameters of
1095 the prototype circuit:
1096
1097 - key *str*: name of the parameter
1098 - value: *SympyExpression*: value or expression of
1099 this parameter
1100
1101 :param parentRrefDes: Reference designator of the parent element
1102 :type parentRefDes: str
1103
1104 :return: newElement with updated node list
1105 :rtype: SLiCAPprotos.element
1106 """
1107 # Create a list with all parameters
1108 allParams = childParDefs.keys()
1109 allAtoms = []
1110 for parName in allParams:
1111 allAtoms += childParDefs[parName].atoms(sp.Symbol)
1112 allParams = [sp.Symbol(par) for par in allParams]
1113 allParams += allAtoms
1114 substDictNames = {}
1115 substDictValues = {}
1116 for parName in allParams:
1117 if parName != ini.laplace and parName != ini.frequency:
1118 if str(parName) in parentParams.keys():
1119 substDictValues[parName] = parentParams[str(parName)]
1120 elif str(parName) in prototypeParams.keys():
1121 substDictValues[parName] = prototypeParams[str(parName)]

Callers 1

_doExpandFunction · 0.85

Calls 2

fullSubsFunction · 0.90
_addParDefsParamFunction · 0.85

Tested by

no test coverage detected