# HG changeset patch # User Nicolas Saunier # Date 1277995472 14400 # Node ID 1a2ac2d4f53a5e0784d05c3fc8e0b0bc2e951078 # Parent eb78c6edc0c8d57bc373851997401d3851a1a860 added loading of the rest of the data for objects diff -r eb78c6edc0c8 -r 1a2ac2d4f53a python/tests/utils.txt --- a/python/tests/utils.txt Fri May 28 20:25:45 2010 -0400 +++ b/python/tests/utils.txt Thu Jul 01 10:44:32 2010 -0400 @@ -26,3 +26,16 @@ 'test-adfasdf.asdfa' >>> removeExtension('test-adfasdf') 'test-adfasdf' + +>>> values = line2Ints('1 2 3 5 6') +>>> values[0] +1 +>>> values[-1] +6 +>>> values = line2Floats('1.3 2.45 7.158e+01 5 6') +>>> values[0] +1.3 +>>> values[2] #doctest: +ELLIPSIS +71.5... +>>> values[-1] +6.0 diff -r eb78c6edc0c8 -r 1a2ac2d4f53a python/ubc_utils.py --- a/python/ubc_utils.py Fri May 28 20:25:45 2010 -0400 +++ b/python/ubc_utils.py Thu Jul 01 10:44:32 2010 -0400 @@ -26,16 +26,27 @@ objects = [] objNum = 0 + isObjectFile = filename.endswith('objects.txt'); lines = getLines(file) while (lines != []) and ((nObjects<0) or (objNum= 3): + #add = True + if len(lines) >= 3: obj.positions = Trajectory(lines[1], lines[2]) - if (len(lines) >= 5): + if len(lines) >= 5: obj.velocities = Trajectory(lines[3], lines[4]) + if (isObjectFile): + obj.userType = parsedLine[3] + obj.nObjects = float(l[4]) + obj.featureNumbers = [int(n) for n in l[5:]] + + # load contour data if available + if len(lines) >= 6: + obj.contourType = utils.line2Floats(lines[6]) + obj.contourOrigins = Trajectory(lines[7], lines[8]) + obj.contourSizes = Trajectory(lines[9], lines[10]) if len(lines) != 2: objects.append(obj) diff -r eb78c6edc0c8 -r 1a2ac2d4f53a python/utils.py --- a/python/utils.py Fri May 28 20:25:45 2010 -0400 +++ b/python/utils.py Thu Jul 01 10:44:32 2010 -0400 @@ -176,6 +176,13 @@ tmp = array(poly.exterior) plot(tmp[:,0], tmp[:,1], options) +def line2Floats(l, separator=' '): + '''Returns the list of floats corresponding to the string''' + return [float(x) for x in l.split(separator)] + +def line2Ints(l, separator=' '): + '''Returns the list of ints corresponding to the string''' + return [int(x) for x in l.split(separator)] ######################### # running tests