Changeset 5912
- Timestamp:
- Nov 6, 2008, 4:39:06 PM (16 years ago)
- Location:
- anuga_core/source_numpy_conversion/anuga/pmesh
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/pmesh/Pmw.py
r3491 r5912 2776 2776 def index(self, index, forInsert = 0): 2777 2777 listLength = len(self._buttonList) 2778 if type(index) == types.IntType:2778 if isinstance(index, types.IntType): 2779 2779 if forInsert and index <= listLength: 2780 2780 return index … … 3708 3708 return 3709 3709 3710 if type(traverseSpec) == types.IntType:3710 if isinstance(traverseSpec, types.IntType): 3711 3711 kw['underline'] = traverseSpec 3712 3712 return … … 3951 3951 return 3952 3952 3953 if type(traverseSpec) == types.IntType:3953 if isinstance(traverseSpec, types.IntType): 3954 3954 kw['underline'] = traverseSpec 3955 3955 return … … 4507 4507 def index(self, index, forInsert = 0): 4508 4508 listLength = len(self._pageNames) 4509 if type(index) == types.IntType:4509 if isinstance(index, types.IntType): 4510 4510 if forInsert and index <= listLength: 4511 4511 return index … … 4973 4973 def index(self, index): 4974 4974 listLength = len(self._itemList) 4975 if type(index) == types.IntType:4975 if isinstance(index, types.IntType): 4976 4976 if index < listLength: 4977 4977 return index … … 5224 5224 # Parse <args> for options. 5225 5225 for arg, value in args.items(): 5226 if type(value) == types.FloatType:5226 if isinstance(value, types.FloatType): 5227 5227 relvalue = value 5228 5228 value = self._absSize(relvalue) … … 5813 5813 5814 5814 listLength = len(self._buttonList) 5815 if type(index) == types.IntType:5815 if isinstance(index, types.IntType): 5816 5816 if index < listLength: 5817 5817 return index -
anuga_core/source_numpy_conversion/anuga/pmesh/mesh.py
r5673 r5912 22 22 import types 23 23 import exceptions 24 from Numeric import array, Float, Int25 26 24 27 25 from anuga.coordinate_transforms.geo_reference import Geo_reference, \ … … 125 123 __slots__ = ['x','y','attributes'] 126 124 127 assert ( type(X) == types.FloatType or type(X) == types.IntType)128 assert ( type(Y) == types.FloatType or type(Y) == types.IntType)125 assert (isinstance(X, types.FloatType) or isinstance(X, types.IntType)) 126 assert (isinstance(Y, types.FloatType) or isinstance(Y, types.IntType)) 129 127 self.x=X 130 128 self.y=Y -
anuga_core/source_numpy_conversion/anuga/pmesh/mesh_interface.py
r5717 r5912 3 3 from anuga.utilities.polygon import point_in_polygon ,populate_polygon 4 4 from anuga.utilities.numerical_tools import ensure_numeric 5 from Numeric import Float 5 import numpy 6 6 from anuga.utilities.polygon import inside_polygon 7 7 … … 150 150 151 151 # Simple check 152 bounding_polygon = ensure_numeric(bounding_polygon, Float)152 bounding_polygon = ensure_numeric(bounding_polygon, numpy.float) 153 153 msg = 'Bounding polygon must be a list of points or an Nx2 array' 154 154 assert len(bounding_polygon.shape) == 2, msg -
anuga_core/source_numpy_conversion/anuga/pmesh/test_mesh.py
r5875 r5912 15 15 from anuga.utilities.polygon import is_inside_polygon ### inside_polygon 16 16 17 from Numeric import alltrue, allclose18 19 17 class meshTestCase(unittest.TestCase): 20 18 def setUp(self): … … 65 63 self.failUnless(mesh.userSegments[0] == s3, 66 64 'Bad segment. ') 67 self.failUnless(len(mesh.userSegments) == 65 self.failUnless(len(mesh.userSegments) ==1, 68 66 'Segments not deleted.') 69 67 self.failUnless(len(mesh.userVertices) == 2, … … 81 79 s3 = Segment(a,f) 82 80 83 r1 = Region(0.3, 0.3, tag = 1.3,maxArea = .6)81 r1 = Region(0.3, 0.3,tag = 1.3,maxArea = .6) 84 82 #print r1 85 83 m = Mesh(userVertices=[a,d,f], userSegments=[s1,s2,s3], regions=[r1] ) … … 1578 1576 1579 1577 1580 #print '** @@@@@******'1578 #print '**.flat@******' 1581 1579 #print "new_m",new_m 1582 #print '** @@@@@******'1580 #print '**.flat@******' 1583 1581 #print "m",m 1584 #print '** @@@@@******'1582 #print '**.flat@******' 1585 1583 1586 1584 self.failUnless( new_m == m, … … 1658 1656 'test_Mesh2IOTriangulationDict failed. test 2') 1659 1657 1660 self.failUnless( alltrue(dict['vertices'].flat == verts.flat),1658 self.failUnless( dict['vertices'] == verts, 1661 1659 'test_Mesh2IOTriangulationDict failed. test vert') 1662 self.failUnless( alltrue(dict['vertex_attributes'].flat == vert_as.flat),1660 self.failUnless( dict['vertex_attributes'] == vert_as, 1663 1661 'test_Mesh2IOTriangulationDict failed. test vert ats') 1664 1662 1665 self.failUnless( alltrue(dict['segments'][0] == [0,1]),1663 self.failUnless( dict['segments'][0] == [0,1], 1666 1664 'test_Mesh2IODict failed. test 3') 1667 1665 … … 1669 1667 'test_Mesh2IODict failed. test 3') 1670 1668 #print " dict['triangles'][0]", dict['triangles'][0] 1671 self.failUnless( alltrue(dict['triangles'][0] == [3,2,4]),1669 self.failUnless( dict['triangles'][0] == [3,2,4], 1672 1670 'test_Mesh2IODict failed. test 5') 1673 self.failUnless( alltrue(dict['triangle_neighbors'][0] == [-1,2,3]),1671 self.failUnless( dict['triangle_neighbors'][0] == [-1,2,3], 1674 1672 'test_Mesh2IODict failed. test 6') 1675 1673 #print "dict['triangle_tags'][0]", dict['triangle_tags'][0] … … 2180 2178 'FAILED!') 2181 2179 vert= m.get_user_vertices(absolute=True) 2182 2183 self.failUnless(allclose(vert, points_ab), 2184 'FAILED!') 2180 self.failUnless(vert==points_ab, 2181 'FAILED!') 2185 2182 2186 2183 … … 2196 2193 self.failUnless(4==len(vert), 2197 2194 'FAILED!') 2198 vert = m.get_user_vertices(absolute=True) 2199 2200 self.failUnless(alltrue(vert.flat == array(points).flat), 2195 vert= m.get_user_vertices(absolute=True) 2196 self.failUnless(vert==points, 2201 2197 'FAILED!') 2202 2198 … … 2215 2211 'FAILED!') 2216 2212 vert= m.get_user_vertices(absolute=True) 2217 2218 self.failUnless(allclose(vert, points_ab), 2213 self.failUnless(vert==points_ab, 2219 2214 'FAILED!') 2220 2215 … … 2232 2227 'FAILED!') 2233 2228 vert= m.get_user_vertices(absolute=True) 2234 2235 self.failUnless(allclose(vert, points_ab), 2229 self.failUnless(vert==points_ab, 2236 2230 'FAILED!') 2237 2231 … … 2254 2248 'FAILED!') 2255 2249 vert= m.get_user_vertices(absolute=True) 2256 self.failUnless( allclose(vert, points_ab),2250 self.failUnless(vert==points_ab, 2257 2251 'FAILED!') 2258 2252 vert= m.get_user_vertices(absolute=False) 2259 2253 points_new = m.geo_reference.get_absolute(vert) 2260 2254 2261 self.failUnless( allclose(points_ab, points_new),2255 self.failUnless(points_ab==points_new, 2262 2256 'FAILED!') 2263 2257 -
anuga_core/source_numpy_conversion/anuga/pmesh/view_tsh.py
r3564 r5912 11 11 from anuga.pyvolution.util import file_function 12 12 from anuga.utilities.polygon import Polygon_function, read_polygon 13 from Numeric import zeros, Float, maximum, minimum14 13 from realtime_visualisation_new import * 15 14
Note: See TracChangeset
for help on using the changeset viewer.