/[escript]/trunk/pyvisi/test/python/run_carpet.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_carpet.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations)
Tue May 22 04:24:01 2007 UTC (13 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 2885 byte(s)
Made some changes to fix the memory leak problem. However, the problem still persists for run_escript_with_lazy_evaluation.py, run_streamline.py and run_streamline_with_lazy_evaluation.py.

1 from esys.pyvisi import DataCollector, Scene, Carpet
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 try:
7 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
8 except KeyError:
9 PYVISI_WORKDIR='.'
10 try:
11 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
12 except KeyError:
13 PYVISI_TEST_DATA_ROOT='.'
14
15 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
16 PYVISI_TEST_CARPET_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, \
17 "data_reference_images", "carpet")
18 PYVISI_TEST_CARPET_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
19 "data_sample_images", "carpet")
20
21 MIN_IMAGE_SIZE = 100
22 FILE_3D = "interior_3D.xml"
23 X_SIZE = 400
24 Y_SIZE = 400
25 JPG_RENDERER = Renderer.OFFLINE_JPG
26
27 class TestCarpet:
28 def render(self, file):
29 self.scene.render(image_name = \
30 os.path.join(PYVISI_TEST_CARPET_IMAGES_PATH, file))
31
32 self.failUnless(os.stat(os.path.join(PYVISI_TEST_CARPET_IMAGES_PATH,\
33 file))[ST_SIZE] > MIN_IMAGE_SIZE)
34
35 class TestCarpetScalarWarp(unittest.TestCase, TestCarpet):
36 def setUp(self):
37 self.scene = \
38 Scene(renderer = JPG_RENDERER, num_viewport = 1,
39 x_size = X_SIZE, y_size = Y_SIZE)
40
41 self.data_collector = DataCollector(source = Source.XML)
42 self.data_collector.setFileName(file_name = \
43 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
44
45 self.carpet = Carpet(scene = self.scene,
46 data_collector = self.data_collector,
47 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
48 lut = Lut.COLOR, cell_to_point = False, outline = True)
49
50 def tearDown(self):
51 del self.scene
52 del self.data_collector
53 del self.carpet
54
55 def testScalarWarp(self):
56 self.carpet.setScaleFactor(1)
57 self.carpet.setPlaneToXY()
58 self.render("TestCarpetScalarWarp.jpg")
59
60 class TestCarpetVectorWarp(unittest.TestCase, TestCarpet):
61 def setUp(self):
62 self.scene = \
63 Scene(renderer = JPG_RENDERER, num_viewport = 1,
64 x_size = X_SIZE, y_size = Y_SIZE)
65
66 self.data_collector = DataCollector(source = Source.XML)
67 self.data_collector.setFileName(file_name = \
68 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
69
70 self.carpet = Carpet(scene = self.scene,
71 data_collector = self.data_collector,
72 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.VECTOR,
73 lut = Lut.COLOR, cell_to_point = False, outline = True)
74
75 def tearDown(self):
76 del self.scene
77 del self.data_collector
78 del self.carpet
79
80 def testVectorWarp(self):
81 self.carpet.setScaleFactor(1)
82 self.carpet.setPlaneToXY()
83 self.render("TestCarpetVectorWarp.jpg")
84
85
86
87 ##############################################################################
88
89
90 if __name__ == '__main__':
91 suite = unittest.TestSuite()
92 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetScalarWarp))
93 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetVectorWarp))
94 unittest.TextTestRunner(verbosity=2).run(suite)
95

  ViewVC Help
Powered by ViewVC 1.1.26