MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / _updateSRCnames

Function _updateSRCnames

SLiCAP/SLiCAPexecute.py:555–650  ·  view source on GitHub ↗

If instr.convType == "dd" or "cc" and ini.update_srcnames == True, this function updates the names and values of noise and dcvar sources after a doNoise() or doDcvar() instruction, respectively. It replaces the pair extensions with "_D", or "_C" for conversion types "dd" and "

(instr)

Source from the content-addressed store, hash-verified

553 return instr
554
555def _updateSRCnames(instr):
556 """
557 If instr.convType == "dd" or "cc" and ini.update_srcnames == True, this
558 function updates the names and values of noise and dcvar sources after a
559 doNoise() or doDcvar() instruction, respectively.
560 It replaces the pair extensions with "_D", or "_C" for conversion types "dd"
561 and "cc", respectively.
562 These source names are the keys of the dictionaries:
563 - instr.snoiseTerms
564 - instr.inoiseTerms
565 - instr.onoiseTerms
566 - instr.svarTerms
567 - instr.ivarTerms
568 - instr.ovarTerms
569
570 The values are the summ of the paired sources.
571
572 :param instr: SLiCAP.SLiCAP.intruction object that hold the instruction
573 data and its results
574 :type instr: SLiCAP.SLiCAP.intruction object
575
576 :return: instruction with updated names in the above result dictionaries
577 :rtype: SLiCAP.SLiCAP.intruction object
578 """
579 if ini.update_srcnames and (instr.convType == 'dd' or instr.convType == 'cc') and (instr.dataType == "noise" or instr.dataType == "dcvar"):
580 if instr.dataType == 'noise':
581 sTerms = instr.snoiseTerms
582 iTerms = instr.inoiseTerms
583 oTerms = instr.onoiseTerms
584 elif instr.dataType=="dcvar":
585 sTerms = instr.svarTerms
586 iTerms = instr.ivarTerms
587 oTerms = instr.ovarTerms
588 srcNames = sTerms.keys()
589 newSterms = {}
590 newOterms = {}
591 newIterms = {}
592 for srcName in srcNames:
593 baseName = srcName[:-1]
594 if (srcName[-1] == instr.pairExt[0] and baseName + instr.pairExt[1] in srcNames) or (srcName[-1] == instr.pairExt[1] and baseName + instr.pairExt[0] in srcNames):
595 if type(sTerms[srcName]) == list:
596 nsteps = len(sTerms[srcName])
597 else:
598 nsteps = 0
599 if instr.convType == "dd":
600 ext = "D"
601 elif instr.convType == "cc":
602 ext = "C"
603 vi = srcName[0].upper()
604 if baseName[-1] == "_":
605 newName = baseName + ext
606 else:
607 newName = baseName + "_" + ext
608 if newName not in newSterms.keys():
609 if vi == "V":
610 if ext == "D":
611 if nsteps:
612 newSterms[newName] = [sTerms[baseName + instr.pairExt[0]][i] + sTerms[baseName + instr.pairExt[1]][i] for i in range(nsteps)]

Callers 2

_doNoiseFunction · 0.85
_doDCvarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected