本文整理汇总了Python中Danu.Output类的典型用法代码示例。如果您正苦于以下问题:Python Output类的具体用法?Python Output怎么用?Python Output使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Output类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestReadDouble3D
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
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: TestConnectivity
class TestConnectivity(unittest.TestCase):
def setUp(self):
import os
import numpy
import random
from Danu import Output
from Danu import UNSTRUCTURED_MESH
from Danu import HEX_ELEM, HEX_ELEM_ORDER
self.filename = 'test-Mesh.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.mesh_name='Test Mesh 3D HEX'
self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
self.data_name='Data to Read'
self.nelem=random.randint(10,2048)
self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
nc=0
while nc < self.nelem:
i=0
while i < HEX_ELEM_ORDER:
self.data[nc][i]=random.randint(0,100000)
i=i+1
nc=nc+1
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
#os.remove(self.filename)
def test_basic(self):
import numpy
import random
# try to read before a write
try:
r_data=self.mesh.read_connectivity()
except:
print 'Caught the read before write error'
self.mesh.write_connectivity(self.data)
read_data=self.mesh.read_connectivity()
self.assertEqual(read_data.all(),self.data.all())
def test_offset(self):
import numpy
import random
self.mesh.write_connectivity(self.data)
offset=self.mesh.connectivity_offset()
self.assertEqual(offset,0)
示例4: TestCreate
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)
示例5: TestAttributes
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)
示例6: TestBasic
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)
示例7: TestAttributes
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)
示例8: TestBasic
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
示例9: TestOutputWriteAttribute
class TestOutputWriteAttribute(unittest.TestCase):
def setUp(self):
self.filename = 'test-Output.h5'
self.int_attr_name = 'Dummy Int Attribute'
self.double_attr_name = 'Dummy Double Attribute'
self.str_attr_name = 'Dummy String Attribute'
self.fh = Output(self.filename,'a')
def tearDown(self):
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def test_string_attribute(self):
import random
str_len = random.randint(16,1024)
self.fh.set_attribute(self.str_attr_name,os.urandom(str_len))
def test_double_attribute(self):
import random
self.fh.set_attribute(self.double_attr_name,random.random())
def test_int_attribute(self):
import random
self.fh.set_attribute(self.int_attr_name,random.randint(0,100000))
示例10: setUp
def setUp(self):
import os
import numpy
import random
from Danu import Output
from Danu import UNSTRUCTURED_MESH
from Danu import HEX_ELEM, HEX_ELEM_ORDER
self.filename = 'test-Mesh.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.mesh_name='Test Mesh 3D HEX'
self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
self.data_name='Data to Read'
self.nelem=random.randint(10,2048)
self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
nc=0
while nc < self.nelem:
i=0
while i < HEX_ELEM_ORDER:
self.data[nc][i]=random.randint(0,100000)
i=i+1
nc=nc+1
示例11: setUp
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)
示例12: setUp
def setUp(self):
import random
import string
self.filename = 'test-Output.h5'
self.fh = Output(self.filename,'w')
self.attributes = []
self.int_attr_name = 'Dummy Int Attribute'
self.attributes.append(self.int_attr_name)
self.int_attr = random.randint(0,1000000)
self.fh.set_attribute(self.int_attr_name,self.int_attr)
self.double_attr_name = 'Dummy Double Attribute'
self.attributes.append(self.double_attr_name)
self.double_attr = random.random()
self.fh.set_attribute(self.double_attr_name,self.double_attr)
self.str_attr_name = 'Dummy String Attribute'
self.attributes.append(self.str_attr_name)
str_len = random.randint(10,1024)
self.str_attr = ''.join(random.choice(string.letters) for i in xrange(str_len))
self.fh.set_attribute(self.str_attr_name,self.str_attr)
示例13: setUp
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)
示例14: TestDataReadDouble
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())
示例15: TestAttributes
class TestAttributes(unittest.TestCase):
def setUp(self):
import os
import numpy
import random
from Danu import Output
from Danu import UNSTRUCTURED_MESH
from Danu import HEX_ELEM, HEX_ELEM_ORDER
self.filename = 'test-Mesh.h5'
if os.path.exists(self.filename):
os.remove(self.filename)
self.fh=Output(self.filename,'w')
self.mesh_name='Test Mesh 3D HEX'
self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
self.n=random.randint(10,2048)
self.x=numpy.random.random_sample((self.n))
self.y=numpy.random.random_sample((self.n))
self.z=numpy.random.random_sample((self.n))
self.coordinates=[self.x,self.y,self.z]
self.mesh.write_coordinates(self.x,self.y,self.z)
self.nelem=random.randint(1024,2048)
self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
nc=0
while nc < self.nelem:
i=0
while i < HEX_ELEM_ORDER:
self.data[nc][i]=random.randint(0,100000)
i=i+1
nc=nc+1
self.mesh.write_connectivity(self.data)
def tearDown(self):
import os
if os.path.exists(self.filename):
self.fh.close()
os.remove(self.filename)
def runTest(self):
import Danu
self.assertEqual(self.x.size,self.mesh.nnodes())
self.assertEqual(Danu.HEX_ELEM_ORDER,self.mesh.elem_order())
print self.mesh.nelem()