本文整理汇总了Python中Danu.Output.simulation_count方法的典型用法代码示例。如果您正苦于以下问题:Python Output.simulation_count方法的具体用法?Python Output.simulation_count怎么用?Python Output.simulation_count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Danu.Output
的用法示例。
在下文中一共展示了Output.simulation_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestOutputSimulations
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import simulation_count [as 别名]
class TestOutputSimulations(unittest.TestCase):
def setUp(self):
import random
self.filename = 'test-Output.h5'
self.fh = Output(self.filename,'w')
def tearDown(self):
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_sim_list(self):
import random
list=self.fh.simulation_list()
self.assertEqual(len(list),0)
n=random.randint(10,20)
i=0
save_names=[]
while i < n:
sim_name='Simulation ' + str(i)
save_names.insert(i,sim_name)
self.fh.add_simulation(sim_name)
i=i+1
list=self.fh.simulation_list()
self.assertEqual(len(list),n)
for name in save_names:
if not name in list:
raise RuntimeError, 'Name not found in list'
def test_add_simulation(self):
sim_name='New Simulation'
self.fh.add_simulation(sim_name)
def test_sim_count(self):
import random
sim_count=self.fh.simulation_count()
self.assertEqual(sim_count,0)
n=random.randint(10,20)
i=0
while i < n:
sim_name='Simulation ' + str(i)
self.fh.add_simulation(sim_name)
i=i+1
cnt=self.fh.simulation_count()
self.assertEqual(cnt,n)
def test_sim_exists(self):
sim_name='Sim DNE'
self.assertEqual(self.fh.simulation_exists(sim_name),0)
sim_name='Smin Does Exist'
self.fh.add_simulation(sim_name)
self.assertEqual(self.fh.simulation_exists(sim_name),1)
def test_get_simulation(self):
import Danu
sim_name='Fetchme'
try:
sim=self.get_simulation(sim_name)
except:
print 'Caught get_simulation DNE test'
else:
raise RuntimeError, 'Failed to raise an error'
self.fh.add_simulation(sim_name)
sim=self.fh.get_simulation(sim_name)
if not isinstance(sim,Danu.Simulation):
raise RuntimeError, 'Failed to return simulation object'