def calculate_indexes(self,cons,orderbys): self.table.ordered=False if len(orderbys)!=0 and len(self.table.data)!=0: self.table.ordered=True self.table.orderindex=len(self.table.data[0]) for o in reversed(orderbys): self.table.data.sort(key=operator.itemgetter(o[0]),reverse=o[1]) self.table.data=[x+(y,) for x,y in itertools.izip(self.table.data,itertools.count())] idxs=[x[0] for x in cons] self.table.kdindex=kdtree.kdtree(self.table.data, idxs)
def window_index(self, data): data = [x + (y,) for x, y in itertools.izip(data, itertools.count())] return kdtree.kdtree(data)