ASyncResult的输出

时间:2019-06-22 11:10:10

标签: python parallel-processing

我发现有关ipyparallel库的一个非常奇怪的问题:使用函数apply我获得了作为输出和名为ASyncResult的对象,其后是一个列表,该列表是我想要的正确输出,我无法访问使用get()输出,因为它说列表不可调用

@tweet.comments.each do |comment|

使用c [0]作为输出:

@like = current_user.likes.new(likable_id: params[:parent_id], likable_type: params[:parent_type])
@like.save

如果仅考虑列表,这是正确的

使用c [0] .get,我获得以下输出

from ipyparallel import Client
import MDAnalysis as mda
import numpy as np

rc = Client(profile="default")

protein = mda.Universe(
    pathtoproteinpdb, pathtoproteinxtc, topology_format="XPDB"
)


def EvaluateDistances(system, df1, df2):
    distances = []
    import MDAnalysis as mda

    core = system.select_atoms("resid 80-196 or resid 333-434")
    gate = system.select_atoms("resid 207-274 or resid 437-503")
    for i in system.trajectory[df1:df2]:
        distances.append(
            np.linalg.norm(
                core.atoms.center_of_mass() - gate.atoms.center_of_mass()
            )
        )
    return distances


dfs = [
    [
        (protein.trajectory.n_frames // 8) * i,
        (protein.trajectory.n_frames // 8) * (1 + i),
    ]
    for i in range(0, 8)
]

for i in range(0, 8):
    c.append(rc[i].apply(EvaluateDistances(protein, dfs[i][0], dfs[i][1])))
rc[:].wait()

并使用c [0] .get() 我收到一个错误:

<AsyncResult: [20.001531553149356, 20.167465117464662, 19.589711947416728, 19.392683041354672, 19.396482975721373, 19.421157652085878, 19.763127849048647, 19.350718797709074, 19.77567590686957, 19.88052552749898, 19.44155212069031, 19.426482956960566, 19.79822743539112, 19.490612408584997, 19.927523036945125, 20.075314247566673, 19.845531002953617, 19.723696756820644, 19.837958825916253, 19.262873269903814, 19.15102523218575, 19.45135041239462, 19.364316494391694, 19.2140975814102, 19.594840738913117, 19.202887337906397, 19.313331598540106, 19.31160870440659, 19.446107609315703, 19.253572442260705, 18.975011258559675, 19.149473801605538, 19.444752712464048, 19.24262143604505, 19.29524612465537, 19.478889572944592, 19.484512416412496, 19.01674312996958, 19.231156289322286, 19.10961748145104, 19.168341410211102, 19.370454824813105, 19.457425809859892, 19.414707191030597, 19.644259709891216, 19.754110846391804, 19.010621091540376, 19.66919577746935, 19.38794596352276, 19.38953100540061, 19.61602656737826, 19.452570611428328, 19.424664717648216, 19.22166518517456, 19.406757198006385, 19.032120995693024, 19.61851806921321, 19.46153107371637, 19.642679924420033, 19.55528661988811, 19.214241670162416, 19.41936899124549, 19.080702574961556, 19.02810763865547, 19.242754821824615, 19.426780557618002, 19.38596638976928, 19.244760400141494, 19.196208993533386, 19.080091555129034, 19.17699080978832]:finished>

我要疯了,因为这没有道理!

0 个答案:

没有答案