mirror of
https://github.com/justinccdev/opensimulator-tools.git
synced 2026-08-14 09:12:07 +00:00
Add legend to generated graph with container name (unfortunately this will not always be corrected)
Also order dictionaries
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import collections
|
||||
import fnmatch
|
||||
import pprint
|
||||
import re
|
||||
@@ -45,14 +46,18 @@ class OSimStatsCorpus:
|
||||
else:
|
||||
return None
|
||||
|
||||
"""
|
||||
Returns a dictionary of matching stats where fullName => stat
|
||||
If no match stats are found then an empty dictionary is returned.
|
||||
"""
|
||||
def getStats(self, glob):
|
||||
matchingStats = []
|
||||
matchingStats = collections.OrderedDict()
|
||||
|
||||
for category, containers in self._data.items():
|
||||
for container, stats in containers.items():
|
||||
for statName, stat in stats.items():
|
||||
if fnmatch.fnmatch(stat['fullName'], glob):
|
||||
matchingStats.append(stat)
|
||||
matchingStats[stat['fullName']] = stat
|
||||
|
||||
return matchingStats
|
||||
|
||||
@@ -69,6 +74,10 @@ class OSimStatsCorpus:
|
||||
# stat : {
|
||||
# 'abs' : { 'values' : [], 'units' : "" },
|
||||
# 'delta' : { 'values' : [], 'units' : "" }
|
||||
# 'name' : string
|
||||
# 'fullName' : string
|
||||
# 'category' : string
|
||||
# 'container' : string
|
||||
# }
|
||||
# delta may not be present
|
||||
|
||||
@@ -87,14 +96,16 @@ class OSimStatsCorpus:
|
||||
value = OSimStatsCorpus.parseValue(rawValue, valueRe)
|
||||
|
||||
if not category in self._data:
|
||||
self._data[category] = {}
|
||||
self._data[category] = collections.OrderedDict()
|
||||
|
||||
if not container in self._data[category]:
|
||||
self._data[category][container] = {}
|
||||
self._data[category][container] = collections.OrderedDict()
|
||||
|
||||
if not name in self._data[category][container]:
|
||||
entry = {
|
||||
'abs' : { 'values' : [], 'units' : value[1] },
|
||||
'category' : category,
|
||||
'container' : container,
|
||||
'fullName' : statFullName,
|
||||
'name' : name
|
||||
}
|
||||
|
||||
@@ -40,11 +40,15 @@ if len(stats) <= 0:
|
||||
sys.exit(1)
|
||||
|
||||
plt.title(opts.select)
|
||||
plt.ylabel(stats[0]['name'])
|
||||
|
||||
for stat in stats:
|
||||
plt.plot(stat['abs']['values'])
|
||||
plt.xlabel("samples")
|
||||
# Arbitrarily use the first stat for this
|
||||
plt.ylabel(stats[stats.keys()[0]]['name'])
|
||||
|
||||
for stat in stats.values():
|
||||
plt.plot(stat['abs']['values'], label=stat['container'])
|
||||
plt.xlabel("samples")
|
||||
|
||||
plt.legend()
|
||||
|
||||
if 'out' in opts:
|
||||
savefig(opts.out)
|
||||
|
||||
Reference in New Issue
Block a user