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

Function _doExpand

SLiCAP/SLiCAPyacc.py:916–945  ·  view source on GitHub ↗
(el, circuitObject)

Source from the content-addressed store, hash-verified

914 return circuitObject
915
916def _doExpand(el, circuitObject):
917 parentRefDes = el.refDes
918 parentNodes = el.nodes
919 parentParams = el.params
920 prototypeNodes = el.model.nodes
921 prototypeParams = el.model.params
922 parentParDefs = circuitObject.parDefs
923 childParDefs = el.model.parDefs
924 circuitObject.parDefs = _updateParDefs(parentParDefs, childParDefs, parentParams, prototypeParams, parentRefDes)
925 for subElement in list(el.model.elements.keys()):
926 newElement = deepcopy(el.model.elements[subElement])
927 # Update the refDes
928 newElement.refDes = el.model.elements[subElement].refDes + '_' + el.refDes
929 # Update the referenced elements
930 for i in range(len(newElement.refs)):
931 newElement.refs[i] += '_' + el.refDes
932 # Update the nodes
933 newElement = _updateNodes(newElement, parentNodes, prototypeNodes, parentRefDes)
934 # Update the parameters used in element expressions and in parameter definitions
935 newElement, newParDefs = _updateElementParams(newElement, parentParams, prototypeParams, parentRefDes)
936 for key in newParDefs.keys():
937 if key not in circuitObject.parDefs.keys():
938 circuitObject.parDefs[key] = newParDefs[key]
939 # Add the new element to the parent circuit
940 circuitObject.elements[newElement.refDes] = newElement
941 # If the new element is a sub circuit, it needs to be expanded
942 if isinstance(newElement.model, circuit):
943 circuitObject = _doExpand(newElement, circuitObject)
944 del circuitObject.elements[el.refDes]
945 return circuitObject
946
947def _updateNodes(newElement, parentNodes, prototypeNodes, parentRefDes):
948 """

Callers 1

_expandCircuitFunction · 0.85

Calls 3

_updateParDefsFunction · 0.85
_updateNodesFunction · 0.85
_updateElementParamsFunction · 0.85

Tested by

no test coverage detected