本文整理匯總了Python中mcni.pyre_support.Instrument.Instrument.main方法的典型用法代碼示例。如果您正苦於以下問題:Python Instrument.main方法的具體用法?Python Instrument.main怎麽用?Python Instrument.main使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mcni.pyre_support.Instrument.Instrument
的用法示例。
在下文中一共展示了Instrument.main方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from mcni.pyre_support.Instrument import Instrument [as 別名]
# 或者: from mcni.pyre_support.Instrument.Instrument import main [as 別名]
def main(self):
base.main(self)
neutrons = {}
#get neutrons from other nodes
from mcni.neutron_storage import neutrons_from_npyarr as a2n, neutrons_as_npyarr as n2a, ndblsperneutron
from mcni.utils.mpi import rank as mpirank, send, receive, world
tag = 999
if mpirank != 0:
arr = n2a( self.inventory.recorder.neutrons )
print "Node %s: sending array of shape %s" % (mpirank, arr.shape,)
send(arr , 0, tag )
else:
for peer in range(1, world.size):
arr = receive( peer, tag )
arr.shape = -1, ndblsperneutron
neutrons[ peer ] = a2n( arr )
print "Node %s: received array of shape %s" % (mpirank, arr.shape)
continue
neutrons[ 0] = self.inventory.recorder.neutrons
#compare
if mpirank == 0:
for peer in range(1, world.size):
assert neutrons[0][0].state.velocity[2] != neutrons[peer][0].state.velocity[2]
continue
return