本文整理汇总了Python中Danu.Output.add_simulation方法的典型用法代码示例。如果您正苦于以下问题:Python Output.add_simulation方法的具体用法?Python Output.add_simulation怎么用?Python Output.add_simulation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Danu.Output
的用法示例。
在下文中一共展示了Output.add_simulation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestReadDouble3D
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestReadDouble3D(TestCase):
def setUp(self):
import os
from Danu import Output
import random
import numpy
self.filename = 'test-Sequence.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Sequence')
seq=self.sim.get_nextSequence(0,0.0)
n1=random.randint(12,50)
n2=random.randint(10,60)
n3=random.randint(2,40)
self.data=numpy.random.random_sample((n1,n2,n3))
self.data_name='Double Data'
seq.data_write(self.data_name,self.data)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
seq=self.sim.get_sequence('Series 1')
read_data=seq.data_read(self.data_name)
self.assertEqual(read_data.all(), self.data.all())
示例2: TestUtils
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestUtils(TestCase):
def setUp(self):
import os
from Danu import Output
self.filename = 'test-Simulation.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Simulation')
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_data_count(self):
cnt=self.sim.data_count()
self.assertEqual(cnt,0)
def test_data_exists(self):
data_name='Dataset'
self.assertEqual(self.sim.data_exists(data_name),0)
def test_data_list(self):
list=self.sim.data_list()
self.assertEqual(len(list),0)
示例3: TestCreate
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestCreate(TestCase):
def setUp(self):
import os
from Danu import Output
self.filename = 'test-Probe.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Probe')
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_create_int(self):
import numpy
import random
len=random.randint(1,7)
num=random.randint(128,512)
idata=numpy.zeros((num,len))
i=0
while i < num:
l=0
while l < len:
idata[i][l]=random.randint(0,100000)
l=l+1
i=i+1
probe=Probe(self.sim,'Int Data',idata)
def test_create_float(self):
import numpy
import random
len=random.randint(1,7)
num=random.randint(128,512)
data=numpy.float32(numpy.random.random_sample((num,len)))
probe=Probe(self.sim,'Float data',data)
def test_create_double(self):
import numpy
import random
len=random.randint(1,7)
num=random.randint(128,512)
data=numpy.random.random_sample((num,len))
probe=Probe(self.sim,'Double data',data)
示例4: TestAttributes
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestAttributes(TestCase):
def setUp(self):
import os
from Danu import Output
import random
import numpy
self.filename = 'test-Probe.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Probe')
self.probe_name='Dummy Probe'
data=numpy.ones((3,10))
Probe(self.sim,self.probe_name,data)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
import random
probe=self.sim.probe_open(self.probe_name)
# integers
int_name='Integer Attribute'
try:
probe.get_attribute(int_name)
except:
print 'Caught DNE attribute'
else:
raise RuntimeError, 'Failed to catch DNE error'
int_attr=random.randint(1,102400)
probe.set_attribute(int_name,int_attr)
read_attr=probe.get_attribute(int_name)
self.assertEqual(int_attr,read_attr)
# double
dbl_name='Double Attribute'
dbl_attr=random.random()
probe.set_attribute(dbl_name,dbl_attr)
read_dbl=probe.get_attribute(dbl_name)
self.assertEqual(read_dbl,dbl_attr)
# string
str_name='Chacracter Name Attribute'
str_attr='ajksdweiouamnv 9iajemn oiwiwe'
probe.set_attribute(str_name,str_attr)
string=probe.get_attribute(str_name)
self.assertEqual(string,str_attr)
示例5: TestBasic
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestBasic(TestCase):
def setUp(self):
import os
from Danu import Output
self.filename = 'test-Probe.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Probe')
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
import random
import numpy
print 'Begin basic test'
try:
probe=Probe()
except:
print 'Caught invalid number of arguments'
try:
probe=Probe(self.sim)
except:
print 'Caught invalid number of arguments'
try:
probe=Probe(self.sim,'Dummy Probe')
except:
print 'Caught invalid number of arguments'
try:
data=numpy.ones((10))
probe=Probe(self.sim,'Dummy Probe',data)
except:
print 'Caught incorrect argument type'
# Simple constructor and delete
len=2
num=20
data=numpy.ones((num,len))
probe= Probe(self.sim,'Dummy Probe',data)
del probe
probe=self.sim.probe_open('Dummy Probe')
self.assertEqual(probe.length(),len)
self.assertEqual(probe.number(),num)
示例6: TestAttributes
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestAttributes(TestCase):
def setUp(self):
import os
from Danu import Output
import random
import numpy
self.filename = 'test-Sequence.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Sequence')
self.seq=self.sim.get_nextSequence(0,0.0)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
import random
seq=self.seq
# integers
int_name='Integer Attribute'
try:
seq.get_attribute(int_name)
except:
print 'Caught DNE attribute'
else:
raise RuntimeError, 'Failed to catch DNE error'
int_attr=random.randint(1,102400)
seq.set_attribute(int_name,int_attr)
read_attr=seq.get_attribute(int_name)
self.assertEqual(int_attr,read_attr)
# double
dbl_name='Double Attribute'
dbl_attr=random.random()
seq.set_attribute(dbl_name,dbl_attr)
read_dbl=seq.get_attribute(dbl_name)
self.assertEqual(read_dbl,dbl_attr)
# string
str_name='Chacracter Name Attribute'
str_attr='ajksdweiouamnv 9iajemn oiwiwe'
seq.set_attribute(str_name,str_attr)
string=seq.get_attribute(str_name)
self.assertEqual(string,str_attr)
示例7: TestBasic
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestBasic(TestCase):
def setUp(self):
import os
from Danu import Output
self.filename = 'test-Sequence.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Sequence')
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
import random
import numpy
print 'Begin basic test'
try:
seq=Sequence()
except:
print 'Caught invalid number of arguments'
try:
seq=Sequence(self.sim)
except:
print 'Caught invalid name or id'
try:
seq=Sequence(self.sim,'Series DNE')
except:
print 'Caught id group that does not exist'
try:
seq=Sequence(self.sim,seriesname='Series 10')
except:
print 'Caught group name that does not exist'
cycle=random.randint(0,10)
time=numpy.float64(random.randint(0,1000))
seq=self.sim.get_nextSequence(cycle,time)
id=seq.id
del seq
seq_name=self.sim.get_sequence_name(id)
new_seq=Sequence(self.sim,seq_name)
del new_seq
示例8: TestDataReadDouble
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestDataReadDouble(TestCase):
def setUp(self):
import os
import numpy
import random
from Danu import Output
self.filename = 'test-Simulation.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Simulation')
self.data_name_1d='Double Data 1D'
self.n=random.randint(1000,10000)
self.data_1d=numpy.random.random_sample((self.n))
self.sim.data_write(self.data_name_1d,self.data_1d)
self.data_name_2d='Double Data 2D'
self.n1=random.randint(100,1000)
self.n2=random.randint(100,1000)
self.data_2d=numpy.random.random_sample((self.n1,self.n2))
self.sim.data_write(self.data_name_2d,self.data_2d)
self.data_name_3d='Double Data 3D'
self.n1=random.randint(10,100)
self.n2=random.randint(10,100)
self.n3=random.randint(10,100)
self.data_3d=numpy.random.random_sample((self.n1,self.n2,self.n3))
self.sim.data_write(self.data_name_3d,self.data_3d)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
def runTest(self):
data1=self.sim.data_read(self.data_name_1d)
self.assertEqual(data1.all(),self.data_1d.all())
data2=self.sim.data_read(self.data_name_2d)
self.assertEqual(data2.all(),self.data_2d.all())
data3=self.sim.data_read(self.data_name_3d)
self.assertEqual(data3.all(),self.data_3d.all())
示例9: TestReadInteger3D
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestReadInteger3D(TestCase):
def setUp(self):
import os
from Danu import Output
import random
import numpy
self.filename = 'test-Sequence.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Sequence')
seq=self.sim.get_nextSequence(0,0.0)
n1=random.randint(10,20)
n2=random.randint(10,20)
n3=random.randint(10,20)
self.data=numpy.zeros((n1,n2,n3))
i=0
while i < n1:
j=0
while j < n2:
k=0
while k < n3:
self.data[i][j]=random.randint(0,10000)
k=k+1
j=j+1
i=i+1
self.data_name='Integer Data'
seq.data_write(self.data_name,self.data)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
seq=self.sim.get_sequence('Series 1')
read_data=seq.data_read(self.data_name)
self.assertEqual(read_data.all(), self.data.all())
示例10: TestReadInteger1D
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestReadInteger1D(TestCase):
def setUp(self):
import os
from Danu import Output
import random
import numpy
self.filename = 'test-Sequence.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Sequence')
seq=self.sim.get_nextSequence(0,0.0)
n=random.randint(128,512)
self.data=numpy.zeros((n))
i=0
while i < n:
self.data[i]=random.randint(0,10000)
i=i+1
self.data_name='Integer Data'
seq.data_write(self.data_name,self.data)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
seq=self.sim.get_sequence('Series 1')
try:
read_data=seq.data_read('Data DNE')
except:
print 'Caught Data set that did not exist'
read_data=seq.data_read(self.data_name)
self.assertEqual(read_data.all(), self.data.all())
示例11: TestReadData
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestReadData(TestCase):
def setUp(self):
import os
from Danu import Output
import random
import numpy
self.filename='test-Probe.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Probe')
# Int data
self.idata_name='Int data'
len=random.randint(1,7)
num=random.randint(128,512)
self.idata=numpy.zeros((num,len))
i=0
while i < num:
l=0
while l < len:
self.idata[i][l]=random.randint(0,100000)
l=l+1
i=i+1
probe=Probe(self.sim,self.idata_name,self.idata)
# Float data
self.fdata_name='Float data'
len=random.randint(1,7)
num=random.randint(128,512)
self.fdata=numpy.float32(numpy.random.random_sample((num,len)))
probe=Probe(self.sim,self.fdata_name,self.fdata)
# Double data
self.rdata_name='Double data'
len=random.randint(1,7)
num=random.randint(128,512)
self.rdata=numpy.random.random_sample((num,len))
probe=Probe(self.sim,self.rdata_name,self.rdata)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_read_int(self):
probe=self.sim.probe_open(self.idata_name)
read_data=probe.read()
self.assertEqual(read_data.all(), self.idata.all())
def test_read_float(self):
probe=self.sim.probe_open(self.fdata_name)
read_data=probe.read()
self.assertEqual(read_data.all(), self.fdata.all())
def test_read_double(self):
probe=self.sim.probe_open(self.rdata_name)
read_data=probe.read()
self.assertEqual(read_data.all(), self.rdata.all())
示例12: TestWrite
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestWrite(TestCase):
def setUp(self):
import os
import random
import numpy
from Danu import Output
self.filename = 'test-Probe.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Probe')
# Int data
self.idata_name='Int data'
len=random.randint(1,7)
num=random.randint(128,512)
self.idata=numpy.zeros((num,len))
self.idata_len=len
i=0
while i < num:
l=0
while l < len:
self.idata[i][l]=random.randint(0,100000)
l=l+1
i=i+1
probe=Probe(self.sim,self.idata_name,self.idata)
# Float data
self.fdata_name='Float data'
len=random.randint(1,7)
num=random.randint(128,512)
self.fdata=numpy.float32(numpy.random.random_sample((num,len)))
self.fdata_len=len
probe=Probe(self.sim,self.fdata_name,self.fdata)
# Double data
self.rdata_name='Double data'
len=random.randint(1,7)
num=random.randint(128,512)
self.rdata=numpy.random.random_sample((num,len))
self.rdata_len=len
probe=Probe(self.sim,self.rdata_name,self.rdata)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_write_int(self):
import numpy
import random
len=self.idata_len + 1
num=random.randint(128,512)
idata=numpy.zeros((num,len))
probe=self.sim.probe_open(self.idata_name)
try:
probe.write(idata)
except:
print 'Caught error when trying to write mis-sized data'
idata=numpy.zeros((num,self.idata_len))
probe.write(idata)
def test_write_float(self):
import numpy
import random
len=self.fdata_len+1
num=random.randint(128,512)
data=numpy.float32(numpy.random.random_sample((num,len)))
probe=self.sim.probe_open(self.fdata_name)
try:
probe.write(data)
except:
print 'Caught error when trying to write mis-sized data'
data=numpy.float32(numpy.random.random_sample((num,self.fdata_len)))
probe.write(data)
def test_write_double(self):
import numpy
import random
len=self.rdata_len+1
num=random.randint(128,512)
data=numpy.random.random_sample((num,len))
probe=self.sim.probe_open(self.rdata_name)
try:
probe.write(data)
except:
#.........这里部分代码省略.........
示例13: TestWriteData
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestWriteData(TestCase):
def setUp(self):
import os
from Danu import Output
self.filename = 'test-Sequence.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Sequence')
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_write_1D(self):
import numpy
import random
seq=self.sim.get_nextSequence(0,0.0)
size=random.randint(128,512)
idata=numpy.zeros((size))
i=0
while i < size:
idata[i]=random.randint(0,100000)
i=i+1
seq.data_write('Integer Data',idata)
size=random.randint(128,512)
data=numpy.float32(numpy.random.random_sample((size)))
seq.data_write('Float Data',data)
size=random.randint(128,512)
data=numpy.random.random_sample((size))
seq.data_write('Double Data',data)
def test_write_2D(self):
import numpy
import random
seq=self.sim.get_nextSequence(0,0.0)
n1=random.randint(10,128)
n2=random.randint(10,128)
idata=numpy.zeros((n1,n2))
i=0
while i < n1:
j=0
while j < n2:
idata[i][j]=random.randint(1,1000)
j=j+1
i=i+1
seq.data_write('Integer Data',idata)
data=numpy.float32(numpy.random.random_sample((n1,n2)))
seq.data_write('Float Data',data)
data=numpy.random.random_sample((n1,n2))
seq.data_write('Double Data',data)
def test_write_3D(self):
import numpy
import random
seq=self.sim.get_nextSequence(0,0.0)
n1=random.randint(1,20)
n2=random.randint(1,20)
n3=random.randint(1,20)
idata=numpy.zeros((n1,n2,n3))
i=0
while i < n1:
j=0
while j < n2:
k=0
while k < n3:
idata[i][j][k]=random.randint(1,1000)
k=k+1
j=j+1
i=i+1
seq.data_write('Integer Data',idata)
data=numpy.float32(numpy.random.random_sample((n1,n2,n3)))
seq.data_write('Float Data',data)
data=numpy.random.random_sample((n1,n2,n3))
seq.data_write('Double Data',data)
示例14: TestSequence
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestSequence(TestCase):
def setUp(self):
import os
import numpy
import random
from Danu import Output
self.filename = 'test-Simulation.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Simulation')
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
def test_basic(self):
from Danu import Sequence
import numpy
import random
cycle=random.randint(10,100)
time=numpy.random.random_sample((1))[0]
seq=self.sim.get_nextSequence(cycle,time);
print seq.id
print seq.time
print seq.cycle
def test_sequence_count(self):
import random
import numpy
cnt=self.sim.sequence_count()
self.assertEqual(cnt,0,'Failed to return zero count')
gen_cnt=random.randint(1,100)
cycle=1
i=1
time=numpy.random.random_sample((1))[0]
while i <= gen_cnt:
time=time+numpy.random.random_sample((1))[0]
seq=self.sim.get_nextSequence(cycle,time)
del seq
i=i+1
cnt=self.sim.sequence_count()
self.assertEqual(cnt,gen_cnt)
def test_sequence_exists(self):
import random
import numpy
cycle=1
time=numpy.random.random_sample((1))[0]
flag=self.sim.sequence_exists('Series DNE')
self.assertEqual(flag,0,'Failed to return false status')
seq=self.sim.get_nextSequence(cycle,time)
id=seq.id
del seq
seq_name=self.sim.get_sequence_name(id)
flag=self.sim.sequence_exists(seq_name)
self.assertEqual(flag,1,'Failed to return true status')
def test_sequence_list(self):
import random
import numpy
list=self.sim.sequence_list()
self.assertEqual(len(list),0,'Failed to return empty list')
gen_cnt=random.randint(1,100)
cycle=1
i=1
time=numpy.random.random_sample((1))[0]
names=[]
while i <= gen_cnt:
time=time+numpy.random.random_sample((1))[0]
seq=self.sim.get_nextSequence(cycle,time)
seq_name=self.sim.get_sequence_name(seq.id)
names.append(seq_name)
del seq
i=i+1
list=self.sim.sequence_list()
self.assertEqual(len(list),gen_cnt,'Failed to return correct list size')
for name in names:
self.assertTrue(name in list)
示例15: TestDataReadInteger
# 需要导入模块: from Danu import Output [as 别名]
# 或者: from Danu.Output import add_simulation [as 别名]
class TestDataReadInteger(TestCase):
def setUp(self):
import os
import numpy
import random
from Danu import Output
self.filename = 'test-Simulation.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.sim=self.fh.add_simulation('Test Simulation')
self.data_name_1d='Integer Data 1D'
self.n=random.randint(1000,10000)
self.data_1d=numpy.zeros((self.n),numpy.int32)
i=0
while i < self.n:
self.data_1d[i]=random.randint(1,100000)
i=i+1
self.sim.data_write(self.data_name_1d,self.data_1d)
self.data_name_2d='Integer Data 2D'
self.n1=random.randint(100,1000)
self.n2=random.randint(100,1000)
self.data_2d=numpy.zeros((self.n1,self.n2),numpy.int32)
i=0
while i < self.n1:
j=0
while j < self.n2:
self.data_2d[i][j]=random.randint(1,100000)
j=j+1
i=i+1
self.sim.data_write(self.data_name_2d,self.data_2d)
self.data_name_3d='Integer Data 3D'
self.n1=random.randint(10,100)
self.n2=random.randint(10,100)
self.n3=random.randint(10,100)
self.data_3d=numpy.zeros((self.n1,self.n2,self.n3),numpy.int32)
i=0
while i < self.n1:
j=0
while j < self.n2:
k=0
while k < self.n3:
self.data_3d[i][j][k]=random.randint(1,100000)
k=k+1
j=j+1
i=i+1
self.sim.data_write(self.data_name_3d,self.data_3d)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
def runTest(self):
try:
data=self.sim.data_read('Data DNE')
except:
print 'Caught bad non-series data name'
else:
raise RuntimeError, 'Failed to catch DNE dataset name'
data1=self.sim.data_read(self.data_name_1d)
self.assertEqual(data1.all(),self.data_1d.all())
data2=self.sim.data_read(self.data_name_2d)
self.assertEqual(data2.all(),self.data_2d.all())
data3=self.sim.data_read(self.data_name_3d)
self.assertEqual(data3.all(),self.data_3d.all())