def build(self, losses_by_event, stats=()):
        """
        :param losses_by_event:
            the aggregate loss table with shape R -> (E, L)
        :param stats:
            list of pairs [(statname, statfunc), ...]
        :returns:
            two arrays with shape (P, R, L) and (P, S, L)
        """
        P, R = len(self.return_periods), len(self.weights)
        L = len(self.loss_dt.names)
        array = numpy.zeros((P, R, L), F32)
        for r in losses_by_event:
            num_events = self.num_events[r]
            losses = losses_by_event[r]
            for l, lt in enumerate(self.loss_dt.names):
                ls = losses[:, l].flatten()  # flatten only in ucerf
                # NB: do not use squeeze or the gmf_ebrisk tests will break
                lbp = losses_by_period(
                    ls, self.return_periods, num_events, self.eff_time)
                array[:, r, l] = lbp
        return self.pair(array, stats)
:param losses_by_event:
            the aggregate loss table with shape R -> (E, L)
        :param stats:
            list of pairs [(statname, statfunc), ...]
        :returns:
            two arrays with shape (P, R, L) and (P, S, L)