Example #1
0
def test_invoke_matrix(n_jobs):
    matrix = np.random.randn(100, 100)
    vectors = [np.random.randn(100) for i in range(100)]
    with invoker(matrix, _mul_op, n_jobs) as inv:
        mults = inv.map(vectors)
        for rv, v in zip(mults, vectors):
            act_rv = matrix @ v
            assert act_rv == approx(rv, abs=1.0e-6)
Example #2
0
def test_ii_parallel_multi_build():
    "Build multiple item-item models in parallel"
    ratings = lktu.ml_test.ratings
    ratings['partition'] = np.random.choice(4, len(ratings), replace=True)

    with invoker(ratings, _build_predict, 2) as inv:
        preds = inv.map(range(4))
        preds = pd.concat(preds, ignore_index=True)

    assert len(preds) == len(ratings)
Example #3
0
def test_mp_is_worker():
    with invoker('foo', _worker_status, 2) as loop:
        res = list(loop.map(range(10)))
        assert all([w for (pid, w, mpw) in res])
        assert all([mpw for (pid, w, mpw) in res])