Index: branches/numpy/anuga/pmesh/test_mesh_interface.py
===================================================================
--- anuga_core/source/anuga/pmesh/test_mesh_interface.py	(revision 6199)
+++ branches/numpy/anuga/pmesh/test_mesh_interface.py	(revision 6304)
@@ -1,4 +1,4 @@
 #!/usr/bin/env python
-#
+
 import tempfile
 import unittest
@@ -13,8 +13,9 @@
 from anuga.coordinate_transforms.geo_reference import Geo_reference,DEFAULT_ZONE
 
+
 class TestCase(unittest.TestCase):
     def setUp(self):
         pass
-    
+
     def tearDown(self):
         pass
@@ -23,9 +24,9 @@
         x=-500
         y=-1000
-        mesh_geo = geo_reference=Geo_reference(56,x,y)
-        
-        # These are the absolute values
-        polygon_absolute = [[0,0],[100,0],[100,100],[0,100]]
-        
+        mesh_geo = geo_reference=Geo_reference(56, x, y)
+
+        # These are the absolute values
+        polygon_absolute = [[0,0], [100,0], [100,100], [0,100]]
+
         x_p = -10
         y_p = -40
@@ -33,19 +34,16 @@
         polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute)
 
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
-        inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]]
-        inner1_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner1_polygon_absolute)
-
-        inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]]
-        inner2_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner2_polygon_absolute)
-        
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
-        
-        #print polygon
-        #print boundary_tags
-        
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
+        inner1_polygon_absolute = [[10,10], [20,10], [20,20], [10,20]]
+        inner1_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner1_polygon_absolute)
+
+        inner2_polygon_absolute = [[30,30], [40,30], [40,40], [30,40]]
+        inner2_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner2_polygon_absolute)
+
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
+
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
@@ -56,20 +54,12 @@
 
         # Test the mesh instance
-        self.failUnless(len(m.regions)==3,
-                        'FAILED!')
+        self.failUnless(len(m.regions)==3, 'FAILED!')
         segs = m.getUserSegments()
-        self.failUnless(len(segs)==12,
-                        'FAILED!')
-        self.failUnless(len(m.userVertices)==12,
-                        'FAILED!') 
-        self.failUnless(segs[0].tag=='walls',
-                        'FAILED!')  
-        self.failUnless(segs[1].tag=='walls',
-                        'FAILED!') 
-         
-        self.failUnless(segs[2].tag=='bom',
-                        'FAILED!') 
-        self.failUnless(segs[3].tag=='bom',
-                        'FAILED!')
+        self.failUnless(len(segs)==12, 'FAILED!')
+        self.failUnless(len(m.userVertices)==12, 'FAILED!')
+        self.failUnless(segs[0].tag=='walls', 'FAILED!')
+        self.failUnless(segs[1].tag=='walls', 'FAILED!')
+        self.failUnless(segs[2].tag=='bom', 'FAILED!')
+        self.failUnless(segs[3].tag=='bom', 'FAILED!')
 
         # Assuming the order of the region points is known.
@@ -77,53 +67,43 @@
         # a black box)
         poly_point = m.getRegions()[0]
-        
-        #print "poly_point", poly_point
-        #print "polygon_absolute",polygon_absolute
-         
+
         # poly_point values are relative to the mesh geo-ref
         # make them absolute
-        self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y],
-                                          polygon_absolute, closed = False),
+        self.failUnless(is_inside_polygon([poly_point.x+x, poly_point.y+y],
+                                          polygon_absolute, closed=False),
                         'FAILED!')
-        
+
         # Assuming the order of the region points is known.
         # (This isn't true, if you consider create_mesh_from_regions
         # a black box)
         poly_point = m.getRegions()[1]
-        
-        #print "poly_point", poly_point
-        #print "polygon_absolute",polygon_absolute
-         
+
         # poly_point values are relative to the mesh geo-ref
         # make them absolute
-        self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y],
+        self.failUnless(is_inside_polygon([poly_point.x+x, poly_point.y+y],
                                           inner1_polygon_absolute,
-                                          closed = False),
+                                          closed=False),
                         'FAILED!')
-        
+
         # Assuming the order of the region points is known.
         # (This isn't true, if you consider create_mesh_from_regions
         # a black box)
         poly_point = m.getRegions()[2]
-        
-        #print "poly_point", poly_point
-        #print "polygon_absolute",polygon_absolute
-         
+
         # poly_point values are relative to the mesh geo-ref
         # make them absolute
-        self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y],
+        self.failUnless(is_inside_polygon([poly_point.x+x, poly_point.y+y],
                                           inner2_polygon_absolute,
-                                          closed = False),
+                                          closed=False),
                         'FAILED!')
-
 
     def test_create_mesh_from_regions_with_caching(self):
         x=-500
         y=-1000
-        mesh_geo = geo_reference=Geo_reference(56,x,y)
-        
-        # These are the absolute values
-        polygon_absolute = [[0,0],[100,0],[100,100],[0,100]]
-        
+        mesh_geo = geo_reference=Geo_reference(56, x, y)
+
+        # These are the absolute values
+        polygon_absolute = [[0,0], [100,0], [100,100], [0,100]]
+
         x_p = -10
         y_p = -40
