Changeset 5912


Ignore:
Timestamp:
Nov 6, 2008, 4:39:06 PM (16 years ago)
Author:
rwilson
Message:

NumPy? conversion.

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  
    27762776    def index(self, index, forInsert = 0):
    27772777        listLength = len(self._buttonList)
    2778         if type(index) == types.IntType:
     2778        if isinstance(index, types.IntType):
    27792779            if forInsert and index <= listLength:
    27802780                return index
     
    37083708            return
    37093709
    3710         if type(traverseSpec) == types.IntType:
     3710        if isinstance(traverseSpec, types.IntType):
    37113711            kw['underline'] = traverseSpec
    37123712            return
     
    39513951            return
    39523952
    3953         if type(traverseSpec) == types.IntType:
     3953        if isinstance(traverseSpec, types.IntType):
    39543954            kw['underline'] = traverseSpec
    39553955            return
     
    45074507    def index(self, index, forInsert = 0):
    45084508        listLength = len(self._pageNames)
    4509         if type(index) == types.IntType:
     4509        if isinstance(index, types.IntType):
    45104510            if forInsert and index <= listLength:
    45114511                return index
     
    49734973    def index(self, index):
    49744974        listLength = len(self._itemList)
    4975         if type(index) == types.IntType:
     4975        if isinstance(index, types.IntType):
    49764976            if index < listLength:
    49774977                return index
     
    52245224        # Parse <args> for options.
    52255225        for arg, value in args.items():
    5226             if type(value) == types.FloatType:
     5226            if isinstance(value, types.FloatType):
    52275227                relvalue = value
    52285228                value = self._absSize(relvalue)
     
    58135813
    58145814        listLength = len(self._buttonList)
    5815         if type(index) == types.IntType:
     5815        if isinstance(index, types.IntType):
    58165816            if index < listLength:
    58175817                return index
  • anuga_core/source_numpy_conversion/anuga/pmesh/mesh.py

    r5673 r5912  
    2222import types
    2323import exceptions
    24 from Numeric import array, Float, Int
    25 
    2624
    2725from anuga.coordinate_transforms.geo_reference import Geo_reference, \
     
    125123        __slots__ = ['x','y','attributes']
    126124       
    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))
    129127        self.x=X
    130128        self.y=Y       
  • anuga_core/source_numpy_conversion/anuga/pmesh/mesh_interface.py

    r5717 r5912  
    33from anuga.utilities.polygon import  point_in_polygon ,populate_polygon
    44from anuga.utilities.numerical_tools import ensure_numeric
    5 from Numeric import Float
     5import numpy
    66from anuga.utilities.polygon import inside_polygon
    77
     
    150150
    151151    # Simple check
    152     bounding_polygon = ensure_numeric(bounding_polygon, Float)
     152    bounding_polygon = ensure_numeric(bounding_polygon, numpy.float)
    153153    msg = 'Bounding polygon must be a list of points or an Nx2 array'
    154154    assert len(bounding_polygon.shape) == 2, msg
  • anuga_core/source_numpy_conversion/anuga/pmesh/test_mesh.py

    r5875 r5912  
    1515from anuga.utilities.polygon import  is_inside_polygon ### inside_polygon
    1616
    17 from Numeric import alltrue, allclose
    18 
    1917class meshTestCase(unittest.TestCase):
    2018    def setUp(self):
     
    6563        self.failUnless(mesh.userSegments[0] == s3,
    6664                        'Bad segment. ')       
    67         self.failUnless(len(mesh.userSegments) == 1,
     65        self.failUnless(len(mesh.userSegments) ==1,
    6866                        'Segments not deleted.')
    6967        self.failUnless(len(mesh.userVertices) == 2,
     
    8179        s3 = Segment(a,f)
    8280
    83         r1 = Region(0.3, 0.3, tag = 1.3, maxArea = .6)
     81        r1 = Region(0.3, 0.3,tag = 1.3,maxArea = .6)
    8482        #print r1
    8583        m = Mesh(userVertices=[a,d,f], userSegments=[s1,s2,s3], regions=[r1] )
     
    15781576       
    15791577
    1580         #print '**@@@@@******'
     1578        #print '**.flat@******'
    15811579        #print "new_m",new_m
    1582         #print '**@@@@@******'
     1580        #print '**.flat@******'
    15831581        #print "m",m
    1584         #print '**@@@@@******'
     1582        #print '**.flat@******'
    15851583       
    15861584        self.failUnless( new_m == m,
     
    16581656                         'test_Mesh2IOTriangulationDict failed. test 2')
    16591657
    1660         self.failUnless( alltrue(dict['vertices'].flat == verts.flat),
     1658        self.failUnless( dict['vertices'] == verts,
    16611659                         'test_Mesh2IOTriangulationDict failed. test vert')
    1662         self.failUnless( alltrue(dict['vertex_attributes'].flat == vert_as.flat),
     1660        self.failUnless( dict['vertex_attributes'] == vert_as,
    16631661                         'test_Mesh2IOTriangulationDict failed. test vert ats')
    16641662
    1665         self.failUnless( alltrue(dict['segments'][0] == [0,1]),
     1663        self.failUnless( dict['segments'][0] == [0,1],
    16661664                        'test_Mesh2IODict failed. test 3')
    16671665       
     
    16691667                        'test_Mesh2IODict failed. test 3')
    16701668        #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],
    16721670                        '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],
    16741672                        'test_Mesh2IODict failed. test 6')
    16751673        #print "dict['triangle_tags'][0]", dict['triangle_tags'][0]
     
    21802178                        'FAILED!')
    21812179        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!')
    21852182
    21862183   
     
    21962193        self.failUnless(4==len(vert),
    21972194                        '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,
    22012197                        'FAILED!')
    22022198   
     
    22152211                        'FAILED!')
    22162212        vert= m.get_user_vertices(absolute=True)
    2217        
    2218         self.failUnless(allclose(vert, points_ab),
     2213        self.failUnless(vert==points_ab,
    22192214                        'FAILED!')
    22202215
     
    22322227                        'FAILED!')
    22332228        vert= m.get_user_vertices(absolute=True)
    2234        
    2235         self.failUnless(allclose(vert, points_ab),
     2229        self.failUnless(vert==points_ab,
    22362230                        'FAILED!')
    22372231
     
    22542248                        'FAILED!')
    22552249        vert= m.get_user_vertices(absolute=True)
    2256         self.failUnless(allclose(vert, points_ab),
     2250        self.failUnless(vert==points_ab,
    22572251                        'FAILED!')
    22582252        vert= m.get_user_vertices(absolute=False)
    22592253        points_new = m.geo_reference.get_absolute(vert)
    22602254       
    2261         self.failUnless(allclose(points_ab, points_new),
     2255        self.failUnless(points_ab==points_new,
    22622256                        'FAILED!')
    22632257
  • anuga_core/source_numpy_conversion/anuga/pmesh/view_tsh.py

    r3564 r5912  
    1111from anuga.pyvolution.util import file_function
    1212from anuga.utilities.polygon import Polygon_function, read_polygon
    13 from Numeric import zeros, Float, maximum, minimum
    1413from realtime_visualisation_new import *
    1514
Note: See TracChangeset for help on using the changeset viewer.