summaryrefslogtreecommitdiff
path: root/aerialvision/variableclasses.py
diff options
context:
space:
mode:
Diffstat (limited to 'aerialvision/variableclasses.py')
-rw-r--r--aerialvision/variableclasses.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/aerialvision/variableclasses.py b/aerialvision/variableclasses.py
index cf24c29..18850a1 100644
--- a/aerialvision/variableclasses.py
+++ b/aerialvision/variableclasses.py
@@ -71,12 +71,14 @@ class variable:
self.bool = bool # wheither to expect reset at the end of a kernel
self.organize = organize # how is the data organize in the log, see organizedata.py for options
self.datatype = datatype # int or float or other custom type?
+ self.initialized = 0
+ self.sampleNum = 0
# import the stat variable setting from a string in variables.txt or a custom header
def importFromString(self, string_spec):
data_type_str = {'int':int, 'float':float}
- plot_type_str = {'scalar': 1, 'vector': 2, 'stackedbar': 3, 'vector2d': 4}
- organize_str = {'scalar': 'scalar', 'implicit': 'impVec', 'index': 'idxVec', 'index2d': 'idx2DVec'} #skip custom
+ plot_type_str = {'scalar': 1, 'vector': 2, 'stackedbar': 3, 'vector2d': 4, 'sparse': 5}
+ organize_str = {'scalar': 'scalar', 'implicit': 'impVec', 'index': 'idxVec', 'index2d': 'idx2DVec', 'sparse': 'sparse'} #skip custom
try:
# initialize new stat variable with info from input string
@@ -95,13 +97,21 @@ class variable:
elif (self.type == 2):
assert(self.organize in ['impVec', 'idxVec'])
elif (self.type == 3):
- assert(self.organize in ['impVec', 'idxVec'])
+ assert(self.organize == 'stackbar')
elif (self.type == 4):
assert(self.organize == 'idx2DVec')
+ elif (self.type == 5):
+ assert(self.organize == 'sparse')
except Exception, (e):
print "Error in creating new stat variable from string: %s" % string_spec
raise e
-
+
+ def initSparseMatrix(self):
+ if (self.initialized == 0):
+ if (self.type != 5): raise Exception("initSparseMatrix called from wrong variable type")
+ self.data = [[], [], []]
+ self.initialized = 1
+ self.sampleNum = 1
class bookmark: