def create_items()

in eventdata/parameter_sources/weightedarray.py [0:0]


    def create_items(self, item_list, min_weight=None, max_weight=None):
        choices = []
        weights = []
        low = sys.maxsize

        for w, c in item_list:
            if (min_weight and w > min_weight) or (max_weight and w <= max_weight):
                low = low if low < w else w
                weights.append(w)
                choices.append(c)

        cumdist = list(itertools.accumulate(weights))
        # choose the size of the resulting array so that the item with the lowest frequency still has a chance to appear (once).
        total = cumdist[-1]
        size = total // low
        # pre-generate the randomly distributed weighted choices as we want to avoid any expensive operations
        # on the fast-path (i.e. in #get_random()).
        #
        return [choices[bisect.bisect(cumdist, random.random() * total)] for _ in range(size)]