Пример #1
0
def multiprocess(processes, samples, x, widths):
    pool = Pool(processes=processes)
    results = [
        pool.apply_async(parzen_estimation, args=(samples, x, w))
        for w in widths
    ]
    results = [p.get() for p in results]
    results.sort()  # to sort the results by input window width
    return results
Пример #2
0
    def test_pool_apply(self):
        pool = Pool(4)
        res_async = pool.apply_async(f, (42,))
        r = res_async.get()
        assert r == (42 * 42)

        res = pool.apply(f, (36,))
        assert res == (36 * 36)

        res = pool.apply(fy, (36,), {"y": 2})
        assert res == (36 * 36 * 2)

        pool.terminate()
        pool.join()