Exemplo n.º 1
0
def test_AnalysisFromFunction(scheduler, universe, custom_function, step):
    ana1 = custom.AnalysisFromFunction(custom_function, universe,
                                       universe.atoms).run(step=step)
    ana2 = custom.AnalysisFromFunction(custom_function, universe,
                                       universe.atoms).run(step=step)
    ana3 = custom.AnalysisFromFunction(custom_function, universe,
                                       universe.atoms).run(step=step)

    results = []
    for ts in universe.trajectory[::step]:
        results.append(custom_function(universe.atoms))
    results = np.asarray(results)

    for ana in (ana1, ana2, ana3):
        assert_equal(results, ana.results)
Exemplo n.º 2
0
def test_different_blocks(scheduler, universe, n_blocks):
    #  This test will fail with np.hstack() #PR 88
    ana1 = custom.AnalysisFromFunction(custom_function_tensor, universe,
                                       universe.atoms).run(n_blocks=n_blocks)
    ana2 = custom.AnalysisFromFunction(custom_function_tensor, universe,
                                       universe.atoms).run(n_blocks=n_blocks)
    ana3 = custom.AnalysisFromFunction(custom_function_tensor, universe,
                                       universe.atoms).run(n_blocks=n_blocks)

    results = []
    for ts in universe.trajectory:
        results.append(custom_function_tensor(universe.atoms))
    results = np.asarray(results)

    for ana in (ana1, ana2, ana3):
        assert_equal(results, ana.results)
Exemplo n.º 3
0
def test_AnalysisFromFunction():
    u = mda.Universe(PSF, DCD)
    step = 2
    ana1 = custom.AnalysisFromFunction(custom_function, u,
                                       u.atoms).run(step=step)
    ana2 = custom.AnalysisFromFunction(custom_function, u,
                                       u.atoms).run(step=step)
    ana3 = custom.AnalysisFromFunction(custom_function, u,
                                       u.atoms).run(step=step)

    results = []
    for ts in u.trajectory[::step]:
        results.append(custom_function(u.atoms))
    results = np.asarray(results)

    for ana in (ana1, ana2, ana3):
        assert_equal(results, ana.results)
Exemplo n.º 4
0
def test_AnalysisFromFunction_otherAgs(universe, step=2):
    u1 = universe
    u2 = universe.copy()
    u3 = universe.copy()
    ana = custom.AnalysisFromFunction(custom_function_2, u1, u1.atoms,
                                      u2.atoms, u3.atoms).run(step=step)

    results = []
    for ts in u1.trajectory[::step]:
        results.append(custom_function_2(u1.atoms, u2.atoms, u3.atoms))
    results = np.asarray(results)
    assert_equal(results, ana.results)
Exemplo n.º 5
0
def test_AnalysisFromFunction_otherAgs():
    u = mda.Universe(PSF, DCD)
    u2 = mda.Universe(PSF, DCD)
    u3 = mda.Universe(PSF, DCD)
    step = 2
    ana = custom.AnalysisFromFunction(custom_function_2, u, u.atoms, u2.atoms,
                                      u3.atoms).run(step=step)

    results = []
    for ts in u.trajectory[::step]:
        results.append(custom_function_2(u.atoms, u2.atoms, u3.atoms))
    results = np.asarray(results)
    assert_equal(results, ana.results)