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

Method checkSource

SLiCAP/SLiCAPinstruction.py:1204–1244  ·  view source on GitHub ↗

Checks if the source has been defined and if it exists in the circuit. Called by **instruction.check()** and by **instruction.setSource( )**. :param need: If True, a source is required and an error message will be given if it missing. If False,

(self, need = True)

Source from the content-addressed store, hash-verified

1202 return
1203
1204 def checkSource(self, need = True):
1205 """
1206 Checks if the source has been defined and if it exists in the circuit.
1207
1208 Called by **instruction.check()** and by **instruction.setSource(<source>)**.
1209
1210
1211 :param need: If True, a source is required and an error message will be
1212 given if it missing. If False, only the presence of the
1213 indicated independent source in the circuit will be
1214 verified.
1215
1216 :type need: bool
1217 """
1218 if self.convType == "all":
1219 print("Error: Conversion type 'all' cannot automatically convert the source to 'DM' or 'CM'. " +
1220 "Use convtype=None instead.")
1221 self.errors += 1
1222 if need:
1223 if self.source == None:
1224 self.errors += 1
1225 print("Error: missing source definition.")
1226 if self.source != None:
1227 for i in range(len(self.source)):
1228 if self.source[i] == None:
1229 if need and i == 0:
1230 self.errors += 1
1231 print("Error: missing source definition.")
1232 elif self.source[i] != None and self.source[i] not in self.indepVars():
1233 self.errors += 1
1234 print("Error: unkown source: '{0}'.".format(self.source[i]))
1235 elif self.source[i] != None:
1236 if i == 0:
1237 self.srcUnits = self.source[i][0].upper()
1238 else:
1239 if self.source[i][0].upper() != self.srcUnits:
1240 self.errors += 1
1241 print("Error: two sources must be of the same type.")
1242 if self.srcUnits == 'I':
1243 self.srcUnits = 'A'
1244 return
1245
1246 def setDetector(self, detector):
1247 """

Callers 2

setSourceMethod · 0.95
checkMethod · 0.95

Calls 2

indepVarsMethod · 0.95
formatMethod · 0.80

Tested by

no test coverage detected