コード例 #1
0
ファイル: test_custom.py プロジェクト: minghao2016/pmda
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)
コード例 #2
0
ファイル: test_custom.py プロジェクト: minghao2016/pmda
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)
コード例 #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)
コード例 #4
0
ファイル: test_custom.py プロジェクト: minghao2016/pmda
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)
コード例 #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)