Mercurial Hosting > traffic-intelligence
diff python/storage.py @ 585:aab2242ea88c
minor modification of objectNumbers to None
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 04 Dec 2014 17:04:56 -0500 |
parents | 5bda87ac0a69 |
children | ff4f0ce46ca6 |
line wrap: on
line diff
--- a/python/storage.py Thu Dec 04 16:57:29 2014 -0500 +++ b/python/storage.py Thu Dec 04 17:04:56 2014 -0500 @@ -253,16 +253,15 @@ else: print('no trajectory type was chosen') - if type(objectNumbers) == int: - if objectNumbers == -1: - query = '' - else: - query = statementBeginning+'between 0 and {0} '.format(objectNumbers) + if objectNumbers is None: + query = '' + elif type(objectNumbers) == int: + query = statementBeginning+'between 0 and {0} '.format(objectNumbers) elif type(objectNumbers) == list: query = statementBeginning+'in ('+', '.join([str(n) for n in objectNumbers])+') ' return query -def loadTrajectoriesFromTable(connection, tableName, trajectoryType, objectNumbers = -1): +def loadTrajectoriesFromTable(connection, tableName, trajectoryType, objectNumbers = None): '''Loads trajectories (in the general sense) from the given table can be positions or velocities @@ -304,8 +303,8 @@ return objects -def loadTrajectoriesFromSqlite(filename, trajectoryType, objectNumbers = -1): - '''Loads nObjects or the indices in objectNumbers from the database''' +def loadTrajectoriesFromSqlite(filename, trajectoryType, objectNumbers = None): + '''Loads the first objectNumbers objects or the indices in objectNumbers from the database''' connection = sqlite3.connect(filename) # add test if it open objects = loadTrajectoriesFromTable(connection, 'positions', trajectoryType, objectNumbers)