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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1
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 __url__="https://launchpad.net/escript-finley"
21
22 from esys.pyvisi import Scene, ImageReader, Logo
23 from esys.pyvisi import LocalPosition
24 from esys.pyvisi.constant import *
25 import unittest, os, sys
26 from stat import ST_SIZE
27 from esys.escript import getMPISizeWorld
28
29 try:
30 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
31 except KeyError:
32 PYVISI_WORKDIR='.'
33 try:
34 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
35 except KeyError:
36 PYVISI_TEST_DATA_ROOT='.'
37
38 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
39 PYVISI_TEST_LOGO_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
40 "data_sample_images", "logo")
41
42 MIN_IMAGE_SIZE = 100
43 LOGO = "access_logo.jpg"
44 X_SIZE = 400
45 Y_SIZE = 400
46 JPG_RENDERER = Renderer.OFFLINE_JPG
47
48 class TestLogoWithLazyEvaluation:
49 def render(self, file):
50 self.scene.render(image_name = \
51 os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, file))
52
53 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LOGO_IMAGES_PATH, \
54 file))[ST_SIZE] > MIN_IMAGE_SIZE)
55
56 class TestLogo(unittest.TestCase, TestLogoWithLazyEvaluation):
57 def tearDown(self):
58 del self.scene
59
60 def testLogo(self):
61
62 # Create a Scene.
63 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
64 y_size = Y_SIZE)
65 self.scene = s
66
67 # Create an ImageReader (in place of DataCollector).
68 ir = ImageReader(ImageFormat.JPG)
69
70 # Create a Logo.
71 l = Logo(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST)
72 l.setSize(size = 0.5)
73
74 ir.setImageName(image_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
75 LOGO))
76 l.setPosition(position = LocalPosition(50,60))
77
78 # Render the Logo.
79 self.render("TestLogoWithLazyEvaluation.jpg")
80
81
82 ###########################################################################
83
84
85 if __name__ == '__main__':
86 if getMPISizeWorld() == 1:
87 suite = unittest.TestSuite()
88 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestLogo))
89 s=unittest.TextTestRunner(verbosity=2).run(suite)
90 if not s.wasSuccessful(): sys.exit(1)
91 else:
92 print "run_logo_with_lazy_evaluation.py is not executed as more than one processor is used."
93

  ViewVC Help
Powered by ViewVC 1.1.26