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

Contents of /trunk/pyvisi/test/python/run_streamline_with_lazy_evaluation.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: 2128 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, StreamLine, GlobalPosition
2 from esys.pyvisi import Camera
3 from esys.pyvisi.constant import *
4 import unittest, os
5 from stat import ST_SIZE
6
7 try:
8 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
9 except KeyError:
10 PYVISI_WORKDIR='.'
11 try:
12 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
13 except KeyError:
14 PYVISI_TEST_DATA_ROOT='.'
15
16 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
17 PYVISI_TEST_STREAMLINE_REFERENCE_IMAGES_PATH = \
18 os.path.join(PYVISI_TEST_DATA_ROOT, \
19 "data_reference_images", "streamline")
20 PYVISI_TEST_STREAMLINE_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
21 "data_sample_images", "streamline")
22
23 MIN_IMAGE_SIZE = 100
24 FILE_3D = "results.xml"
25 X_SIZE = 400
26 Y_SIZE = 400
27 JPG_RENDERER = Renderer.OFFLINE_JPG
28
29 class TestStreamLineWithLazyEvaluation:
30 def render(self, file):
31 self.scene.render(image_name = \
32 os.path.join(PYVISI_TEST_STREAMLINE_IMAGES_PATH, file))
33
34 self.failUnless(os.stat(\
35 os.path.join(PYVISI_TEST_STREAMLINE_IMAGES_PATH, \
36 file))[ST_SIZE] > MIN_IMAGE_SIZE)
37
38 class TestStreamLine(unittest.TestCase, TestStreamLineWithLazyEvaluation):
39 def tearDown(self):
40 del self.scene
41
42 def testStreamLine(self):
43 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
44 y_size = Y_SIZE)
45 self.scene = s
46
47 dc1 = DataCollector(source = Source.XML)
48
49 # Create one streamline instance for the first viewport.
50 sl1 = StreamLine(scene = s, data_collector = dc1,
51 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
52 outline = True, color_mode = ColorMode.VECTOR)
53 sl1.setTubeRadius(radius = 0.01)
54
55 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
56 cam1.elevation(angle = -40)
57 dc1.setFileName(file_name = \
58 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
59
60 self.render("TestStreamLineWithLazyEvaluation.jpg")
61
62
63 ##############################################################################
64 if __name__ == '__main__':
65 suite = unittest.TestSuite()
66 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestStreamLine))
67 unittest.TextTestRunner(verbosity=2).run(suite)
68

  ViewVC Help
Powered by ViewVC 1.1.26