Mercurial > hg > audiodb
comparison bindings/python/pyadb.py @ 750:d93292ae7c1b
Fixed accumulation and distance options (strcmp==0) and added times. Added queryFromData
author | mas01mc |
---|---|
date | Wed, 24 Nov 2010 19:29:52 +0000 |
parents | dd4b9fec8d85 |
children | b9dbe4611dde |
comparison
equal
deleted
inserted
replaced
749:dd4b9fec8d85 | 750:d93292ae7c1b |
---|---|
153 raise Usage("query require either key or featData to be defined, you have defined both or neither.") | 153 raise Usage("query require either key or featData to be defined, you have defined both or neither.") |
154 if key: | 154 if key: |
155 result = _pyadb._pyadb_queryFromKey(self._db, key, **self.configQuery) | 155 result = _pyadb._pyadb_queryFromKey(self._db, key, **self.configQuery) |
156 elif featData: | 156 elif featData: |
157 raise NotImplementedError("direct data query not yet implemented. Sorry.") | 157 raise NotImplementedError("direct data query not yet implemented. Sorry.") |
158 return Pyadb.Result(result, self.configQuery) | |
159 | |
160 def query_data(self, featData=None, powerData=None, timesData=None, strictConfig=True): | |
161 """query the database using numpy arrays. required data: featData, optional data: [powerData, timesData]Query parameters as defined in self.configQuery. For details on this consult the doc string in the configCheck method.""" | |
162 if not self.configCheck(): | |
163 if strictConfig: | |
164 raise ValueError("configQuery dict contains unsupported terms and strict configure mode is on.\n\ | |
165 Only keys found in Pyadb.validConfigTerms may be defined") | |
166 else: | |
167 print "configQuery dict contains unsupported terms and strict configure mode is off.\n\ | |
168 Only keys found in Pyadb.validConfigTerms should be defined. Removing invalid terms and proceeding..." | |
169 self.configCheck(scrub=True) | |
170 cq = self.configQuery.copy() | |
171 if (featData==None): | |
172 raise Usage("query requires featData to be defined.") | |
173 if(powerData!=None): | |
174 cq['power']=powerData | |
175 if(timesData!=None): | |
176 cq['times']=timesData | |
177 result = _pyadb._pyadb_queryFromData(self._db, featData, **cq) | |
158 return Pyadb.Result(result, self.configQuery) | 178 return Pyadb.Result(result, self.configQuery) |
159 | 179 |
160 def status(self): | 180 def status(self): |
161 '''update attributes and return them as a dict''' | 181 '''update attributes and return them as a dict''' |
162 self._updateDBAttributes() | 182 self._updateDBAttributes() |