def eobs2(obs, domain): def mixObsWithLoc(loc): newObs = copy.deepcopy(obs) newObs["label"] = newObs["label"].replace("%loc",loc) newObs["algexp"] = substituteDataArrayElementInString("%loc", newObs["algexp"], locations[loc]) newObs["algexp"] = newObs["algexp"].replace("%loc",loc) return newObs def mixObsWithOrgDst(matrixCell): (org, dst, r) = matrixCell if (options.fullMatrix == False and r == 0): return nullInstruction if (org != dst): newObs = copy.deepcopy(obs) newObs["label"] = newObs["label"].replace("%org",org) newObs["label"] = newObs["label"].replace("%dst",dst) newObs["algexp"] = substituteDataArrayElementInString("%org", newObs["algexp"], locations[org]) newObs["algexp"] = substituteDataArrayElementInString("%dst", newObs["algexp"], locations[dst]) newObs["algexp"] = newObs["algexp"].replace("%cell", str(r)) newObs["algexp"] = newObs["algexp"].replace("%org",org) newObs["algexp"] = newObs["algexp"].replace("%dst",dst) return newObs else: return nullInstruction obsBuilder = None if (domain[0].__class__ == "".__class__): #if it is string, it is just loc obsBuilder = mixObsWithLoc else: #the type is tuple, it is a matrix obsBuilder = mixObsWithOrgDst for r in map(obsBuilder, domain): printing.printObs2(r)