comparison bindings/python/pyadb.py @ 721:70542745f473

db creation can now use non-default values for datasize, ntracks and datadim
author map01bf
date Fri, 02 Jul 2010 11:23:26 +0000
parents 2fad8cfdb2d8
children 63a75a2b5fa6
comparison
equal deleted inserted replaced
720:2fad8cfdb2d8 721:70542745f473
30 """Pyadb class. Allows for creation, access, insertion and query of an audioDB vector matching database.""" 30 """Pyadb class. Allows for creation, access, insertion and query of an audioDB vector matching database."""
31 validConfigTerms = {"seqLength":int, "seqStart":int, "exhaustive":bool, 31 validConfigTerms = {"seqLength":int, "seqStart":int, "exhaustive":bool,
32 "falsePositives":bool, "accumulation":str, "distance":str, "npoints":int, 32 "falsePositives":bool, "accumulation":str, "distance":str, "npoints":int,
33 "ntracks":int, "includeKeys":list, "excludeKeys":list, "radius":float, "absThres":float, 33 "ntracks":int, "includeKeys":list, "excludeKeys":list, "radius":float, "absThres":float,
34 "relThres":float, "durRatio":float, "hopSize":int, "resFmt":str} 34 "relThres":float, "durRatio":float, "hopSize":int, "resFmt":str}
35 def __init__(self, path, mode='w'): 35 def __init__(self, path, mode='w', datasize=0, ntracks=0, datadim=0):
36 """
37 initialize the database. By default db will hold 20000 tracks, be 2GB in size and determine datadim from the first inserted feature
38 """
36 self.path = path 39 self.path = path
37 self.configQuery = {} 40 self.configQuery = {}
38 if not (mode=='w' or mode =='r'): 41 if not (mode=='w' or mode =='r'):
39 raise(ValueError, "if specified, mode must be either\'r\' or \'w\'.") 42 raise(ValueError, "if specified, mode must be either\'r\' or \'w\'.")
40 if os.path.exists(path): 43 if os.path.exists(path):
41 self._db = _pyadb._pyadb_open(path, mode) 44 self._db = _pyadb._pyadb_open(path, mode)
42 else: 45 else:
43 self._db = _pyadb._pyadb_create(path,0,0,0) 46 self._db = _pyadb._pyadb_create(path,datasize,ntracks,datadim)
44 self._updateDBAttributes() 47 self._updateDBAttributes()
45 return 48 return
46 49
47 def insert(self, featFile=None, powerFile=None, timesFile=None, featData=None, powerData=None, timesData=None, key=None): 50 def insert(self, featFile=None, powerFile=None, timesFile=None, featData=None, powerData=None, timesData=None, key=None):
48 """ 51 """