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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2344 - (hide annotations)
Mon Mar 30 02:13:58 2009 UTC (10 years, 6 months ago) by jfenwick
File MIME type: text/x-python
File size: 2833 byte(s)
Change __url__ to launchpad site

1 ksteube 1811
2     ########################################################
3     #
4     # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 ksteube 1811
22 jongui 1148 from esys.pyvisi import DataCollector, Scene, Carpet, Camera
23     from esys.pyvisi.constant import *
24 gross 2313 from esys.escript import getMPISizeWorld
25 gross 1381 import unittest, os, sys
26 jongui 1148 from stat import ST_SIZE
27    
28     try:
29     PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
30     except KeyError:
31     PYVISI_WORKDIR='.'
32     try:
33     PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
34     except KeyError:
35     PYVISI_TEST_DATA_ROOT='.'
36    
37     PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
38     PYVISI_TEST_CARPET_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
39     "data_sample_images", "carpet")
40    
41     MIN_IMAGE_SIZE = 100
42     FILE_3D = "interior_3D.xml"
43     X_SIZE = 400
44     Y_SIZE = 400
45     JPG_RENDERER = Renderer.OFFLINE_JPG
46    
47     class TestCarpetWithLazyEvaluation:
48     def render(self, file):
49     self.scene.render(image_name = \
50     os.path.join(PYVISI_TEST_CARPET_IMAGES_PATH, file))
51    
52     self.failUnless(os.stat(os.path.join(PYVISI_TEST_CARPET_IMAGES_PATH,\
53     file))[ST_SIZE] > MIN_IMAGE_SIZE)
54    
55     class TestCarpet(unittest.TestCase, TestCarpetWithLazyEvaluation):
56 jongui 1158 def tearDown(self):
57     del self.scene
58    
59 jongui 1148 def testCarpet(self):
60     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
61     y_size = Y_SIZE)
62     self.scene = s
63    
64     dc1 = DataCollector(source = Source.XML)
65    
66     # Create one carpet instance.
67     cpt1 = Carpet(scene = s, data_collector = dc1,
68     warp_mode = WarpMode.SCALAR, lut = Lut.COLOR)
69     cpt1.setScaleFactor(0.5)
70    
71     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
72     c1.isometricView()
73    
74     cpt1.setPlaneToXY(0.5)
75     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH,\
76     FILE_3D))
77    
78     self.render("TestCarpetWithLazyEvaluation.jpg")
79    
80    
81     ##############################################################################
82     if __name__ == '__main__':
83 gross 2313 if getMPISizeWorld() == 1:
84 jongui 1148 suite = unittest.TestSuite()
85     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpet))
86 gross 1376 s=unittest.TextTestRunner(verbosity=2).run(suite)
87     if not s.wasSuccessful(): sys.exit(1)
88    
89 gross 2313 else:
90     print "run_carpet_with_lazy_evaluation.py is not executed as more than one processor is used."

  ViewVC Help
Powered by ViewVC 1.1.26