File: TestXdmfError.py

package info (click to toggle)
xdmf 3.0%2Bgit20160803-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 35,388 kB
  • ctags: 36,627
  • sloc: ansic: 265,382; cpp: 162,889; python: 10,976; f90: 1,378; yacc: 687; fortran: 464; xml: 200; java: 187; lex: 125; makefile: 82; sh: 28
file content (47 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from XdmfCore import *

if __name__ == "__main__":

	writtenArray = XdmfArray.New()
	dimensionVector = UInt32Vector()
	dimensionVector.push_back(20)
	writtenArray.initializeAsInt32(dimensionVector)
	for i in range(20):
		writtenArray.pushBackAsInt32(i + 1)

	readArray = XdmfArray.New()
	readDimensionVector = UInt32Vector()
	readDimensionVector.push_back(6)
	readDimensionVector.push_back(4)
	readArray.initializeAsInt32(readDimensionVector)

	writeStarts = UInt32Vector()
	writeStarts.push_back(0)
	writeStarts.push_back(0)
	writeStrides = UInt32Vector()
	writeStrides.push_back(2)
	writeStrides.push_back(2)
	writeDim = UInt32Vector()
	writeDim.push_back(3)
	writeDim.push_back(2)
	readStarts = UInt32Vector()
	readStarts.push_back(0)
	readStarts.push_back(0)
	readStrides = UInt32Vector()
	readStrides.push_back(2)
	readStrides.push_back(2)
	readDim = UInt32Vector()
	readDim.push_back(3)
	readDim.push_back(2)

	try:
		readArray.insert(readStarts, writtenArray, writeStarts, writeDim, readDim, readStrides, writeStrides)
	except RuntimeError as e:
		#this is simpler than it is in C++
		print e.args[0]


	try:
		raise RuntimeError(XdmfError(XdmfError.FATAL, "testError"))
        except RuntimeError as e:
		print e.args[0].what()