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

Contents of /trunk/pyvisi/test/python/run_legend_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: 3726 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 DataCollector, Scene, Contour, Legend, LocalPosition
23 from esys.pyvisi.constant import *
24 import unittest, os, sys
25 from stat import ST_SIZE
26 from esys.escript import getMPISizeWorld
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_LEGEND_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
39 "data_sample_images", "legend")
40
41 MIN_IMAGE_SIZE = 100
42 FILE_2D = "interior_2D.xml"
43 X_SIZE = 400
44 Y_SIZE = 400
45 JPG_RENDERER = Renderer.OFFLINE_JPG
46
47 class TestLegendWithLazyEvaluation(unittest.TestCase):
48 def setUp(self):
49 self.scene = \
50 Scene(renderer = JPG_RENDERER, num_viewport = 1,
51 x_size = X_SIZE, y_size = Y_SIZE)
52
53 self.data_collector = DataCollector(source = Source.XML)
54
55 self.contour = Contour(scene = self.scene,
56 data_collector = self.data_collector,
57 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
58 cell_to_point = False, outline = True)
59
60
61 def tearDown(self):
62 del self.scene
63 del self.data_collector
64 del self.contour
65 del self.legend
66
67 def render(self, file):
68 self.scene.render(image_name = \
69 os.path.join(PYVISI_TEST_LEGEND_IMAGES_PATH, file))
70
71 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LEGEND_IMAGES_PATH, \
72 file))[ST_SIZE] > MIN_IMAGE_SIZE)
73
74 def testScalarLegendLazy(self):
75 self.legend = Legend(scene = self.scene, \
76 data_collector = self.data_collector, \
77 viewport = Viewport.SOUTH_WEST,\
78 lut = Lut.COLOR, legend = LegendType.SCALAR)
79
80 self.legend.setOrientationToHorizontal()
81 self.legend.setTitle(title = "Scalar Bar")
82 self.legend.setPosition(LocalPosition(50, 5))
83
84 self.data_collector.setFileName(file_name = \
85 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
86 self.render("TestLegend_testScalarLegendWithLazyEvaluation.jpg")
87
88 def testVectorLegendLazy(self):
89 self.legend = Legend(scene = self.scene, \
90 data_collector = self.data_collector, \
91 viewport = Viewport.SOUTH_WEST,\
92 lut = Lut.COLOR, legend = LegendType.VECTOR)
93
94 self.legend.setOrientationToVertical()
95 self.legend.setTitle(title = "Scalar Bar")
96 self.legend.setPosition(LocalPosition(5, 50))
97
98 self.data_collector.setFileName(file_name = \
99 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
100 self.render("TestLegend_testVectorLegendWithLazyEvaluation.jpg")
101
102
103
104 ##############################################################################
105
106
107 if __name__ == '__main__':
108 if getMPISizeWorld() == 1:
109 suite = unittest.TestSuite()
110 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(\
111 TestLegendWithLazyEvaluation))
112 s=unittest.TextTestRunner(verbosity=2).run(suite)
113 if not s.wasSuccessful(): sys.exit(1)
114 else:
115 print "run_legend_with_lazy_evaluation.py is not executed as more than one processor is used."

  ViewVC Help
Powered by ViewVC 1.1.26