aboutsummaryrefslogtreecommitdiffstats
path: root/Metrics/Metrics-Calculation/metrics_plot/utils
diff options
context:
space:
mode:
Diffstat (limited to 'Metrics/Metrics-Calculation/metrics_plot/utils')
-rw-r--r--Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py4
-rw-r--r--Metrics/Metrics-Calculation/metrics_plot/utils/constants.py5
-rw-r--r--Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py17
3 files changed, 19 insertions, 7 deletions
diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py
index d6bdad0d..feb9a0a9 100644
--- a/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py
+++ b/Metrics/Metrics-Calculation/metrics_plot/utils/GraphType.py
@@ -25,6 +25,8 @@ class GraphStat:
25 # init with teh file name of the stat 25 # init with teh file name of the stat
26 def __init__(self, filename): 26 def __init__(self, filename):
27 contents, self.out_d, self.na, self.mpc = reader.getmetrics(filename) 27 contents, self.out_d, self.na, self.mpc = reader.getmetrics(filename)
28 self.num_nodes = np.array(contents[constants.NUMBER_NODES]) 28 self.numNodes = np.array(contents[constants.NUMBER_NODES])
29 if constants.STATE_ID in contents: 29 if constants.STATE_ID in contents:
30 self.id = (contents[constants.STATE_ID])[0] 30 self.id = (contents[constants.STATE_ID])[0]
31 if constants.Node_TYPE_KEY in contents:
32 self.nodeTypeStat = contents[constants.Node_TYPE_KEY]
diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py b/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py
index aba81b13..51e538f8 100644
--- a/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py
+++ b/Metrics/Metrics-Calculation/metrics_plot/utils/constants.py
@@ -18,8 +18,13 @@ METAMODEL = 'Meta Mode'
18 18
19STATE_ID = 'State Id' 19STATE_ID = 'State Id'
20 20
21NODE_TYPE = 'Node Type'
22
23Node_TYPE_KEY = 'NodeType'
24
21HUMAN_OUT_D_REP = '../input/humanOutput/R_2015225_run_1.csv' 25HUMAN_OUT_D_REP = '../input/humanOutput/R_2015225_run_1.csv'
22 26
23HUMAN_MPC_REP = '../input/humanOutput/R_2016324_run_1.csv' 27HUMAN_MPC_REP = '../input/humanOutput/R_2016324_run_1.csv'
24 28
25HUMAN_NA_REP = '../input/humanOutput/R_2017419_run_1.csv' 29HUMAN_NA_REP = '../input/humanOutput/R_2017419_run_1.csv'
30
diff --git a/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py b/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py
index 33378ce5..1cec2f0c 100644
--- a/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py
+++ b/Metrics/Metrics-Calculation/metrics_plot/utils/readCSV.py
@@ -13,8 +13,10 @@ def readcsvfile(filename):
13 13
14 contents = {} 14 contents = {}
15 with open(filename) as f: 15 with open(filename) as f:
16 for i, line in enumerate(f): 16 data = list(f)
17 arr = line.split(',') 17 f.close()
18 for i, line in enumerate(data):
19 arr = line.replace('\n', '').split(',')
18 # if there is no element in the line, continue 20 # if there is no element in the line, continue
19 if len(line) < 0: continue 21 if len(line) < 0: continue
20 # else check for contents 22 # else check for contents
@@ -24,14 +26,17 @@ def readcsvfile(filename):
24 # meta models are string 26 # meta models are string
25 elif(arr[0] == constants.METAMODEL): 27 elif(arr[0] == constants.METAMODEL):
26 contents[constants.METAMODEL] = arr[1:] 28 contents[constants.METAMODEL] = arr[1:]
27 # NA and OD are integers 29 # Node types
30 elif(arr[0] == constants.NODE_TYPE):
31 types = data[i+1].replace('\n', '').split(',')
32 numbers = data[i+2].replace('\n', '').split(',')
33 contents[constants.Node_TYPE_KEY] = {t : n for t, n in zip(types, numbers)}
34 # NA and OD are integers, and store other information as string
28 else: 35 else:
29 try: 36 try:
30 contents[arr[0]] = list(map(int, arr[1:])) 37 contents[arr[0]] = list(map(int, arr[1:]))
31 except: 38 except:
32 message = arr[0], ' is not integer' 39 contents[arr[0]] = arr[1:]
33 #print(message)
34 f.close()
35 return contents 40 return contents
36 41
37def checkAndReshape(arr): 42def checkAndReshape(arr):