@@ -131,15 +111,15 @@
         polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute)
 
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
-        inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]]
-        inner1_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner1_polygon_absolute)
-
-        inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]]
-        inner2_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner2_polygon_absolute)
-        
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
+        inner1_polygon_absolute = [[10,10], [20,10], [20,20], [10,20]]
+        inner1_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner1_polygon_absolute)
+
+        inner2_polygon_absolute = [[30,30], [40,30], [40,40], [30,40]]
+        inner2_polygon = geo_ref_poly.\
+                             change_points_geo_ref(inner2_polygon_absolute)
+
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
 
         interior_holes = None
@@ -147,4 +127,5 @@
         # Clear cache first
         from anuga.caching import cache
+
         cache(_create_mesh_from_regions,
               (polygon, boundary_tags),
@@ -159,7 +140,4 @@
               clear=1)
 
-        #print polygon
-        #print boundary_tags
-        
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
@@ -173,20 +151,12 @@
 
         # Test the mesh instance
-        self.failUnless(len(m.regions)==3,
-                        'FAILED!')
+        self.failUnless(len(m.regions)==3, 'FAILED!')
         segs = m.getUserSegments()
-        self.failUnless(len(segs)==12,
-                        'FAILED!')
-        self.failUnless(len(m.userVertices)==12,
-                        'FAILED!') 
-        self.failUnless(segs[0].tag=='walls',
-                        'FAILED!')  
-        self.failUnless(segs[1].tag=='walls',
-                        'FAILED!') 
-         
-        self.failUnless(segs[2].tag=='bom',
-                        'FAILED!') 
-        self.failUnless(segs[3].tag=='bom',
-                        'FAILED!')
+        self.failUnless(len(segs)==12, 'FAILED!')
+        self.failUnless(len(m.userVertices)==12, 'FAILED!')
+        self.failUnless(segs[0].tag=='walls', 'FAILED!')
+        self.failUnless(segs[1].tag=='walls', 'FAILED!')
+        self.failUnless(segs[2].tag=='bom', 'FAILED!')
+        self.failUnless(segs[3].tag=='bom', 'FAILED!')
 
         # Assuming the order of the region points is known.
@@ -194,44 +164,35 @@
         # a black box)
         poly_point = m.getRegions()[0]
-        
-        #print "poly_point", poly_point
-        #print "polygon_absolute",polygon_absolute
-         
+
         # poly_point values are relative to the mesh geo-ref
         # make them absolute
-        self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y],
-                                          polygon_absolute, closed = False),
+        self.failUnless(is_inside_polygon([poly_point.x+x, poly_point.y+y],
+                                          polygon_absolute,
+                                          closed=False),
                         'FAILED!')
-        
+
         # Assuming the order of the region points is known.
         # (This isn't true, if you consider create_mesh_from_regions
         # a black box)
         poly_point = m.getRegions()[1]
-        
-        #print "poly_point", poly_point
-        #print "polygon_absolute",polygon_absolute
-         
+
         # poly_point values are relative to the mesh geo-ref
         # make them absolute
-        self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y],
+        self.failUnless(is_inside_polygon([poly_point.x+x, poly_point.y+y],
                                           inner1_polygon_absolute,
-                                          closed = False),
+                                          closed=False),
                         'FAILED!')
-        
+
         # Assuming the order of the region points is known.
         # (This isn't true, if you consider create_mesh_from_regions
         # a black box)
         poly_point = m.getRegions()[2]
-        
-        #print "poly_point", poly_point
-        #print "polygon_absolute",polygon_absolute
-         
+
         # poly_point values are relative to the mesh geo-ref
         # make them absolute
-        self.failUnless(is_inside_polygon([poly_point.x+x,poly_point.y+y],
+        self.failUnless(is_inside_polygon([poly_point.x+x, poly_point.y+y],
                                           inner2_polygon_absolute,
-                                          closed = False),
+                                          closed=False),
                         'FAILED!')
-
 
         # Now create m using cached values
@@ -245,14 +206,10 @@
                                            use_cache=True)
 
-
-
-        
     def test_create_mesh_from_regions2(self):
-
-        # These are the absolute values
-        min_x = -10 
+        # These are the absolute values
+        min_x = -10
         min_y = -88
-        polygon_absolute = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
-        
+        polygon_absolute = [[min_x,min_y], [1000,100], [1000,1000], [100,1000]]
+
         x_p = -10
         y_p = -40
@@ -261,15 +218,15 @@
         polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute)
 
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
-        inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]]
-        inner1_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner1_polygon_absolute)
-
-        inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]]
-        inner2_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner2_polygon_absolute)
-        
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
+        inner1_polygon_absolute = [[10,10], [20,10], [20,20], [10,20]]
+        inner1_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner1_polygon_absolute)
+
+        inner2_polygon_absolute = [[30,30], [40,30], [40,40], [30,40]]
+        inner2_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner2_polygon_absolute)
+
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
@@ -277,193 +234,148 @@
                                      interior_regions=interior_regions,
                                      poly_geo_reference=geo_ref_poly)
-        
 
         # Test the mesh instance
-        self.failUnless(len(m.regions)==3,
-                        'FAILED!')
+        self.failUnless(len(m.regions)==3, 'FAILED!')
         segs = m.getUserSegments()
