Commit 2fcc1e5e authored by Martin Beseda's avatar Martin Beseda

TMP: Added part of recursion in

parent f87eedab
...@@ -1077,22 +1077,47 @@ def getYLabelVals(valuesLst, yLabelCat, yLabelArg, summate=True): ...@@ -1077,22 +1077,47 @@ def getYLabelVals(valuesLst, yLabelCat, yLabelArg, summate=True):
def getElFromDic(d, i): def getElFromDic(d, i):
return {k: d[k][i] for k in d} return {k: d[k][i] for k in d}
# Fce pro ziskani objektu ze stromu slovniku,
# kde cesta je zadana listem klicu
def getObjFromPath(pathLst, dic):
tmp = dic
for key in pathLst:
tmp = tmp[key]
return tmp
# @info construction of the sumarySources structure # @info construction of the sumarySources structure
# @param items (dictionary) dictioray of results for this settings, key funcLabel with a list of results as a value of the key # @param items (dictionary) dictioray of results for this settings, key funcLabel with a list of results as a value of the key
# @param path (list) list of keys, that must be added as a path to this settings in final structure # @param path (list) list of keys, that must be added as a path to this settings in final structure
# @return (void) # @return (void)
# @note edits global structure summarySources # @note edits global structure summarySources
def func(items, path): def constructSummarySources(items, path, slideshowCreator, summarySources, conf):
for cat in ('vals', 'inds'):
for dic in summarySources.values():
tmp = dict()
dic[cat][conf] = tmp
for key in path:
tmp2 = dict()
tmp[key] = tmp2
tmp = tmp2
for funcLabel, val in items:
tmp[funcLabel] = {'singleProgramStarts': list(),
'avgProgramStart': list()}
print(path)
dummy = 1
for funcLabel, val in items: for funcLabel, val in items:
for cat in ('avg', 'full', 'min', 'max'): for cat in ('avg', 'full', 'min', 'max'):
for c in ('vals', 'inds'): #for c in ('vals', 'inds'):
summarySources[cat][c][conf][funcLabel] = {'singleProgramStarts': list(), #summarySources[cat][c][conf][funcLabel] = {'singleProgramStarts': list(),
'avgProgramStart': list()} # 'avgProgramStart': list()}
# Zapisu do listu data pro danou konfiguraci - pro vypocty procent atd. # Zapisu do listu data pro danou konfiguraci - pro vypocty procent atd.
# 1 polozka listu = 1 volani programu (init) # 1 polozka listu = 1 volani programu (init)
for dic in val: for dic in val:
summarySources[cat]['vals'][conf][funcLabel]['singleProgramStarts'].append(dic[cat])
summarySourcesTmp = getObjFromPath(path, summarySources[cat]['vals'][conf])
summarySourcesTmp[funcLabel]['singleProgramStarts'].append(dic[cat])
######################################################################### #########################################################################
# Zapisu zdroje pro vykreslovani grafu - prumer, minimum, maximum, full # # Zapisu zdroje pro vykreslovani grafu - prumer, minimum, maximum, full #
...@@ -1107,7 +1132,7 @@ def func(items, path): ...@@ -1107,7 +1132,7 @@ def func(items, path):
# - do nej se budou ukladat indexy dat za # - do nej se budou ukladat indexy dat za
# jednotlive iterace v jednom startu programu # jednotlive iterace v jednom startu programu
oneProgStartIndices = list() oneProgStartIndices = list()
summarySources['full']['inds'][conf][funcLabel]['singleProgramStarts']\ getObjFromPath(path, summarySources['full']['inds'][conf])[funcLabel]['singleProgramStarts']\
.append(oneProgStartIndices) .append(oneProgStartIndices)
# Vytvarim list tuplu za kazdou iteraci # Vytvarim list tuplu za kazdou iteraci
...@@ -1128,7 +1153,8 @@ def func(items, path): ...@@ -1128,7 +1153,8 @@ def func(items, path):
oneProgStartIndices.append(slideshowCreator.getNumOfDataSources()) oneProgStartIndices.append(slideshowCreator.getNumOfDataSources())
slideshowCreator.createAndAddDataSourcesTexCode([sorted(nthIterData)], 0, False, 0, 1) slideshowCreator.createAndAddDataSourcesTexCode([sorted(nthIterData)], 0, False, 0, 1)
else: else:
summarySources[cat]['inds'][conf][funcLabel]['singleProgramStarts']\ summarySourcesTmp = getObjFromPath(path, summarySources[cat]['inds'][conf])
summarySourcesTmp[funcLabel]['singleProgramStarts']\
.append(slideshowCreator.getIndOfLastDataSource()) .append(slideshowCreator.getIndOfLastDataSource())
slideshowCreator.createAndAddDataSourcesTexCode([sorted(dic[cat])], 0, False, 0, 1) slideshowCreator.createAndAddDataSourcesTexCode([sorted(dic[cat])], 0, False, 0, 1)
...@@ -1139,7 +1165,8 @@ def func(items, path): ...@@ -1139,7 +1165,8 @@ def func(items, path):
# Ziskam maximalni pocet iteraci za jedno volani # Ziskam maximalni pocet iteraci za jedno volani
# fce - jen pro 'full'! # fce - jen pro 'full'!
maxNumOfItersPerStart = 1 maxNumOfItersPerStart = 1
for singleProgramStart in summarySources[cat]['vals'][conf][funcLabel]['singleProgramStarts']: for singleProgramStart in getObjFromPath(path, summarySources[cat]['vals'][conf])\
[funcLabel]['singleProgramStarts']:
for XYvals in singleProgramStart: for XYvals in singleProgramStart:
if cat == 'full': if cat == 'full':
...@@ -1158,7 +1185,9 @@ def func(items, path): ...@@ -1158,7 +1185,9 @@ def func(items, path):
# ze vsech volani # ze vsech volani
avgValFromAllStartsPerOneXLabelKey = list() avgValFromAllStartsPerOneXLabelKey = list()
for singleProgramStart in summarySources[cat]['vals'][conf][funcLabel]['singleProgramStarts']: for singleProgramStart in getObjFromPath(path, summarySources[cat]['vals'][conf])\
[funcLabel]['singleProgramStarts']:
if cat == 'full': if cat == 'full':
xyVal = [None for i in range(maxNumOfItersPerStart)] xyVal = [None for i in range(maxNumOfItersPerStart)]
for XYvals in singleProgramStart: for XYvals in singleProgramStart:
...@@ -1182,48 +1211,54 @@ def func(items, path): ...@@ -1182,48 +1211,54 @@ def func(items, path):
avgValFromAllStartsPerOneXLabelKey.append(xyVal) avgValFromAllStartsPerOneXLabelKey.append(xyVal)
# Z hodnot za vsechna volani ziskam prumernou hodnotu # Z hodnot za vsechna volani ziskam prumernou hodnotu
if cat == 'full': if cat == 'full':
valsTmp = [[e[i] for e in avgValFromAllStartsPerOneXLabelKey if e[i] is not None] valsTmp = [[e[i] for e in avgValFromAllStartsPerOneXLabelKey if e[i] is not None]
for i in range(maxNumOfItersPerStart)] for i in range(maxNumOfItersPerStart)]
if valsTmp: if valsTmp:
summarySources[cat]['vals'][conf][funcLabel]['avgProgramStart']\ getObjFromPath(path, summarySources[cat]['vals'][conf])[funcLabel]['avgProgramStart']\
.append((xLabelKey, [numpy.mean(e) if e else None for e in valsTmp])) .append((xLabelKey, [numpy.mean(e) if e else None for e in valsTmp]))
else: else:
valsTmp = [e for e in avgValFromAllStartsPerOneXLabelKey if e is not None] valsTmp = [e for e in avgValFromAllStartsPerOneXLabelKey if e is not None]
if valsTmp: if valsTmp:
summarySources[cat]['vals'][conf][funcLabel]['avgProgramStart']\ getObjFromPath(path, summarySources[cat]['vals'][conf])[funcLabel]['avgProgramStart']\
.append((xLabelKey, numpy.mean(valsTmp))) .append((xLabelKey, numpy.mean(valsTmp)))
# Zapisu data za prumerny start programu jako zdroj pro graf # Zapisu data za prumerny start programu jako zdroj pro graf
if cat != 'full': if cat != 'full':
summarySources[cat]['inds'][conf][funcLabel]['avgProgramStart']\ getObjFromPath(path, summarySources[cat]['inds'][conf])[funcLabel]['avgProgramStart']\
.append(slideshowCreator.getIndOfLastDataSource()) .append(slideshowCreator.getIndOfLastDataSource())
slideshowCreator.createAndAddDataSourcesTexCode( slideshowCreator.createAndAddDataSourcesTexCode(
[sorted(summarySources[cat]['vals'][conf][funcLabel]['avgProgramStart'])], [sorted(getObjFromPath(path, summarySources[cat]['vals'][conf])[funcLabel]['avgProgramStart'])],
0, False, 0, 1) 0, False, 0, 1)
else: else:
plotDataTmp = [[(e[0], e[1][i]) plotDataTmp = [[(e[0], e[1][i])
for e in summarySources[cat]['vals'][conf][funcLabel]['avgProgramStart'] for e in getObjFromPath(path, summarySources[cat]['vals'][conf])[funcLabel]['avgProgramStart']
if e[1][i] is not None] if e[1][i] is not None]
for i in range(maxNumOfItersPerStart)] for i in range(maxNumOfItersPerStart)]
for i in range(maxNumOfItersPerStart): for i in range(maxNumOfItersPerStart):
summarySources[cat]['inds'][conf][funcLabel]['avgProgramStart']\ getObjFromPath(path, summarySources[cat]['inds'][conf])[funcLabel]['avgProgramStart']\
.append(slideshowCreator.getIndOfLastDataSource()) .append(slideshowCreator.getIndOfLastDataSource())
slideshowCreator.createAndAddDataSourcesTexCode( slideshowCreator.createAndAddDataSourcesTexCode(
[sorted(plotDataTmp[i])], [sorted(plotDataTmp[i])],
0, False, 0, 1) 0, False, 0, 1)
dummy = 2
# @info recursively goes through the dict until it reaches its last dict the results # @info recursively goes through the dict until it reaches its last dict the results
# @param nested (dict) dictionary with another key or results # @param nested (dict) dictionary with another key or results
# @param path (list) path of previous keys # @param path (list) path of previous keys
# @return (void) # @return (void)
def a(nested,path): def processKeys(nested, path, slideshowCreator, summarySources, conf):
for item in nested: for ind, item in enumerate(nested):
if type(nested[item]) is dict: # if type(nested[item]) is dict:
a(nested[item], path.append(item)) path.append(item)
processKeys(nested[item], path, slideshowCreator, summarySources, conf)
else: else:
func(sorted(nested.items()), path) #sorted(vals.items()) constructSummarySources(sorted(nested.items()), path, slideshowCreator, summarySources, conf)
if path and ind == len(nested)-1:
path.pop(0)
def getAllDataClassifiedFromFolder(measuredFuncFolderArg, def getAllDataClassifiedFromFolder(measuredFuncFolderArg,
yLabelCategory, yLabelCategory,
...@@ -1443,13 +1478,15 @@ def getAllDataClassifiedFromFolder(measuredFuncFolderArg, ...@@ -1443,13 +1478,15 @@ def getAllDataClassifiedFromFolder(measuredFuncFolderArg,
for conf, vals in sorted(folderDataGroups.items()): for conf, vals in sorted(folderDataGroups.items()):
# Pridam do summarySources list na konkretni konfiguraci. # Pridam do summarySources list na konkretni konfiguraci.
# V listu budou vysledky za jednotliva spusteni programu. # V listu budou vysledky za jednotliva spusteni programu.
for cat in ('vals', 'inds'):
for dic in summarySources.values(): #for cat in ('vals', 'inds'):
dic[cat][conf] = dict() # for dic in summarySources.values():
# dic[cat][conf] = dict()
# TODO OV # TODO OV
func(sorted(vals.items())) #func(sorted(vals.items()))
#a(vals, []) #? print(conf)
processKeys(vals, [], slideshowCreator, summarySources, conf)
# Kontrola, jestli se nacetla nejaka data # Kontrola, jestli se nacetla nejaka data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment