def idx_to_infos(self, idxs): """Return info about object with index in `idxs`.""" neighbors_ids = [self.index_to_id(idx) for idx in idxs] neighbors_locs = [self.loc[idx] for idx in idxs] extra = [] if self.fields: extra = u.xzip([self.info[id_] for id_ in neighbors_ids], self.fields) return neighbors_ids, extra, neighbors_locs
# and almost same venue id (except those at the border) if not vids == avids: print(len(vids), len(vids.difference(avids)), len(avids.difference(vids))) for missing in vids.difference(avids): print(np.linalg.norm(lvenues[missing] - lvenues[vid])) print((clock() - start) / len(test_ids)) lphotos = p.load_var(city + '_lphotos.my') photos = CLIENT.world.photos.find({ 'hint': city, 'loc': { '$near': ball } }, { 'venue': 1, 'taken': 1 }) pids, pvenue, ptime = u.xzip(photos, ['_id', 'venue', 'taken']) start = clock() sphotos = Surrounding(CLIENT.world.photos, {'hint': city}, 'venue taken'.split(), lphotos) print((clock() - start)) apids, ainfo = sphotos.around(lvenues[test_ids[0]], radius) # lcheckins = p.load_var(city+'_lcheckins.my') # scheckins = Surrounding(DB.checkin, {'city': city}, ['time'], lcheckins) # checkins = DB.checkin.find({'city': city, 'loc': {'$near': ball}}, # {'time': 1, 'loc': 1}) # cids, ctime = u.xzip(checkins, ['_id', 'time'])
# start = clock() # for vid in test_ids: avids, acats = svenues.around(lvenues[vid], radius) # Check that we get same cats print(all([set(vcats[i]) == set(acats[0][avids.index(id_)]) for i, id_ in enumerate(vids) if id_ in avids])) vids, avids = set(vids), set(avids) # and almost same venue id (except those at the border) if not vids == avids: print(len(vids), len(vids.difference(avids)), len(avids.difference(vids))) for missing in vids.difference(avids): print(np.linalg.norm(lvenues[missing] - lvenues[vid])) print((clock() - start)/len(test_ids)) lphotos = p.load_var(city+'_lphotos.my') photos = CLIENT.world.photos.find({'hint': city, 'loc': {'$near': ball}}, {'venue': 1, 'taken': 1}) pids, pvenue, ptime = u.xzip(photos, ['_id', 'venue', 'taken']) start = clock() sphotos = Surrounding(CLIENT.world.photos, {'hint': city}, 'venue taken'.split(), lphotos) print((clock() - start)) apids, ainfo = sphotos.around(lvenues[test_ids[0]], radius) # lcheckins = p.load_var(city+'_lcheckins.my') # scheckins = Surrounding(DB.checkin, {'city': city}, ['time'], lcheckins) # checkins = DB.checkin.find({'city': city, 'loc': {'$near': ball}}, # {'time': 1, 'loc': 1}) # cids, ctime = u.xzip(checkins, ['_id', 'time'])