-        self.failUnless(len(segs)==12,
-                        'FAILED!')
-        self.failUnless(len(m.userVertices)==12,
-                        'FAILED!') 
-        self.failUnless(segs[0].tag=='walls',
-                        'FAILED!')  
-        self.failUnless(segs[1].tag=='walls',
-                        'FAILED!') 
-         
-        self.failUnless(segs[2].tag=='bom',
-                        'FAILED!') 
-        self.failUnless(segs[3].tag=='bom',
-                        'FAILED!')
-        
-        self.failUnless(m.geo_reference.get_zone()==zone,
-                        'FAILED!')
-        self.failUnless(m.geo_reference.get_xllcorner()==min_x,
-                        'FAILED!')
-        self.failUnless(m.geo_reference.get_yllcorner()==min_y,
-                        'FAILED!')
-
-        
+        self.failUnless(len(segs)==12, 'FAILED!')
+        self.failUnless(len(m.userVertices)==12, 'FAILED!')
+        self.failUnless(segs[0].tag=='walls', 'FAILED!')
+        self.failUnless(segs[1].tag=='walls', 'FAILED!')
+        self.failUnless(segs[2].tag=='bom', 'FAILED!')
+        self.failUnless(segs[3].tag=='bom', 'FAILED!')
+        self.failUnless(m.geo_reference.get_zone()==zone, 'FAILED!')
+        self.failUnless(m.geo_reference.get_xllcorner()==min_x, 'FAILED!')
+        self.failUnless(m.geo_reference.get_yllcorner()==min_y, 'FAILED!')
+
     def test_create_mesh_from_regions3(self):
-
-        # These are the absolute values
-        min_x = -10 
+        # These are the absolute values
+        min_x = -10
         min_y = -88
-        polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
-        
+        polygon = [[min_x,min_y], [1000,100], [1000,1000], [100,1000]]
+
 
         x_p = -10
         y_p = -40
         geo_ref_poly = Geo_reference(56, x_p, y_p)
-        
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
-        inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]]
-        inner1_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner1_polygon_absolute)
-
-        inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]]
-        inner2_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner2_polygon_absolute)
-        
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
+
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
+        inner1_polygon_absolute = [[10,10], [20,10], [20,20], [10,20]]
+        inner1_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner1_polygon_absolute)
+
+        inner2_polygon_absolute = [[30,30], [40,30], [40,40], [30,40]]
+        inner2_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner2_polygon_absolute)
+
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
                                      10000000,
                                      interior_regions=interior_regions)
-        
 
         # Test the mesh instance
-        self.failUnless(len(m.regions)==3,
-                        'FAILED!')
+        self.failUnless(len(m.regions) == 3, 'FAILED!')
         segs = m.getUserSegments()
-        self.failUnless(len(segs)==12,
-                        'FAILED!')
-        self.failUnless(len(m.userVertices)==12,
-                        'FAILED!') 
-        self.failUnless(segs[0].tag=='walls',
-                        'FAILED!')  
-        self.failUnless(segs[1].tag=='walls',
-                        'FAILED!') 
-         
-        self.failUnless(segs[2].tag=='bom',
-                        'FAILED!') 
-        self.failUnless(segs[3].tag=='bom',
-                        'FAILED!')
-        
-        self.failUnless(m.geo_reference.get_zone()==DEFAULT_ZONE,
-                        'FAILED!')
-        self.failUnless(m.geo_reference.get_xllcorner()==min_x,
-                        'FAILED!')
-        self.failUnless(m.geo_reference.get_yllcorner()==min_y,
-                        'FAILED!')
+        self.failUnless(len(segs) == 12, 'FAILED!')
+        self.failUnless(len(m.userVertices) == 12, 'FAILED!')
+        self.failUnless(segs[0].tag == 'walls', 'FAILED!')
+        self.failUnless(segs[1].tag == 'walls', 'FAILED!')
+        self.failUnless(segs[2].tag == 'bom', 'FAILED!')
+        self.failUnless(segs[3].tag == 'bom', 'FAILED!')
+        self.failUnless(m.geo_reference.get_zone() == DEFAULT_ZONE, 'FAILED!')
+        self.failUnless(m.geo_reference.get_xllcorner() == min_x, 'FAILED!')
+        self.failUnless(m.geo_reference.get_yllcorner() == min_y, 'FAILED!')
 
     def test_create_mesh_from_regions4(self):
-
-        file_name = tempfile.mktemp(".tsh")
-        
+        file_name = tempfile.mktemp('.tsh')
+
         # These are the absolute values
         density_outer = 1000
-        min_outer = 0 
+        min_outer = 0
         max_outer = 1000
-        polygon_outer = [[min_outer,min_outer],[max_outer,min_outer],
-                   [max_outer,max_outer],[min_outer,max_outer]]
-        
+        polygon_outer = [[min_outer,min_outer], [max_outer,min_outer],
+                         [max_outer,max_outer], [min_outer,max_outer]]
+
         density_inner1 = 10000000
         inner_buffer = 100
         min_inner1 = min_outer + inner_buffer
         max_inner1 = max_outer - inner_buffer
-        inner1_polygon = [[min_inner1,min_inner1],[max_inner1,min_inner1],
-                   [max_inner1,max_inner1],[min_inner1,max_inner1]]
-      
-        
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
+        inner1_polygon = [[min_inner1,min_inner1], [max_inner1,min_inner1],
+                          [max_inner1,max_inner1], [min_inner1,max_inner1]]
+
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
         interior_regions = [(inner1_polygon, density_inner1)]
