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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations)
Tue May 22 04:24:01 2007 UTC (12 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 1951 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, Camera
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 TestCarpetWithLazyEvaluation:
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 TestCarpet(unittest.TestCase, TestCarpetWithLazyEvaluation):
36 def tearDown(self):
37 del self.scene
38
39 def testCarpet(self):
40 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
41 y_size = Y_SIZE)
42 self.scene = s
43
44 dc1 = DataCollector(source = Source.XML)
45
46 # Create one carpet instance.
47 cpt1 = Carpet(scene = s, data_collector = dc1,
48 warp_mode = WarpMode.SCALAR, lut = Lut.COLOR)
49 cpt1.setScaleFactor(0.5)
50
51 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
52 c1.isometricView()
53
54 cpt1.setPlaneToXY(0.5)
55 dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH,\
56 FILE_3D))
57
58 self.render("TestCarpetWithLazyEvaluation.jpg")
59
60
61 ##############################################################################
62 if __name__ == '__main__':
63 suite = unittest.TestSuite()
64 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpet))
65 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26