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

Contents of /trunk/pyvisi/test/python/run_contour.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: 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, Contour
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_CONTOUR_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT,\
17 "data_reference_images", "contour")
18 PYVISI_TEST_CONTOUR_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
19 "data_sample_images", "contour")
20
21 MIN_IMAGE_SIZE = 100
22 FILE_2D = "interior_2D.xml"
23 X_SIZE = 400
24 Y_SIZE = 400
25 JPG_RENDERER = Renderer.OFFLINE_JPG
26
27 class TestContour(unittest.TestCase):
28 def setUp(self):
29 self.scene = \
30 Scene(renderer = JPG_RENDERER, num_viewport = 1,
31 x_size = X_SIZE, y_size = Y_SIZE)
32
33 self.data_collector = DataCollector(source = Source.XML)
34 self.data_collector.setFileName(file_name = \
35 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
36
37 self.contour = Contour(scene = self.scene,
38 data_collector = self.data_collector,
39 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
40 cell_to_point = False, outline = True)
41
42 def tearDown(self):
43 del self.scene
44 del self.data_collector
45 del self.contour
46
47 def render(self, file):
48 self.scene.render(image_name = \
49 os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, file))
50
51 self.failUnless(os.stat(os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, \
52 file))[ST_SIZE] > MIN_IMAGE_SIZE)
53
54 def testGenerateContours(self):
55 self.contour.generateContours(5)
56 self.render("TestContour_testGenerateContours.jpg")
57
58
59 ##############################################################################
60
61
62 if __name__ == '__main__':
63 suite = unittest.TestSuite()
64 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContour))
65 unittest.TextTestRunner(verbosity=2).run(suite)
66

  ViewVC Help
Powered by ViewVC 1.1.26