# HG changeset patch # User Nicolas Saunier # Date 1530907125 14400 # Node ID c9c03c97ed9f51f036e047ab09418422ed41a40c # Parent 27a822922cb0b98ff939722b2ac6d4fc6d87ccab bug fix to store numpy integers in SQLite diff -r 27a822922cb0 -r c9c03c97ed9f scripts/process.py --- a/scripts/process.py Fri Jul 06 11:13:10 2018 -0400 +++ b/scripts/process.py Fri Jul 06 15:58:45 2018 -0400 @@ -168,7 +168,7 @@ lcss = utils.LCSS(metric = args.metric, epsilon = args.epsilon) similarityFunc = lambda x,y : lcss.computeNormalized(x, y) trainingObjects = [o for tmpobjects in objects.values() for o in tmpobjects] - if args.nMPObjects is not None: + if args.nMPObjects is not None and args.nMPObjects < len(trainingObjects): m = int(np.floor(float(len(trainingObjects))/args.nMPObjects)) trainingObjects = trainingObjects[::m] similarities = -np.ones((len(trainingObjects), len(trainingObjects))) @@ -179,7 +179,6 @@ outputPrototypeDatabaseFilename = args.outputPrototypeDatabaseFilename # TODO maintain mapping from object prototype to db filename + compute nmatchings before clusterSizes = ml.computeClusterSizes(labels, prototypeIndices, -1) - #print([clusterSizes[i] for i in prototypeIndices]) storage.savePrototypesToSqlite(str(parentPath/site.getPath()/outputPrototypeDatabaseFilename), [moving.Prototype(object2VideoSequences[trainingObjects[i]].getDatabaseFilename(False), trainingObjects[i].getNum(), prototypeType, clusterSizes[i]) for i in prototypeIndices]) diff -r 27a822922cb0 -r c9c03c97ed9f trafficintelligence/storage.py --- a/trafficintelligence/storage.py Fri Jul 06 11:13:10 2018 -0400 +++ b/trafficintelligence/storage.py Fri Jul 06 15:58:45 2018 -0400 @@ -7,7 +7,7 @@ from copy import copy import sqlite3, logging -from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg +from numpy import log, min as npmin, max as npmax, round as npround, array, sum as npsum, loadtxt, floor as npfloor, ceil as npceil, linalg, int32, int64 from pandas import read_csv, merge from trafficintelligence import utils, moving, events, indicators @@ -22,6 +22,9 @@ 'object': 'objects', 'objectfeatures': 'positions'} +sqlite3.register_adapter(int64, lambda val: int(val)) +sqlite3.register_adapter(int32, lambda val: int(val)) + ######################### # Sqlite #########################