def _sample_reduce(reduce_iter, k, replace):
    '\n    Reduce function used on the sample and choice functions.\n\n    Parameters\n    ----------\n    reduce_iter : iterable\n        Each element is a tuple coming generated by the _sample_map_partitions function.\n\n    Returns a sequence of uniformly distributed samples;\n    '
    ns_ks = []
    s = []
    n = 0
    for i in reduce_iter:
        (s_i, n_i) = i
        s.extend(s_i)
        n += n_i
        k_i = len(s_i)
        ns_ks.append((n_i, k_i))
    if ((k < 0) or ((k > n) and (not replace))):
        raise ValueError('Sample larger than population or is negative')
    p = []
    for (n_i, k_i) in ns_ks:
        if (k_i > 0):
            p_i = (n_i / (k_i * n))
            p += ([p_i] * k_i)
    sample_func = (rnd.choices if replace else _weighted_sampling_without_replacement)
    return sample_func(population=s, weights=p, k=k)
Reduce function used on the sample and choice functions.

Parameters
----------
reduce_iter : iterable
    Each element is a tuple coming generated by the _sample_map_partitions function.

Returns a sequence of uniformly distributed samples;
def _sample_reduce(reduce_iter, k, replace):
    '\n    Reduce function used on the sample and choice functions.\n\n    Parameters\n    ----------\n    reduce_iter : iterable\n        Each element is a tuple coming generated by the _sample_map_partitions function.\n\n    Returns a sequence of uniformly distributed samples;\n    '
    ns_ks = []
    s = []
    n = 0
    for i in reduce_iter:
        (s_i, n_i) = i
        s.extend(s_i)
        n += n_i
        k_i = len(s_i)
        ns_ks.append((n_i, k_i))
    if ((k < 0) or ((k > n) and (not replace))):
        raise ValueError('Sample larger than population or is negative')
    p = []
    for (n_i, k_i) in ns_ks:
        if (k_i > 0):
            p_i = (n_i / (k_i * n))
            p += ([p_i] * k_i)
    sample_func = (rnd.choices if replace else _weighted_sampling_without_replacement)
    return sample_func(population=s, weights=p, k=k)