-        create_mesh_from_regions(polygon_outer
-                                     , boundary_tags
-                                     , density_outer
-                                     , interior_regions=interior_regions
-                                     ,filename=file_name
-                                     #,verbose=True
-                                     ,verbose=False
-                                     )
-        
+        create_mesh_from_regions(polygon_outer,
+                                 boundary_tags,
+                                 density_outer,
+                                 interior_regions=interior_regions,
+                                 filename=file_name, verbose=False)
+
         m = importMeshFromFile(file_name)
-        
-        #print "file_name",file_name 
+
         self.failUnless(len(m.getTriangulation()) <= 900,
                         'Test mesh interface failed!')
         self.failUnless(len(m.getTriangulation()) >= 200,
                         'Test mesh interface failed!')
-        
-        create_mesh_from_regions(polygon_outer
-                                     , boundary_tags
-                                     , interior_regions=interior_regions
-                                     ,filename=file_name
-                                     #,verbose=True
-                                     ,verbose=False
-                                     )
-        
+
+        create_mesh_from_regions(polygon_outer,
+                                 boundary_tags,
+                                 interior_regions=interior_regions,
+                                 filename=file_name,
+                                 verbose=False)
+
         m = importMeshFromFile(file_name)
-        
-        #print "len(m.meshTriangles)",len(m.meshTriangles) 
+
         self.failUnless(len(m.getTriangulation()) <= 100,
                         'Test mesh interface failed!')
 
         os.remove(file_name)
-        
+
     def test_create_mesh_from_regions5(self):
-
-        file_name = tempfile.mktemp(".tsh")
-        
-        # These are the absolute values
-        density_outer = 10000000 
-        min_outer = 0 
+        file_name = tempfile.mktemp('.tsh')
+
+        # These are the absolute values
+        density_outer = 10000000
+        min_outer = 0
         max_outer = 1000
-        polygon_outer = [[min_outer,min_outer],[max_outer,min_outer],
-                   [max_outer,max_outer],[min_outer,max_outer]]
-        
+        polygon_outer = [[min_outer,min_outer], [max_outer,min_outer],
+                         [max_outer,max_outer], [min_outer,max_outer]]
+
         density_inner1 = 1000
         inner_buffer = 100
         min_inner1 = min_outer + inner_buffer
         max_inner1 = max_outer - inner_buffer
-        inner1_polygon = [[min_inner1,min_inner1],[max_inner1,min_inner1],
-                   [max_inner1,max_inner1],[min_inner1,max_inner1]]
-      
-        
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
+        inner1_polygon = [[min_inner1,min_inner1], [max_inner1,min_inner1],
+                          [max_inner1,max_inner1], [min_inner1,max_inner1]]
+
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
         interior_regions = [(inner1_polygon, density_inner1)]
-        create_mesh_from_regions(polygon_outer
-                                     , boundary_tags
-                                     , density_outer
-                                     , interior_regions=interior_regions
-                                     ,filename=file_name
-                                     #,verbose=True
-                                     ,verbose=False
-                                     )
-        
+        create_mesh_from_regions(polygon_outer,
+                                 boundary_tags,
+                                 density_outer,
+                                 interior_regions=interior_regions,
+                                 filename=file_name,
+                                 verbose=False)
+
         m = importMeshFromFile(file_name)
-        #print "file_name",file_name
-        #print "len(m.meshTriangles",len(m.meshTriangles) 
-        self.failUnless(len(m.getTriangulation()) <= 2000, 
+        self.failUnless(len(m.getTriangulation()) <= 2000,
                         'Test mesh interface failed!')
- 
         self.failUnless(len(m.getTriangulation()) >= 900,
                         'Test mesh interface failed!')
 
         os.remove(file_name)
-        
+
     def test_create_mesh_from_regions6(self):
-
-        file_name = tempfile.mktemp(".tsh")
-        
+        file_name = tempfile.mktemp('.tsh')
+
         # These are the absolute values
         density_outer = 1000
-        min_outer = 0 
+        min_outer = 0
         max_outer = 1000
-        polygon_outer = [[min_outer,min_outer],[max_outer,min_outer],
-                         [max_outer,max_outer],[min_outer,max_outer]]
+        polygon_outer = [[min_outer,min_outer], [max_outer,min_outer],
+                         [max_outer,max_outer], [min_outer,max_outer]]
 
         delta = 10
@@ -471,16 +383,15 @@
         min_inner1 = min_outer + delta
         max_inner1 = max_outer - delta
-        inner1_polygon = [[min_inner1,min_inner1],[max_inner1,min_inner1],
-                          [max_inner1,max_inner1],[min_inner1,max_inner1]]
-      
-        
-        density_inner2 = 10000000 
+        inner1_polygon = [[min_inner1,min_inner1], [max_inner1,min_inner1],
+                          [max_inner1,max_inner1], [min_inner1,max_inner1]]
+
+        density_inner2 = 10000000
         min_inner2 = min_outer +  2*delta
         max_inner2 = max_outer -  2*delta
-        inner2_polygon = [[min_inner2,min_inner2],[max_inner2,min_inner2],
-                          [max_inner2,max_inner2],[min_inner2,max_inner2]]
-        
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-        
+        inner2_polygon = [[min_inner2,min_inner2], [max_inner2,min_inner2],
+                          [max_inner2,max_inner2], [min_inner2,max_inner2]]
+
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
         interior_regions = [(inner1_polygon, density_inner1),
                             (inner2_polygon, density_inner2)]
@@ -491,26 +402,22 @@
                                  filename=file_name,
                                  verbose=False)
