diff --git a/DAS/visualizor.py b/DAS/visualizor.py index 31d3fea..dbebfb0 100644 --- a/DAS/visualizor.py +++ b/DAS/visualizor.py @@ -35,6 +35,13 @@ class Visualizor: self.config = config self.results = results os.makedirs("results/"+self.execID+"/plots", exist_ok=True) + + def __get_attrbs__(self, result): + text = str(result.shape).split("-") + d = dict() + for i in range(0, len(text), 2): + d[text[i]] = text[i + 1] + return d def plotAll(self): """Plot all the important elements of each result""" @@ -49,9 +56,9 @@ class Visualizor: def plotMissingSamples(self, result): """Plots the missing samples in the network""" conf = {} - text = str(result.shape).split("-") - conf["textBox"] = "Block Size: "+text[1]+"\nNumber of nodes: "+text[3]\ - +"\nFailure rate: "+text[7]+" \nNetwork degree: "+text[23]+"\nX: "+text[11]+" rows/columns" + attrbs = self.__get_attrbs__(result) + conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ + +"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+" \nNetwork degree: "+attrbs['nd'] conf["title"] = "Missing Samples" conf["type"] = "plot" conf["legLoc"] = 1 @@ -77,9 +84,9 @@ class Visualizor: vector2 = result.metrics["progress"]["validators ready"] vector3 = result.metrics["progress"]["samples received"] conf = {} - text = str(result.shape).split("-") - conf["textBox"] = "Block Size: "+text[1]+"\nNumber of nodes: "+text[3]\ - +"\nFailure rate: "+text[7]+" \nNetwork degree: "+text[23]+"\nX: "+text[11]+" rows/columns" + attrbs = self.__get_attrbs__(result) + conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ + +"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+" \nNetwork degree: "+attrbs['nd'] conf["title"] = "Nodes/validators ready" conf["type"] = "plot" conf["legLoc"] = 2 @@ -109,9 +116,9 @@ class Visualizor: vector2[i] = (vector2[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000 vector3[i] = (vector3[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000 conf = {} - text = str(result.shape).split("-") - conf["textBox"] = "Block Size: "+text[1]+"\nNumber of nodes: "+text[3]\ - +"\nFailure rate: "+text[7]+" \nNetwork degree: "+text[23]+"\nX: "+text[11]+" rows/columns" + attrbs = self.__get_attrbs__(result) + conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ + +"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+" \nNetwork degree: "+attrbs['nd'] conf["title"] = "Sent data" conf["type"] = "plot" conf["legLoc"] = 2 @@ -139,9 +146,9 @@ class Visualizor: vector1[i] = (vector1[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000 vector2[i] = (vector2[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000 conf = {} - text = str(result.shape).split("-") - conf["textBox"] = "Block Size: "+text[1]+"\nNumber of nodes: "+text[3]\ - +"\nFailure rate: "+text[7]+" \nNetwork degree: "+text[23]+"\nX: "+text[11]+" rows/columns" + attrbs = self.__get_attrbs__(result) + conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ + +"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+" \nNetwork degree: "+attrbs['nd'] conf["title"] = "Received data" conf["type"] = "plot" conf["legLoc"] = 2 @@ -169,9 +176,9 @@ class Visualizor: vector1[i] = (vector1[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000 vector2[i] = (vector2[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000 conf = {} - text = str(result.shape).split("-") - conf["textBox"] = "Block Size: "+text[1]+"\nNumber of nodes: "+text[3]\ - +"\nFailure rate: "+text[7]+" \nNetwork degree: "+text[23]+"\nX: "+text[11]+" rows/columns" + attrbs = self.__get_attrbs__(result) + conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ + +"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+" \nNetwork degree: "+attrbs['nd'] conf["title"] = "Duplicated data" conf["type"] = "plot" conf["legLoc"] = 2 @@ -200,9 +207,9 @@ class Visualizor: elif len(vector1) < len(vector2): vector1 += [np.nan] * (len(vector2) - len(vector1)) conf = {} - text = str(result.shape).split("-") - conf["textBox"] = "Block Size: "+text[1]+"\nNumber of nodes: "+text[3]\ - +"\nFailure rate: "+text[7]+" \nNetwork degree: "+text[23]+"\nX: "+text[11]+" rows/columns" + attrbs = self.__get_attrbs__(result) + conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ + +"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+" \nNetwork degree: "+attrbs['nd'] conf["title"] = "Row/Column distribution" conf["type"] = "bar" conf["legLoc"] = 2