Beispiel #1
0
def with_all_clients(client):
    pre = elfi.get_client()
    elfi.client.set_client(client)

    yield

    elfi.client.set_client(pre)
Beispiel #2
0
def test_batch_index_value(ma2):
    bi = lambda meta: meta['batch_index']

    # Test the correct batch_index value
    m = elfi.ElfiModel()
    op = elfi.Operation(bi, model=m, name='op')
    op['_uses_meta'] = True
    client = elfi.get_client()
    c = elfi.ComputationContext()
    compiled_net = client.compile(m.source_net, m.nodes)
    loaded_net = client.load_data(compiled_net, c, batch_index=3)
    res = client.compute(loaded_net)

    assert res['op'] == 3
Beispiel #3
0
def test_batch_index_value(ma2):
    def bi(meta):
        return meta['batch_index']

    # Test the correct batch_index value
    op = elfi.Operation(bi, model=ma2, name='op')
    op.uses_meta = True
    client = elfi.get_client()
    c = elfi.ComputationContext()
    compiled_net = client.compile(ma2.source_net, ma2.nodes)
    loaded_net = client.load_data(compiled_net, c, batch_index=3)
    res = client.compute(loaded_net)

    assert res['op'] == 3
Beispiel #4
0
def test_multiprocessing_kwargs(simple_model):
    pre = elfi.get_client()

    m = simple_model
    num_proc = 2
    elfi.set_client('multiprocessing', num_processes=num_proc)
    rej = elfi.Rejection(m['k1'])
    assert rej.client.num_cores == num_proc

    elfi.set_client('multiprocessing', processes=num_proc)
    rej = elfi.Rejection(m['k1'])
    assert rej.client.num_cores == num_proc

    elfi.set_client(pre)