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

Contents of /trunk/pyvisi/test/python/run_ellipsoid.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: 2161 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, Ellipsoid
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_ELLIPSOID_REFERENCE_IMAGES_PATH = \
17 os.path.join(PYVISI_TEST_DATA_ROOT, "data_reference_images", \
18 "ellipsoid")
19 PYVISI_TEST_ELLIPSOID_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
20 "data_sample_images", "ellipsoid")
21
22 MIN_IMAGE_SIZE = 100
23 FILE_3D = "interior_3D.xml"
24 X_SIZE = 400
25 Y_SIZE = 400
26 JPG_RENDERER = Renderer.OFFLINE_JPG
27
28 class TestEllipsoid(unittest.TestCase):
29 def setUp(self):
30 self.scene = \
31 Scene(renderer = JPG_RENDERER, num_viewport = 1,
32 x_size = X_SIZE, y_size = Y_SIZE)
33
34 self.data_collector = DataCollector(source = Source.XML)
35 self.data_collector.setFileName(file_name = \
36 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
37
38 self.ellipsoid = Ellipsoid(scene = self.scene,
39 data_collector = self.data_collector,
40 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
41 cell_to_point = False, outline = True)
42
43 def tearDown(self):
44 del self.scene
45 del self.data_collector
46 del self.ellipsoid
47
48 def render(self, file):
49 self.scene.render(image_name = \
50 os.path.join(PYVISI_TEST_ELLIPSOID_IMAGES_PATH, file))
51
52 self.failUnless(os.stat(os.path.join(PYVISI_TEST_ELLIPSOID_IMAGES_PATH,\
53 file))[ST_SIZE] > MIN_IMAGE_SIZE)
54
55 def testSphere(self):
56 self.ellipsoid.setThetaResolution(5)
57 self.ellipsoid.setPhiResolution(10)
58 self.render("TestEllipsoid_testSphere.jpg")
59
60 def testTensorGlyph(self):
61 self.ellipsoid.setScaleFactor(0.2)
62 self.ellipsoid.setMaxScaleFactor(3)
63 self.render("TestEllipsoid_testTensorGlyph.jpg")
64
65
66 ##############################################################################
67
68
69 if __name__ == '__main__':
70 suite = unittest.TestSuite()
71 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestEllipsoid))
72 unittest.TextTestRunner(verbosity=2).run(suite)
73

  ViewVC Help
Powered by ViewVC 1.1.26