def histogram(self): """Return a plain histogram by converting all sub-aggregator values into Counts""" out = CentrallyBin([c for c, v in self.bins], self.quantity, Count(), self.nanflow.copy()) out.entries = self.entries for i, v in self.bins: out.bins[i] = Count.ed(v.entries) return out.specialize()
def histogram(self): """Return a plain histogram by converting all sub-aggregator values into Counts""" out = SparselyBin(self.binWidth, self.quantity, Count(), self.nanflow.copy(), self.origin) out.entries = float(self.entries) out.contentType = "Count" for i, v in self.bins.items(): out.bins[i] = Count.ed(v.entries) return out.specialize()
def build(*ys): """Create a Stack out of pre-existing containers, which might have been aggregated on different streams. Parameters: aggregators (list of :doc:`Container <histogrammar.defs.Container>`): this function will attempt to add them, so they must also have the same binning/bounds/etc. """ from functools import reduce if not all(isinstance(y, Container) for y in ys): raise TypeError("ys must all be Containers") entries = sum(y.entries for y in ys) bins = [] for i in xrange(len(ys)): bins.append((float("nan"), reduce(lambda a, b: a + b, ys[i:]))) return Stack.ed(entries, bins, Count.ed(0.0))