def aggregate(self, glyphset, info, screen): # TODO: vectorize pretty much this whole method... (width, height) = screen # co-iterating on number of points in case glyphset.data() is a non-length-carrying placeholder # TODO: Should the default placeholder carry length? infos = [ info(data) for (data, _) in zip(glyphset.data(), range(len(glyphset.points()))) ] aggregates = self.allocate(glyphset, screen) for idx, points in enumerate(glyphset.points()): self.combine(aggregates, points, glyphset.shaper.code, infos[idx]) return aggregates
def aggregate(self, glyphset, info, screen): # TODO: vectorize pretty much this whole method... (width, height) = screen # co-iterating on number of points in case glyphset.data() is a non-length-carrying placeholder # TODO: Should the default placeholder carry length? infos = [info(data) for (data, _) in zip(glyphset.data(), range(len(glyphset.points())))] aggregates = self.allocate(glyphset, screen) for idx, points in enumerate(glyphset.points()): self.combine(aggregates, points, glyphset.shaper.code, infos[idx]) return aggregates
def aggregate(self, glyphset, info, screen): points = glyphset.points() coder = np.vectorize(info) coded = coder(glyphset.data()) coded = np.array(coded) cats = coded.max() (width, height) = screen dims = (height, width, cats+1) # Need cats+1 to do proper categorization... ranges = ((0, screen[1]), (0, screen[0]), (0, cats+1)) data = np.hstack([np.fliplr(points[:, 0:2]), coded[:, np.newaxis]]) dense = np.histogramdd(data, bins=dims, range=ranges) return dense[0]
def aggregate(self, glyphset, info, screen): points = glyphset.points() coder = np.vectorize(info) coded = coder(glyphset.data()) coded = np.array(coded) cats = coded.max() (width, height) = screen dims = (height, width, cats + 1) # Need cats+1 to do proper categorization... ranges = ((0, screen[1]), (0, screen[0]), (0, cats + 1)) data = np.hstack([np.fliplr(points[:, 0:2]), coded[:, np.newaxis]]) dense = np.histogramdd(data, bins=dims, range=ranges) return dense[0]