-        
+
         m = importMeshFromFile(file_name)
-        #print "file_name",file_name
-        #print "len(m.meshTriangles",len(m.meshTriangles) 
-        self.failUnless(len(m.getTriangulation()) <= 2000, 
+        self.failUnless(len(m.getTriangulation()) <= 2000,
                         'Test mesh interface failed!')
- 
         self.failUnless(len(m.getTriangulation()) >= 900,
                         'Test mesh interface failed!')
 
         os.remove(file_name)
-        
+
     def test_create_mesh_from_regions7(self):
-
-        file_name = tempfile.mktemp(".tsh")
-        
+        file_name = tempfile.mktemp('.tsh')
+
         # These are the absolute values
         density_outer = 1001
-        min_outer = 0 
+        min_outer = 0
         max_outer = 1000
-        polygon_outer = [[min_outer,min_outer],[max_outer,min_outer],
-                   [max_outer,max_outer],[min_outer,max_outer]]
+        polygon_outer = [[min_outer,min_outer], [max_outer,min_outer],
+                         [max_outer,max_outer], [min_outer,max_outer]]
 
         delta = 10
@@ -518,20 +425,20 @@
         min_inner1 = min_outer + delta
         max_inner1 = max_outer - delta
-        inner1_polygon = [[min_inner1,min_inner1],[max_inner1,min_inner1],
-                   [max_inner1,max_inner1],[min_inner1,max_inner1]]
-      
-        
-        density_inner2 = 1000 
+        inner1_polygon = [[min_inner1,min_inner1], [max_inner1,min_inner1],
+                          [max_inner1,max_inner1], [min_inner1,max_inner1]]
+
+        density_inner2 = 1000
         min_inner2 = min_outer +  2*delta
         max_inner2 = max_outer -  2*delta
-        inner2_polygon = [[min_inner2,min_inner2],[max_inner2,min_inner2],
-                   [max_inner2,max_inner2],[min_inner2,max_inner2]]
-        
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-
-        #Note the list order is important
+        inner2_polygon = [[min_inner2,min_inner2], [max_inner2,min_inner2],
+                          [max_inner2,max_inner2], [min_inner2,max_inner2]]
+
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
+        # Note the list order is important
         # The last region added will be the region triangle uses,
         # if two regions points are in the same bounded area.
-        interior_regions = [(inner2_polygon, density_inner2),(inner1_polygon, density_inner1)]
+        interior_regions = [(inner2_polygon, density_inner2),
+                            (inner1_polygon, density_inner1)]
         create_mesh_from_regions(polygon_outer,
                                  boundary_tags,
@@ -540,11 +447,8 @@
                                  filename=file_name,
                                  verbose=False)
-        
+
         m = importMeshFromFile(file_name)
-        #print "file_name",file_name
-        #print "len(m.meshTriangles",len(m.meshTriangles) 
-        self.failUnless(len(m.getTriangulation()) <= 3000, 
+        self.failUnless(len(m.getTriangulation()) <= 3000,
                         'Test mesh interface failed!')
- 
         self.failUnless(len(m.getTriangulation()) >= 2000,
                         'Test mesh interface failed!')
@@ -552,19 +456,18 @@
         os.remove(file_name)
 
-        
     def test_create_mesh_from_regions_interior_regions(self):
-        """Test that create_mesh_from_regions fails when an interior region is
-         outside bounding polygon.       """
-        
-
-        # These are the absolute values
-        min_x = 10 
+        '''Test that create_mesh_from_regions fails when an interior
+        region is outside bounding polygon.
+        '''
+
+        # These are the absolute values
+        min_x = 10
         min_y = 88
-        polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
-        
-        boundary_tags = {'walls':[0,1],'bom':[2,3]}
-#        boundary_tags = {'walls':[0,1]}
+        polygon = [[min_x,min_y], [1000,100], [1000,1000], [100,1000]]
+
+        boundary_tags = {'walls': [0,1], 'bom': [2,3]}
+
         # This one is inside bounding polygon - should pass
-        inner_polygon = [[800,400],[900,500],[800,600]]
+        inner_polygon = [[800,400], [900,500], [800,600]]
 
         interior_regions = [(inner_polygon, 5)]
@@ -574,12 +477,9 @@
                                      interior_regions=interior_regions)
 
-
         # This one sticks outside bounding polygon - should fail
-        inner_polygon = [[800,400],[900,500],[800,600], [200, 995]]
-        inner_polygon1 = [[800,400],[1100,500],[800,600]]
+        inner_polygon = [[800,400], [900,500], [800,600], [200, 995]]
+        inner_polygon1 = [[800,400], [1100,500], [800,600]]
         interior_regions = [[inner_polygon, 50], [inner_polygon1, 50]]
 
-
-        
         try:
             m = create_mesh_from_regions(polygon,
@@ -593,13 +493,12 @@
             msg = 'Interior polygon sticking outside bounding polygon should '
             msg += 'cause an Exception to be raised'
-            raise msg
+            raise Exception, msg
 
     def test_create_mesh_from_regions_interior_regions1(self):
-        """Test that create_mesh_from_regions fails when an interior region is
-         outside bounding polygon.       """
-        
+        '''Test that create_mesh_from_regions fails
+        when an interior region is outside bounding polygon.
+        '''
 
         # These are the values
-
         d0 = [310000, 7690000]
         d1 = [280000, 7690000]
@@ -609,7 +508,6 @@
         d5 = [300000, 7590000]
         d6 = [340000, 7610000]
-
         poly_all = [d0, d1, d2, d3, d4, d5, d6]
-        
+
         i0 = [304000, 7607000]
         i1 = [302000, 7605000]
@@ -619,25 +517,23 @@
 #        i4 = [310000, 7580000]
         i5 = [307000, 7606000]
-
         poly_onslow = [i0, i1, i2, i3, i4, i5]
 
-        #Thevenard Island
+        # Thevenard Island
         j0 = [294000, 7629000]
         j1 = [285000, 7625000]
         j2 = [294000, 7621000]
         j3 = [299000, 7625000]
-
         poly_thevenard = [j0, j1, j2, j3]
 
-        #med res around onslow
+        # med res around onslow
         l0 = [300000, 7610000]
         l1 = [285000, 7600000]
         l2 = [300000, 7597500]
-        l3 = [310000, 7770000] #this one is outside
-#        l3 = [310000, 7630000] #this one is NOT outside
+        l3 = [310000, 7770000] # this one is outside
+#        l3 = [310000, 7630000] # this one is NOT outside
         l4 = [315000, 7610000]
         poly_coast = [l0, l1, l2, l3, l4]
 
-        #general coast and local area to onslow region
+        # general coast and local area to onslow region
         m0 = [270000, 7581000]
         m1 = [300000, 7591000]
@@ -646,13 +542,11 @@
         m4 = [290000, 7640000]
         m5 = [260000, 7600000]
-
         poly_region = [m0, m1, m2, m3, m4, m5]
 
         # This one sticks outside bounding polygon - should fail
-
-        interior_regions = [[poly_onslow, 50000], [poly_region, 50000], [poly_coast,100000], [poly_thevenard, 100000]]
-
-        boundary_tags = {'walls':[0,1],'bom':[2]}
-        
+        interior_regions = [[poly_onslow, 50000], [poly_region, 50000],
+                            [poly_coast, 100000], [poly_thevenard, 100000]]
+        boundary_tags = {'walls': [0,1], 'bom': [2]}
+
         try:
             m = create_mesh_from_regions(poly_all,
@@ -666,40 +560,29 @@
             msg = 'Interior polygon sticking outside bounding polygon should '
             msg += 'cause an Exception to be raised'
-            raise msg
-
-
+            raise Exception, msg
 
     def FIXME_test_create_mesh_with_multiply_tagged_segments(self):
-        """Test that create_mesh_from_regions fails when
+        '''Test that create_mesh_from_regions fails when
         segments are listed repeatedly in boundary_tags.
-        """
-        
-        
-        
-
-        # These are the absolute values
-        min_x = 10 
+        '''
+
+        # These are the absolute values
+        min_x = 10
         min_y = 88
-        polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
-
-        
-        boundary_tags = {'walls':[0,1],'bom':[1,2]}
+        polygon = [[min_x,min_y], [1000,100], [1000,1000], [100,1000]]
+        boundary_tags = {'walls': [0,1], 'bom': [1,2]}
 
         # This one is inside bounding polygon - should pass
-        inner_polygon = [[800,400],[900,500],[800,600]]
-        
+        inner_polygon = [[800,400], [900,500], [800,600]]
         interior_regions = [(inner_polygon, 5)]
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
                                      10000000,
-                                     interior_regions=interior_regions,verbose=False)
-
+                                     interior_regions=interior_regions,
+                                     verbose=False)
 
         # This one sticks outside bounding polygon - should fail
-        inner_polygon = [[800,400],[900,500],[800,600]]
+        inner_polygon = [[800,400], [900,500], [800,600]]
         interior_regions = [(inner_polygon, 5)]
-
-
-
         try:
             m = create_mesh_from_regions(polygon,
@@ -712,19 +595,13 @@
             msg = 'Tags are listed repeatedly, but create mesh from regions '
             msg += 'does not cause an Exception to be raised'
-            raise msg
-
-        
-
+            raise Exception, msg
 
     def test_create_mesh_from_regions_with_duplicate_verts(self):
-
-        # These are the absolute values
-        
-        polygon_absolute = [[0.0,0.0],
-                            [0,4.0],
-                            [4.0,4.0],
-                            [4.0,0.0],
-                            [4.0,0.0]]
-        
+        # These are the absolute values
+        polygon_absolute = [[0.0, 0.0],
+                            [0, 4.0],
+                            [4.0, 4.0],
+                            [4.0, 0.0],
+                            [4.0, 0.0]]
         x_p = -10
         y_p = -40
@@ -732,30 +609,25 @@
         geo_ref_poly = Geo_reference(zone, x_p, y_p)
         polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute)
-
-        boundary_tags = {'50':[0],
-                         '40':[1],
-                         '30':[2],
-                         'no where seg':[3],
-                         '20':[4]
-                         }
-       
+        boundary_tags = {'50': [0],
+                         '40': [1],
+                         '30': [2],
+                         'no where seg': [3],
+                         '20': [4]}
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
                                      10000000,
-                                     poly_geo_reference=geo_ref_poly,verbose=False)
-        
-
-        fileName = "badmesh.tsh"
+                                     poly_geo_reference=geo_ref_poly,
+                                     verbose=False)
+
+        fileName = 'badmesh.tsh'
         #m.export_mesh_file(fileName)
-  
-        
+
     def concept_create_mesh_from_regions_with_ungenerate(self):
         x=0
         y=0
-        mesh_geo = geo_reference=Geo_reference(56,x,y)
-        
-        # These are the absolute values
-        polygon_absolute = [[0,0],[100,0],[100,100],[0,100]]
-        
+        mesh_geo = geo_reference=Geo_reference(56, x, y)
+
+        # These are the absolute values
+        polygon_absolute = [[0,0], [100,0], [100,100], [0,100]]
         x_p = -10
         y_p = -40
@@ -763,16 +635,16 @@
         polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute)
 
-        boundary_tags = {'walls':[0,1],'bom':[2]}
-        
-        inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]]
-        inner1_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner1_polygon_absolute)
-
-        inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]]
-        inner2_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner2_polygon_absolute)
-        
+        boundary_tags = {'walls': [0,1], 'bom': [2]}
+
+        inner1_polygon_absolute = [[10,10], [20,10], [20,20], [10,20]]
+        inner1_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner1_polygon_absolute)
+
+        inner2_polygon_absolute = [[30,30], [40,30], [40,40], [30,40]]
+        inner2_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner2_polygon_absolute)
+
         max_area = 10000000
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
@@ -781,10 +653,10 @@
                                      poly_geo_reference=geo_ref_poly,
                                      mesh_geo_reference=mesh_geo)
-                    
-        m.export_mesh_file('a_test_mesh_iknterface.tsh')                 
-        
-        fileName = tempfile.mktemp(".txt")
-        file = open(fileName,"w")
-        file.write("         1       ??      ??\n\
+
+        m.export_mesh_file('a_test_mesh_iknterface.tsh')
+
+        fileName = tempfile.mktemp('.txt')
+        file = open(fileName, 'w')
+        file.write('         1       ??      ??\n\
        90.0       90.0\n\
        81.0       90.0\n\
@@ -799,23 +671,22 @@
        10.0       80.0\n\
 END\n\
-END\n")
-        file.close() 
-        
+END\n')
+        file.close()
+
         m.import_ungenerate_file(fileName, tag='wall')
         os.remove(fileName)
-        m.generate_mesh(maximum_triangle_area=max_area,verbose=False)
+        m.generate_mesh(maximum_triangle_area=max_area, verbose=False)
         m.export_mesh_file('b_test_mesh_iknterface.tsh')
 
     def concept_ungenerateII(self):
-        
         from anuga.shallow_water import Domain, Reflective_boundary, \
                             Dirichlet_boundary
+
         x=0
         y=0
-        mesh_geo = geo_reference=Geo_reference(56,x,y)
-        
-        # These are the absolute values
-        polygon_absolute = [[0,0],[100,0],[100,100],[0,100]]
-        
+        mesh_geo = geo_reference=Geo_reference(56, x, y)
+
+        # These are the absolute values
+        polygon_absolute = [[0,0], [100,0], [100,100], [0,100]]
         x_p = -10
         y_p = -40
@@ -823,16 +694,16 @@
         polygon = geo_ref_poly.change_points_geo_ref(polygon_absolute)
 
-        boundary_tags = {'wall':[0,1,3],'wave':[2]}
-        
-        inner1_polygon_absolute = [[10,10],[20,10],[20,20],[10,20]]
-        inner1_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner1_polygon_absolute)
-
-        inner2_polygon_absolute = [[30,30],[40,30],[40,40],[30,40]]
-        inner2_polygon = geo_ref_poly. \
-                         change_points_geo_ref(inner2_polygon_absolute)
-        
+        boundary_tags = {'wall': [0,1,3], 'wave': [2]}
+
+        inner1_polygon_absolute = [[10,10], [20,10], [20,20], [10,20]]
+        inner1_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner1_polygon_absolute)
+
+        inner2_polygon_absolute = [[30,30], [40,30], [40,40], [30,40]]
+        inner2_polygon = geo_ref_poly.\
+                            change_points_geo_ref(inner2_polygon_absolute)
+
         max_area = 1
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
@@ -841,10 +712,10 @@
                                      poly_geo_reference=geo_ref_poly,
                                      mesh_geo_reference=mesh_geo)
-                    
-        m.export_mesh_file('a_test_mesh_iknterface.tsh')                 
-        
-        fileName = tempfile.mktemp(".txt")
-        file = open(fileName,"w")
-        file.write("         1       ??      ??\n\
+
+        m.export_mesh_file('a_test_mesh_iknterface.tsh')
+
+        fileName = tempfile.mktemp('.txt')
+        file = open(fileName, 'w')
+        file.write('         1       ??      ??\n\
        90.0       90.0\n\
        81.0       90.0\n\
@@ -859,51 +730,45 @@
        10.0       80.0\n\
 END\n\
-END\n")
-        file.close() 
-        
-        m.import_ungenerate_file(fileName) #, tag='wall')
+END\n')
+        file.close()
+
+        m.import_ungenerate_file(fileName)      #, tag='wall')
         os.remove(fileName)
-        m.generate_mesh(maximum_triangle_area=max_area,verbose=False)
-        mesh_filename = "bento_b.tsh"
+        m.generate_mesh(maximum_triangle_area=max_area, verbose=False)
+        mesh_filename = 'bento_b.tsh'
         m.export_mesh_file(mesh_filename)
 
         domain = Domain(mesh_filename, use_cache = False)
-        
+
         Br = Reflective_boundary(domain)
-        Bd = Dirichlet_boundary([3,0,0]) 
-        domain.set_boundary( {'wall': Br, 'wave': Bd} )
+        Bd = Dirichlet_boundary([3, 0, 0])
+        domain.set_boundary({'wall': Br, 'wave': Bd})
         yieldstep = 0.1
         finaltime = 10
-        for t in domain.evolve(yieldstep, finaltime):    
+        for t in domain.evolve(yieldstep, finaltime):
             domain.write_time()
-    
+
     def concept_ungenerateIII(self):
-        
         from anuga.shallow_water import Domain, Reflective_boundary, \
                             Dirichlet_boundary
-       
         from anuga.pmesh.mesh_interface import create_mesh_from_regions
-        
-        # These are the absolute values
-        polygon = [[0,0],[100,0],[100,100],[0,100]]
-        
-        boundary_tags = {'wall':[0,1,3],'wave':[2]}
-        
-        inner1_polygon = [[10,10],[20,10],[20,20],[10,20]]
-        
-
-        inner2_polygon = [[30,30],[40,30],[40,40],[30,40]]
-        
-        
+
+        # These are the absolute values
+        polygon = [[0,0], [100,0], [100,100], [0,100]]
+
+        boundary_tags = {'wall': [0,1,3], 'wave': [2]}
+        inner1_polygon = [[10,10], [20,10], [20,20], [10,20]]
+        inner2_polygon = [[30,30], [40,30], [40,40], [30,40]]
+
         max_area = 1
-        interior_regions = [(inner1_polygon, 5),(inner2_polygon, 10)]
+        interior_regions = [(inner1_polygon, 5), (inner2_polygon, 10)]
         m = create_mesh_from_regions(polygon,
                                      boundary_tags,
                                      max_area,
                                      interior_regions=interior_regions)
-                    
-        fileName = tempfile.mktemp(".txt")
-        file = open(fileName,"w")
-        file.write("         1       ??      ??\n\
+
+        fileName = tempfile.mktemp('.txt')
+        file = open(fileName, 'w')
+        file.write('         1       ??      ??\n\
        90.0       90.0\n\
        81.0       90.0\n\
@@ -918,40 +783,36 @@
        10.0       80.0\n\
 END\n\
-END\n")
-        file.close() 
-        
-        m.import_ungenerate_file(fileName) 
+END\n')
+        file.close()
+
+        m.import_ungenerate_file(fileName)
         os.remove(fileName)
-        m.generate_mesh(maximum_triangle_area=max_area,verbose=False)
-        mesh_filename = "mesh.tsh"
+        m.generate_mesh(maximum_triangle_area=max_area, verbose=False)
+        mesh_filename = 'mesh.tsh'
         m.export_mesh_file(mesh_filename)
 
-        domain = Domain(mesh_filename, use_cache = False)
-        
+        domain = Domain(mesh_filename, use_cache=False)
+
         Br = Reflective_boundary(domain)
-        Bd = Dirichlet_boundary([3,0,0]) 
-        domain.set_boundary( {'wall': Br, 'wave': Bd} )
+        Bd = Dirichlet_boundary([3, 0, 0])
+        domain.set_boundary({'wall': Br, 'wave': Bd})
         yieldstep = 0.1
         finaltime = 10
-        for t in domain.evolve(yieldstep, finaltime):    
+        for t in domain.evolve(yieldstep, finaltime):
             domain.write_time()
 
-            
-        
     def test_create_mesh_from_regions_check_segs(self):
-        """Test that create_mesh_from_regions fails when an interior region is
-         outside bounding polygon.       """
-        
-
-        # These are the absolute values
-        min_x = 10 
+        '''Test that create_mesh_from_regions fails
+        when an interior region is outside bounding polygon.
+        '''
+
+        # These are the absolute values
+        min_x = 10
         min_y = 88
-        polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
-        
-        boundary_tags = {'walls':[0,1,3],'bom':[2]}
-#        boundary_tags = {'walls':[0,1]}
+        polygon = [[min_x,min_y], [1000,100], [1000,1000], [100,1000]]
+        boundary_tags = {'walls': [0,1,3], 'bom': [2]}
+
         # This one is inside bounding polygon - should pass
-        inner_polygon = [[800,400],[900,500],[800,600]]
-
+        inner_polygon = [[800,400], [900,500], [800,600]]
         interior_regions = [(inner_polygon, 5)]
         m = create_mesh_from_regions(polygon,
@@ -960,6 +821,5 @@
                                      interior_regions=interior_regions)
 
-        boundary_tags = {'walls':[0,1,3,4],'bom':[2]}
-        
+        boundary_tags = {'walls': [0,1,3,4], 'bom': [2]}
         try:
             m = create_mesh_from_regions(polygon,
@@ -970,13 +830,12 @@
             pass
         else:
-            msg = 'segment out of bounds not caught '
-            raise msg
-
-        
+            msg = 'Segment out of bounds not caught '
+            raise Exception, msg
+
+
 #-------------------------------------------------------------
 if __name__ == "__main__":
     suite = unittest.makeSuite(TestCase,'test')
-    #suite = unittest.makeSuite(TestCase,'test_create_mesh_from_regions_check_segs')
     runner = unittest.TextTestRunner() #verbosity=2)
     runner.run(suite)
-    
+
