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

Method checkDetector

SLiCAP/SLiCAPinstruction.py:1293–1362  ·  view source on GitHub ↗

Checks if the detector has been defined and if it exists in the circuit. Called by **instruction.check()** and by **instruction.setDetector( )**.

(self)

Source from the content-addressed store, hash-verified

1291 return
1292
1293 def checkDetector(self):
1294 """
1295 Checks if the detector has been defined and if it exists in the circuit.
1296
1297 Called by **instruction.check()** and by **instruction.setDetector(<detector>)**.
1298 """
1299 if self.convType == "all":
1300 print("Error: Conversion type 'all' cannot automatically convert the detector to 'DM' or 'CM'. " +
1301 "Use convtype=None instead.")
1302 self.errors += 1
1303 if self.detector != None:
1304 self.detLabel = ''
1305 # detector has two nodes or two voltage sources
1306 if type(self.detector) == str:
1307 # Change the detector definition
1308 self.detector = [self.detector, None]
1309 elif type(self.detector) == list:
1310 numDets = len(self.detector)
1311 if numDets == 0:
1312 self.errors += 1
1313 print("Error: missing detector specification")
1314 elif numDets == 1:
1315 self.detector = [self.detector[0], None]
1316 elif numDets > 2:
1317 self.errors += 1
1318 print("Error: to many detectors.")
1319 if self.errors !=0:
1320 return
1321 detP = self.detector[0]
1322 detN = self.detector[1]
1323 if detP == None and detN == None:
1324 self.errors += 1
1325 print("Error: missing detector specification.")
1326 elif detP == detN:
1327 self.errors += 1
1328 print("Error: equal positive and negative detector.")
1329 elif detP == detN:
1330 self.errors += 1
1331 print("Error: two detectors must be of the same type.")
1332
1333 if self.errors == 0 and self.convType == None:
1334 if detP != None and detP not in self.depVars():
1335 self.errors += 1
1336 print("Error: unkown detector: '{0}'.".format(detP))
1337 print("Available detectors:", str(self.depVars()))
1338 elif detN != None and detN not in self.depVars():
1339 self.errors += 1
1340 print("Error: unkown detector: '{0}'.".format(detN))
1341 print("Available detectors:", str(self.depVars()))
1342
1343 if self.errors == 0 and self.lgRef != None:
1344 for lgRef in self.lgRef:
1345 if lgRef != None:
1346 # Impossible to calculate the asymptotic gain with these values
1347 forbidden = 'I_i_' + lgRef
1348 if detP == forbidden or detN == forbidden:
1349 self.errors += 1
1350 print("Error: forbidden combination of lgRef and detector.")

Callers 2

setDetectorMethod · 0.95
checkMethod · 0.95

Calls 2

depVarsMethod · 0.95
formatMethod · 0.80

Tested by

no test coverage detected