def _queryToArray(self, q): recs = self._queryToDict(q) if len(recs) < 1: #return np.array([]) ## need to return empty array *with correct fields*, but this is very difficult, so just return None return None rec1 = recs[0] dtype = functions.suggestRecordDType(rec1) #print rec1, dtype arr = np.empty(len(recs), dtype=dtype) arr[0] = tuple(rec1.values()) for i in xrange(1, len(recs)): arr[i] = tuple(recs[i].values()) return arr
def _queryToArray(self, q): recs = self._queryToDict(q) if len(recs) < 1: #return np.array([]) ## need to return empty array *with correct fields*, but this is very difficult, so just return None return None rec1 = recs[0] dtype = functions.suggestRecordDType(rec1) #print rec1, dtype arr = np.empty(len(recs), dtype=dtype) arr[0] = tuple(rec1.values()) for i in range(1, len(recs)): arr[i] = tuple(recs[i].values()) return arr
def _queryToArray(self, q): prof = debug.Profiler("_queryToArray", disabled=True) recs = self._queryToDict(q) prof.mark("got records") if len(recs) < 1: #return np.array([]) ## need to return empty array *with correct columns*, but this is very difficult, so just return None return None rec1 = recs[0] dtype = functions.suggestRecordDType(rec1, singleRecord=True) #print rec1, dtype arr = np.empty(len(recs), dtype=dtype) arr[0] = tuple(rec1.values()) for i in xrange(1, len(recs)): arr[i] = tuple(recs[i].values()) prof.mark('converted to array') prof.finish() return arr