Changeset 5892


Ignore:
Timestamp:
Nov 5, 2008, 4:29:38 PM (16 years ago)
Author:
rwilson
Message:

Made numpy changes, lots of problems.

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/domain.py

    r5847 r5892  
    88"""
    99
    10 from Numeric import allclose, argmax, zeros, Float
     10##from numpy.oldnumeric import allclose, argmax, zeros, Float
     11import numpy
     12
    1113from anuga.config import epsilon
    1214from anuga.config import beta_euler, beta_rk2
     
    105107
    106108        if verbose: print 'Initialising Domain'
    107         from Numeric import zeros, Float, Int, ones
    108109        from quantity import Quantity
    109110
     
    155156        for key in self.full_send_dict:
    156157            buffer_shape = self.full_send_dict[key][0].shape[0]
    157             self.full_send_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     158            self.full_send_dict[key].append(numpy.zeros( (buffer_shape,self.nsys), numpy.float))
    158159
    159160
    160161        for key in self.ghost_recv_dict:
    161162            buffer_shape = self.ghost_recv_dict[key][0].shape[0]
    162             self.ghost_recv_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     163            self.ghost_recv_dict[key].append(numpy.zeros( (buffer_shape,self.nsys), numpy.float))
    163164
    164165
     
    168169        N = len(self) #number_of_elements
    169170        self.number_of_elements = N
    170         self.tri_full_flag = ones(N, Int)
     171        self.tri_full_flag = numpy.ones(N, numpy.int)
    171172        for i in self.ghost_recv_dict.keys():
    172173            for id in self.ghost_recv_dict[i][0]:
     
    175176        # Test the assumption that all full triangles are store before
    176177        # the ghost triangles.
    177         if not allclose(self.tri_full_flag[:self.number_of_full_nodes],1):
     178        if not numpy.allclose(self.tri_full_flag[:self.number_of_full_nodes],1):
    178179            print 'WARNING:  Not all full triangles are store before ghost triangles'
    179180                       
     
    230231        # calculation
    231232        N = len(self) # Number_of_triangles
    232         self.already_computed_flux = zeros((N, 3), Int)
     233        self.already_computed_flux = numpy.zeros((N, 3), numpy.int)
    233234
    234235        # Storage for maximal speeds computed for each triangle by
    235236        # compute_fluxes
    236237        # This is used for diagnostics only (reset at every yieldstep)
    237         self.max_speed = zeros(N, Float)
     238        self.max_speed = numpy.zeros(N, numpy.float)
    238239
    239240        if mesh_filename is not None:
     
    266267        """
    267268
    268         from Numeric import zeros, Float
    269 
    270269        if not (vertex is None or edge is None):
    271270            msg = 'Values for both vertex and edge was specified.'
     
    273272            raise msg
    274273
    275         q = zeros( len(self.conserved_quantities), Float)
     274        q = numpy.zeros( len(self.conserved_quantities), numpy.float)
    276275
    277276        for i, name in enumerate(self.conserved_quantities):
     
    769768            # Find index of largest computed flux speed
    770769            if triangle_id is None:
    771                 k = self.k = argmax(self.max_speed)
     770                k = self.k = numpy.argmax(self.max_speed)
    772771            else:
    773772                errmsg = 'Triangle_id %d does not exist in mesh: %s' %(triangle_id,
     
    10861085
    10871086        """
     1087        print '.evolve: 0'
    10881088
    10891089        from anuga.config import min_timestep, max_timestep, epsilon
     
    10961096               %self.get_boundary_tags()
    10971097        assert hasattr(self, 'boundary_objects'), msg
     1098        print '.evolve: 1'
    10981099
    10991100
     
    11041105
    11051106        self._order_ = self.default_order
     1107        print '.evolve: 2'
    11061108
    11071109
     
    11271129        self.number_of_first_order_steps = 0
    11281130
    1129 
     1131        print '.evolve: 3'
    11301132        # Update ghosts
    11311133        self.update_ghosts()
    11321134
     1135        print '.evolve: 4'
    11331136        # Initial update of vertex and edge values
    11341137        self.distribute_to_vertices_and_edges()
    11351138
     1139        print '.evolve: 5'
    11361140        # Update extrema if necessary (for reporting)
    11371141        self.update_extrema()
    11381142       
     1143        print '.evolve: 6'
    11391144        # Initial update boundary values
    11401145        self.update_boundary()
    11411146
     1147        print '.evolve: 7'
    11421148        # Or maybe restore from latest checkpoint
    11431149        if self.checkpoint is True:
    11441150            self.goto_latest_checkpoint()
     1151        print '.evolve: 8'
    11451152
    11461153        if skip_initial_step is False:
     
    12021209                self.number_of_steps = 0
    12031210                self.number_of_first_order_steps = 0
    1204                 self.max_speed = zeros(N, Float)
     1211                self.max_speed = numpy.zeros(N, numpy.float)
    12051212
    12061213    def evolve_one_euler_step(self, yieldstep, finaltime):
     
    15681575        """
    15691576
    1570         from Numeric import ones, sum, equal, Float
    1571 
    15721577        N = len(self) # Number_of_triangles
    15731578        d = len(self.conserved_quantities)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/ermapper_grids.py

    r2054 r5892  
    22
    33# from os import open, write, read
    4 import Numeric
    5 
    6 celltype_map = {'IEEE4ByteReal': Numeric.Float32, 'IEEE8ByteReal': Numeric.Float64}
     4##import numpy.oldnumeric as Numeric
     5import numpy
     6
     7celltype_map = {'IEEE4ByteReal': numpy.float32, 'IEEE8ByteReal': numpy.float64}
    78
    89
     
    1112    write_ermapper_grid(ofile, data, header = {}):
    1213   
    13     Function to write a 2D Numeric array to an ERMapper grid.  There are a series of conventions adopted within
     14    Function to write a 2D NumPy array to an ERMapper grid.  There are a series of conventions adopted within
    1415    this code, specifically:
    1516    1)  The registration coordinate for the data is the SW (or lower-left) corner of the data
    1617    2)  The registration coordinates refer to cell centres
    17     3)  The data is a 2D Numeric array with the NW-most data in element (0,0) and the SE-most data in element (N,M)
     18    3)  The data is a 2D NumPy array with the NW-most data in element (0,0) and the SE-most data in element (N,M)
    1819        where N is the last line and M is the last column
    1920    4)  There has been no testng of the use of a rotated grid.  Best to keep data in an NS orientation
     
    2223    ofile:      string - filename for output (note the output will consist of two files
    2324                ofile and ofile.ers.  Either of these can be entered into this function
    24     data:       Numeric.array - 2D array containing the data to be output to the grid
     25    data:       NumPy.array - 2D array containing the data to be output to the grid
    2526    header:     dictionary - contains spatial information about the grid, in particular:
    2627                    header['datum'] datum for the data ('"GDA94"')
     
    5758
    5859    # Check that the data is a 2 dimensional array
    59     data_size = Numeric.shape(data)
     60    data_size = numpy.shape(data)
    6061    assert len(data_size) == 2
    6162   
     
    8384    nrofcellsperlines = int(header['nrofcellsperline'])
    8485    data = read_ermapper_data(data_file)
    85     data = Numeric.reshape(data,(nroflines,nrofcellsperlines))
     86    data = numpy.reshape(data,(nroflines,nrofcellsperlines))
    8687    return data
    8788   
     
    163164    return header                     
    164165
    165 def write_ermapper_data(grid, ofile, data_format = Numeric.Float32):
     166def write_ermapper_data(grid, ofile, data_format = numpy.float32):
    166167
    167168
     
    181182       
    182183   
    183     # Convert the array to data_format (default format is Float32)
     184    # Convert the array to data_format (default format is float32)
    184185    grid_as_float = grid.astype(data_format)
    185186
     
    193194
    194195
    195 def read_ermapper_data(ifile, data_format = Numeric.Float32):
     196def read_ermapper_data(ifile, data_format = numpy.float32):
    196197    # open input file in a binary format and read the input string
    197198    fid = open(ifile,'rb')
     
    199200    fid.close()
    200201
    201     # convert input string to required format (Note default format is Numeric.Float32)
    202     grid_as_float = Numeric.fromstring(input_string,data_format)
     202    # convert input string to required format (Note default format is numpy.float32)
     203    grid_as_float = numpy.fromstring(input_string,data_format)
    203204    return grid_as_float
    204205
  • anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py

    r5842 r5892  
    1 
    2 from Numeric import concatenate, reshape, take, allclose
    3 from Numeric import array, zeros, Int, Float, sqrt, sum, arange
     1import numpy
    42
    53from anuga.coordinate_transforms.geo_reference import Geo_reference
     
    9088        if verbose: print 'General_mesh: Building basic mesh structure in ANUGA domain'
    9189
    92         self.triangles = array(triangles, Int)
    93         self.nodes = array(nodes, Float)
     90##        self.triangles = array(triangles, Int)
     91##        self.nodes = array(nodes, Float)
     92        self.triangles = numpy.array(triangles, numpy.int)
     93        self.nodes = numpy.array(nodes, numpy.float)
    9494
    9595
     
    138138
    139139        msg = 'Vertex indices reference non-existing coordinate sets'
    140         assert max(self.triangles.flat) < self.nodes.shape[0], msg
     140        assert max(self.triangles.ravel()) < self.nodes.shape[0], msg
    141141
    142142
     
    146146                      max(self.nodes[:,0]), max(self.nodes[:,1]) ]
    147147
    148         self.xy_extent = array(xy_extent, Float)
     148##        self.xy_extent = array(xy_extent, Float)
     149        self.xy_extent = numpy.array(xy_extent, numpy.float)
    149150
    150151
    151152        # Allocate space for geometric quantities
    152         self.normals = zeros((N, 6), Float)
    153         self.areas = zeros(N, Float)
    154         self.edgelengths = zeros((N, 3), Float)
     153##        self.normals = zeros((N, 6), Float)
     154##        self.areas = zeros(N, Float)
     155##        self.edgelengths = zeros((N, 3), Float)
     156        self.normals = numpy.zeros((N, 6), numpy.float)
     157        self.areas = numpy.zeros(N, numpy.float)
     158        self.edgelengths = numpy.zeros((N, 3), numpy.float)
    155159
    156160        # Get x,y coordinates for all triangles and store
     
    187191            #   - Stored as six floats n0x,n0y,n1x,n1y,n2x,n2y per triangle
    188192
    189             n0 = array([x2 - x1, y2 - y1])
    190             l0 = sqrt(sum(n0**2))
    191 
    192             n1 = array([x0 - x2, y0 - y2])
    193             l1 = sqrt(sum(n1**2))
    194 
    195             n2 = array([x1 - x0, y1 - y0])
    196             l2 = sqrt(sum(n2**2))
     193            n0 = numpy.array([x2 - x1, y2 - y1])
     194            l0 = numpy.sqrt(numpy.sum(n0**2))
     195
     196            n1 = numpy.array([x0 - x2, y0 - y2])
     197            l1 = numpy.sqrt(numpy.sum(n1**2))
     198
     199            n2 = numpy.array([x1 - x0, y1 - y0])
     200            l2 = numpy.sqrt(numpy.sum(n2**2))
    197201
    198202            # Normalise
     
    274278        if absolute is True:
    275279            if not self.geo_reference.is_absolute():
    276                 return V + array([self.geo_reference.get_xllcorner(),
    277                                   self.geo_reference.get_yllcorner()])
     280                return V + numpy.array([self.geo_reference.get_xllcorner(),
     281                                        self.geo_reference.get_yllcorner()])
    278282            else:
    279283                return V
     
    311315            i = triangle_id
    312316            msg = 'triangle_id must be an integer'
     317            print 'type(triangle_id)=%s. triangle_id=%s' % (type(triangle_id), str(triangle_id))
    313318            assert int(i) == i, msg
    314319            assert 0 <= i < self.number_of_triangles
     
    316321            i3 = 3*i 
    317322            if absolute is True and not self.geo_reference.is_absolute():
    318                 offset=array([self.geo_reference.get_xllcorner(),
    319                                   self.geo_reference.get_yllcorner()])
    320                 return array([V[i3,:]+offset,
    321                               V[i3+1,:]+offset,
    322                               V[i3+2,:]+offset])
     323                offset = numpy.array([self.geo_reference.get_xllcorner(),
     324                                      self.geo_reference.get_yllcorner()])
     325                return numpy.array([V[i3,:]+offset,
     326                                    V[i3+1,:]+offset,
     327                                    V[i3+2,:]+offset])
    323328            else:
    324                 return array([V[i3,:], V[i3+1,:], V[i3+2,:]])
     329                return numpy.array([V[i3,:], V[i3+1,:], V[i3+2,:]])
    325330               
    326331
     
    349354
    350355        M = self.number_of_triangles
    351         vertex_coordinates = zeros((3*M, 2), Float)
     356##        vertex_coordinates = zeros((3*M, 2), Float)
     357        vertex_coordinates = numpy.zeros((3*M, 2), numpy.float)
    352358
    353359        for i in range(M):
     
    376382            indices = range(M)
    377383
    378         return take(self.triangles, indices)
     384        return numpy.take(self.triangles, indices, axis=0)
    379385   
    380386
     
    409415       
    410416        #T = reshape(array(range(K)).astype(Int), (M,3))
    411         T = reshape(arange(K).astype(Int), (M,3))  # Faster
     417##        T = reshape(arange(K).astype(Int), (M,3))  # Faster
     418        T = numpy.reshape(numpy.arange(K).astype(numpy.int), (M,3))  # Faster
    412419       
    413420        return T     
     
    439446        if node is not None:
    440447            # Get index for this node
    441             first = sum(self.number_of_triangles_per_node[:node])
     448            first = numpy.sum(self.number_of_triangles_per_node[:node])
    442449           
    443450            # Get number of triangles for this node
    444             count = self.number_of_triangles_per_node[node]
     451            count = int(self.number_of_triangles_per_node[node])
    445452
    446453            for i in range(count):
     
    452459                triangle_list.append( (volume_id, vertex_id) )
    453460
    454             triangle_list = array(triangle_list)   
     461            triangle_list = numpy.array(triangle_list)   
    455462        else:
    456463            # Get info for all nodes recursively.
     
    529536
    530537        # Count number of triangles per node
    531         number_of_triangles_per_node = zeros(self.number_of_full_nodes)
     538        number_of_triangles_per_node = numpy.zeros(self.number_of_full_nodes)
    532539        for volume_id, triangle in enumerate(self.get_triangles()):
    533540            for vertex_id in triangle:
     
    535542
    536543        # Allocate space for inverted structure
    537         number_of_entries = sum(number_of_triangles_per_node)
    538         vertex_value_indices = zeros(number_of_entries)
     544        number_of_entries = numpy.sum(number_of_triangles_per_node)
     545        vertex_value_indices = numpy.zeros(number_of_entries)
    539546
    540547        # Register (triangle, vertex) indices for each node
     
    582589        Y = C[:,1:6:2].copy()
    583590
    584         xmin = min(X.flat)
    585         xmax = max(X.flat)
    586         ymin = min(Y.flat)
    587         ymax = max(Y.flat)
     591        xmin = min(X.ravel())
     592        xmax = max(X.ravel())
     593        ymin = min(Y.ravel())
     594        ymax = max(Y.ravel())
    588595        #print "C",C
    589596        return xmin, xmax, ymin, ymax
     
    598605        """
    599606
    600         return sum(self.areas)
    601 
    602        
    603        
     607        return numpy.sum(self.areas)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r5672 r5892  
    77from anuga.fit_interpolate.interpolate import Modeltime_too_late
    88from anuga.fit_interpolate.interpolate import Modeltime_too_early
     9
     10import numpy
    911
    1012
     
    6769            raise Exception, msg
    6870
    69         from Numeric import array, Float
    70         self.conserved_quantities=array(conserved_quantities).astype(Float)
     71        self.conserved_quantities=numpy.array(conserved_quantities).astype(numpy.float)
    7172
    7273    def __repr__(self):
     
    9697            raise msg
    9798
    98 
    99         from Numeric import array, Float
    10099        try:
    101             q = array(q).astype(Float)
     100            q = numpy.array(q).astype(numpy.float)
    102101        except:
    103102            msg = 'Return value from time boundary function could '
     
    136135    def __init__(self, filename, domain):
    137136        import time
    138         from Numeric import array
    139137        from anuga.config import time_format
    140138        from anuga.abstract_2d_finite_volumes.util import File_function
     
    206204
    207205        import time
    208         from Numeric import array, zeros, Float
    209206        from anuga.config import time_format
    210207        from anuga.abstract_2d_finite_volumes.util import file_function
     
    222219
    223220        if verbose: print 'Find midpoint coordinates of entire boundary'
    224         self.midpoint_coordinates = zeros( (len(domain.boundary), 2), Float)
     221        self.midpoint_coordinates = numpy.zeros( (len(domain.boundary), 2), numpy.float)
    225222        boundary_keys = domain.boundary.keys()
    226223
     
    242239           
    243240            # Compute midpoints
    244             if edge_id == 0: m = array([(x1 + x2)/2, (y1 + y2)/2])
    245             if edge_id == 1: m = array([(x0 + x2)/2, (y0 + y2)/2])
    246             if edge_id == 2: m = array([(x1 + x0)/2, (y1 + y0)/2])
     241            if edge_id == 0: m = numpy.array([(x1 + x2)/2, (y1 + y2)/2])
     242            if edge_id == 1: m = numpy.array([(x0 + x2)/2, (y0 + y2)/2])
     243            if edge_id == 2: m = numpy.array([(x1 + x0)/2, (y1 + y0)/2])
    247244
    248245            # Convert to absolute UTM coordinates
  • anuga_core/source/anuga/abstract_2d_finite_volumes/mesh_factory.py

    r3678 r5892  
    22mesh file formats
    33"""
     4
     5import numpy
    46
    57
     
    7375
    7476    from anuga.config import epsilon
    75     from Numeric import zeros, Float, Int
    7677
    7778    delta1 = float(len1)/m
     
    9394    index = Index(n,m)
    9495
    95     points = zeros( (Np,2), Float)
     96    points = numpy.zeros( (Np,2), numpy.float)
    9697
    9798    for i in range(m+1):
     
    105106
    106107
    107     elements = zeros( (Nt,3), Int)
     108    elements = numpy.zeros( (Nt,3), numpy.int)
    108109    boundary = {}
    109110    nt = -1
     
    149150
    150151    from anuga.config import epsilon
    151     from Numeric import zeros, Float, Int
    152152
    153153    delta1 = float(len1)/m
     
    208208    """
    209209
    210     from Numeric import array
    211210    import math
    212211
     
    510509    """
    511510
    512     from Numeric import array
     511#    from numpy.oldnumeric import array
    513512    import math
    514513
     
    592591    """
    593592
    594     from Numeric import array
    595593    import math
    596594
     
    686684    """
    687685
    688     from Numeric import array
    689686    import math
    690 
    691687    from anuga.config import epsilon
    692 
    693688
    694689    deltax = lenx/float(m)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r5866 r5892  
    1111from anuga.caching import cache
    1212from math import pi, sqrt
    13 from Numeric import array, allclose
    14        
     13import numpy       
    1514
    1615class Mesh(General_mesh):
     
    7978        """
    8079
    81 
    82 
    83         from Numeric import array, zeros, Int, Float, maximum, sqrt, sum
    84 
    8580        General_mesh.__init__(self, coordinates, triangles,
    8681                              number_of_full_nodes=\
     
    9893
    9994        #Allocate space for geometric quantities
    100         self.centroid_coordinates = zeros((N, 2), Float)
    101 
    102         self.radii = zeros(N, Float)
    103 
    104         self.neighbours = zeros((N, 3), Int)
    105         self.neighbour_edges = zeros((N, 3), Int)
    106         self.number_of_boundaries = zeros(N, Int)
    107         self.surrogate_neighbours = zeros((N, 3), Int)
     95        self.centroid_coordinates = numpy.zeros((N, 2), numpy.float)
     96
     97        self.radii = numpy.zeros(N, numpy.float)
     98
     99        self.neighbours = numpy.zeros((N, 3), numpy.int)
     100        self.neighbour_edges = numpy.zeros((N, 3), numpy.int)
     101        self.number_of_boundaries = numpy.zeros(N, numpy.int)
     102        self.surrogate_neighbours = numpy.zeros((N, 3), numpy.int)
    108103
    109104        #Get x,y coordinates for all triangles and store
     
    124119
    125120            #Compute centroid
    126             centroid = array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3])
     121            centroid = numpy.array([(x0 + x1 + x2)/3, (y0 + y1 + y2)/3])
    127122            self.centroid_coordinates[i] = centroid
    128123
     
    133128
    134129                #Midpoints
    135                 m0 = array([(x1 + x2)/2, (y1 + y2)/2])
    136                 m1 = array([(x0 + x2)/2, (y0 + y2)/2])
    137                 m2 = array([(x1 + x0)/2, (y1 + y0)/2])
     130                m0 = numpy.array([(x1 + x2)/2, (y1 + y2)/2])
     131                m1 = numpy.array([(x0 + x2)/2, (y0 + y2)/2])
     132                m2 = numpy.array([(x1 + x0)/2, (y1 + y0)/2])
    138133
    139134                #The radius is the distance from the centroid of
    140135                #a triangle to the midpoint of the side of the triangle
    141136                #closest to the centroid
    142                 d0 = sqrt(sum( (centroid-m0)**2 ))
    143                 d1 = sqrt(sum( (centroid-m1)**2 ))
    144                 d2 = sqrt(sum( (centroid-m2)**2 ))
     137                d0 = numpy.sqrt(numpy.sum( (centroid-m0)**2 ))
     138                d1 = numpy.sqrt(numpy.sum( (centroid-m1)**2 ))
     139                d2 = numpy.sqrt(numpy.sum( (centroid-m2)**2 ))
    145140
    146141                self.radii[i] = min(d0, d1, d2)
     
    150145                #of inscribed circle is computed
    151146
    152                 a = sqrt((x0-x1)**2+(y0-y1)**2)
    153                 b = sqrt((x1-x2)**2+(y1-y2)**2)
    154                 c = sqrt((x2-x0)**2+(y2-y0)**2)
     147                a = numpy.sqrt((x0-x1)**2+(y0-y1)**2)
     148                b = numpy.sqrt((x1-x2)**2+(y1-y2)**2)
     149                c = numpy.sqrt((x2-x0)**2+(y2-y0)**2)
    155150
    156151                self.radii[i]=2.0*self.areas[i]/(a+b+c)
     
    388383            self.element_tag is defined
    389384        """
    390         from Numeric import array, Int
    391385
    392386        if tagged_elements is None:
     
    395389            #Check that all keys in given boundary exist
    396390            for tag in tagged_elements.keys():
    397                 tagged_elements[tag] = array(tagged_elements[tag]).astype(Int)
     391                tagged_elements[tag] = numpy.array(tagged_elements[tag]).astype(numpy.int)
    398392
    399393                msg = 'Not all elements exist. '
     
    463457        """
    464458       
    465         from Numeric import allclose, sqrt, array, minimum, maximum
    466459        from anuga.utilities.numerical_tools import angle, ensure_numeric     
    467460
     
    477470        inverse_segments = {}
    478471        p0 = None
    479         mindist = sqrt(sum((pmax-pmin)**2)) # Start value across entire mesh
     472        mindist = numpy.sqrt(numpy.sum((pmax-pmin)**2)) # Start value across entire mesh
    480473        for i, edge_id in self.boundary.keys():
    481474            # Find vertex ids for boundary segment
     
    487480            B = self.get_vertex_coordinate(i, b, absolute=True) # End
    488481
    489 
    490482            # Take the point closest to pmin as starting point
    491483            # Note: Could be arbitrary, but nice to have
    492484            # a unique way of selecting
    493             dist_A = sqrt(sum((A-pmin)**2))
    494             dist_B = sqrt(sum((B-pmin)**2))
     485            dist_A = numpy.sqrt(numpy.sum((A-pmin)**2))
     486            dist_B = numpy.sqrt(numpy.sum((B-pmin)**2))
    495487
    496488            # Find lower leftmost point
     
    593585                # We have reached a point already visited.
    594586               
    595                 if allclose(p1, polygon[0]):
     587                if numpy.allclose(p1, polygon[0]):
    596588                    # If it is the initial point, the polygon is complete.
    597589                   
     
    629621        from anuga.utilities.numerical_tools import anglediff
    630622
    631         from Numeric import sort, allclose
    632 
    633623        N = len(self)
    634624
     
    672662
    673663                # Normalise
    674                 l_u = sqrt(u[0]*u[0] + u[1]*u[1])
    675                 l_v = sqrt(v[0]*v[0] + v[1]*v[1])
     664                l_u = numpy.sqrt(u[0]*u[0] + u[1]*u[1])
     665                l_v = numpy.sqrt(v[0]*v[0] + v[1]*v[1])
    676666
    677667                msg = 'Normal vector in triangle %d does not have unit length' %i
    678                 assert allclose(l_v, 1), msg
     668                assert numpy.allclose(l_v, 1), msg
    679669
    680670                x = (u[0]*v[0] + u[1]*v[1])/l_u # Inner product
     
    730720
    731721        V = self.vertex_value_indices[:] #Take a copy
    732         V = sort(V)
    733         assert allclose(V, range(3*N))
     722        V = numpy.sort(V)
     723        assert numpy.allclose(V, range(3*N))
    734724
    735725        assert sum(self.number_of_triangles_per_node) ==\
     
    742732                count[i] += 1
    743733
    744         assert allclose(count, self.number_of_triangles_per_node)
     734        assert numpy.allclose(count, self.number_of_triangles_per_node)
    745735
    746736
     
    805795        """
    806796
    807         from Numeric import arange
    808797        from anuga.utilities.numerical_tools import histogram, create_bins
    809798
     
    11411130
    11421131            # Distances from line origin to the two intersections
    1143             z0 = array([x0 - xi0, y0 - eta0])
    1144             z1 = array([x1 - xi0, y1 - eta0])             
    1145             d0 = sqrt(sum(z0**2))
    1146             d1 = sqrt(sum(z1**2))
     1132            z0 = numpy.array([x0 - xi0, y0 - eta0])
     1133            z1 = numpy.array([x1 - xi0, y1 - eta0])             
     1134            d0 = numpy.sqrt(numpy.sum(z0**2))
     1135            d1 = numpy.sqrt(numpy.sum(z1**2))
    11471136               
    11481137            if d1 < d0:
     
    11571146            # Normal direction:
    11581147            # Right hand side relative to line direction
    1159             vector = array([x1 - x0, y1 - y0]) # Segment vector
    1160             length = sqrt(sum(vector**2))      # Segment length
    1161             normal = array([vector[1], -vector[0]])/length
     1148            vector = numpy.array([x1 - x0, y1 - y0]) # Segment vector
     1149            length = numpy.sqrt(numpy.sum(vector**2))      # Segment length
     1150            normal = numpy.array([vector[1], -vector[0]])/length
    11621151
    11631152
     
    12391228        assert isinstance(segment, Triangle_intersection), msg
    12401229       
    1241         midpoint = sum(array(segment.segment))/2
     1230        midpoint = numpy.sum(numpy.array(segment.segment))/2
    12421231        midpoints.append(midpoint)
    12431232
  • anuga_core/source/anuga/abstract_2d_finite_volumes/pmesh2domain.py

    r4902 r5892  
    99import sys
    1010
     11import numpy
    1112
    1213
     
    161162    """
    162163
    163     from Numeric import transpose
    164164    from load_mesh.loadASCII import import_mesh_file
    165165
     
    172172    volumes = mesh_dict['triangles']
    173173    vertex_quantity_dict = {}
    174     point_atts = transpose(mesh_dict['vertex_attributes'])
     174    point_atts = numpy.transpose(mesh_dict['vertex_attributes'])
    175175    point_titles  = mesh_dict['vertex_attribute_titles']
    176176    geo_reference  = mesh_dict['geo_reference']
    177177    if point_atts != None:
    178         for quantity, value_vector in map (None, point_titles, point_atts):
     178        print 'type(point_atts)=%s' % type(point_atts)
     179        for quantity, value_vector in map(None, point_titles, point_atts):
    179180            vertex_quantity_dict[quantity] = value_vector
    180181    tag_dict = pmesh_dict_to_tag_dict(mesh_dict)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r5866 r5892  
    1515"""
    1616
    17 from Numeric import array, zeros, Float, less, concatenate, NewAxis,\
    18      argmax, argmin, allclose, take, reshape, alltrue
     17import numpy
    1918
    2019from anuga.utilities.numerical_tools import ensure_numeric, is_scalar
     
    3837        if vertex_values is None:
    3938            N = len(domain) # number_of_elements
    40             self.vertex_values = zeros((N, 3), Float)
     39            self.vertex_values = numpy.zeros((N, 3), numpy.float)
    4140        else:
    42             self.vertex_values = array(vertex_values).astype(Float)
     41            self.vertex_values = numpy.array(vertex_values).astype(numpy.float)
    4342
    4443            N, V = self.vertex_values.shape
     
    5756
    5857        # Allocate space for other quantities
    59         self.centroid_values = zeros(N, Float)
    60         self.edge_values = zeros((N, 3), Float)
     58        self.centroid_values = numpy.zeros(N, numpy.float)
     59        self.edge_values = numpy.zeros((N, 3), numpy.float)
    6160
    6261        # Allocate space for Gradient
    63         self.x_gradient = zeros(N, Float)
    64         self.y_gradient = zeros(N, Float)
     62        self.x_gradient = numpy.zeros(N, numpy.float)
     63        self.y_gradient = numpy.zeros(N, numpy.float)
    6564
    6665        # Allocate space for Limiter Phi
    67         self.phi = zeros(N, Float)       
     66        self.phi = numpy.zeros(N, numpy.float)       
    6867
    6968        # Intialise centroid and edge_values
     
    7271        # Allocate space for boundary values
    7372        L = len(domain.boundary)
    74         self.boundary_values = zeros(L, Float)
     73        self.boundary_values = numpy.zeros(L, numpy.float)
    7574
    7675        # Allocate space for updates of conserved quantities by
     
    7877
    7978        # Allocate space for update fields
    80         self.explicit_update = zeros(N, Float )
    81         self.semi_implicit_update = zeros(N, Float )
    82         self.centroid_backup_values = zeros(N, Float)
     79        self.explicit_update = numpy.zeros(N, numpy.float )
     80        self.semi_implicit_update = numpy.zeros(N, numpy.float )
     81        self.centroid_backup_values = numpy.zeros(N, numpy.float)
    8382
    8483        self.set_beta(1.0)
     
    382381        from anuga.geospatial_data.geospatial_data import Geospatial_data
    383382        from types import FloatType, IntType, LongType, ListType, NoneType
    384         from Numeric import ArrayType
    385383
    386384        # Treat special case: Polygon situation
     
    448446
    449447        msg = 'Indices must be a list or None'
    450         assert type(indices) in [ListType, NoneType, ArrayType], msg
     448        assert type(indices) in [ListType, NoneType, numpy.ndarray], msg
    451449
    452450
     
    458456                self.set_values_from_constant(numeric,
    459457                                              location, indices, verbose)
    460             elif type(numeric) in [ArrayType, ListType]:
     458            elif type(numeric) in [numpy.ndarray, ListType]:
    461459                self.set_values_from_array(numeric,
    462460                                           location, indices, verbose)
     
    474472                                                     use_cache=use_cache)
    475473            else:
    476                 msg = 'Illegal type for argument numeric: %s' %str(numeric)
    477                 raise msg
     474                msg = 'Illegal type for argument numeric: %s' % str(numeric)
     475                raise TypeError, msg
    478476
    479477        elif quantity is not None:
     
    610608        """
    611609
    612         from Numeric import array, Float, Int, allclose
    613 
    614         values = array(values).astype(Float)
     610        values = numpy.array(values).astype(numpy.float)
    615611
    616612        if indices is not None:
    617             indices = array(indices).astype(Int)
     613            indices = numpy.array(indices).astype(numpy.int)
    618614            msg = 'Number of values must match number of indices:'
    619615            msg += ' You specified %d values and %d indices'\
     
    640636
    641637        elif location == 'unique vertices':
    642             assert len(values.shape) == 1 or allclose(values.shape[1:], 1),\
     638            assert len(values.shape) == 1 or numpy.allclose(values.shape[1:], 1),\
    643639                   'Values array must be 1d'
    644640
    645             self.set_vertex_values(values.flat, indices=indices)
     641            self.set_vertex_values(values.ravel(), indices=indices)
    646642           
    647643        else:
     
    676672        A = q.vertex_values
    677673
    678         from Numeric import allclose
    679674        msg = 'Quantities are defined on different meshes. '+\
    680675              'This might be a case for implementing interpolation '+\
    681676              'between different meshes.'
    682         assert allclose(A.shape, self.vertex_values.shape), msg
     677        assert numpy.allclose(A.shape, self.vertex_values.shape), msg
    683678
    684679        self.set_values(A, location='vertices',
     
    716711                indices = range(len(self))
    717712               
    718             V = take(self.domain.get_centroid_coordinates(), indices)
     713            V = numpy.take(self.domain.get_centroid_coordinates(), indices, axis=0)
     714            print 'V=%s' % str(V)
    719715            self.set_values(f(V[:,0], V[:,1]),
    720716                            location=location,
     
    780776
    781777
    782         points = ensure_numeric(points, Float)
    783         values = ensure_numeric(values, Float)
     778        points = ensure_numeric(points, numpy.float)
     779        values = ensure_numeric(values, numpy.float)
    784780
    785781        if location != 'vertices':
     
    913909        # Always return absolute indices
    914910        if mode is None or mode == 'max':
    915             i = argmax(V)
     911            i = numpy.argmax(V)
    916912        elif mode == 'min':   
    917             i = argmin(V)
     913            i = numpy.argmin(V)
    918914
    919915           
     
    11181114        """
    11191115       
    1120         from Numeric import take
    1121 
    11221116        # FIXME (Ole): I reckon we should have the option of passing a
    11231117        #              polygon into get_values. The question becomes how
     
    11431137            raise msg
    11441138
    1145         import types, Numeric
    1146         assert type(indices) in [types.ListType, types.NoneType,
    1147                                  Numeric.ArrayType],\
     1139        import types
     1140       
     1141        assert type(indices) in [types.ListType, types.NoneType, numpy.ndarray], \
    11481142                                 'Indices must be a list or None'
    11491143
     
    11511145            if (indices ==  None):
    11521146                indices = range(len(self))
    1153             return take(self.centroid_values,indices)
     1147            return numpy.take(self.centroid_values, indices, axis=0)
    11541148        elif location == 'edges':
    11551149            if (indices ==  None):
    11561150                indices = range(len(self))
    1157             return take(self.edge_values,indices)
     1151            return numpy.take(self.edge_values, indices, axis=0)
    11581152        elif location == 'unique vertices':
    11591153            if (indices ==  None):
     
    11781172                    sum += self.vertex_values[triangle_id, vertex_id]
    11791173                vert_values.append(sum/len(triangles))
    1180             return Numeric.array(vert_values)
     1174            return numpy.array(vert_values)
    11811175        else:
    11821176            if (indices is None):
    11831177                indices = range(len(self))
    1184             return take(self.vertex_values, indices)
     1178            return numpy.take(self.vertex_values, indices, axis=0)
    11851179
    11861180
     
    11961190        """
    11971191
    1198         from Numeric import array, Float
    1199 
    12001192        # Assert that A can be converted to a Numeric array of appropriate dim
    1201         A = ensure_numeric(A, Float)
     1193        A = ensure_numeric(A, numpy.float)
    12021194
    12031195        # print 'SHAPE A', A.shape
     
    12731265        """
    12741266
    1275         from Numeric import concatenate, zeros, Float, Int, array, reshape
    1276 
    1277 
    12781267        if smooth is None:
    12791268            # Take default from domain
     
    12841273
    12851274        if precision is None:
    1286             precision = Float
     1275            precision = numpy.float
    12871276           
    12881277
     
    12931282            V = self.domain.get_triangles()
    12941283            N = self.domain.number_of_full_nodes # Ignore ghost nodes if any
    1295             A = zeros(N, Float)
     1284            A = numpy.zeros(N, numpy.float)
    12961285            points = self.domain.get_nodes()           
    12971286           
     
    13431332            V = self.domain.get_disconnected_triangles()
    13441333            points = self.domain.get_vertex_coordinates()
    1345             A = self.vertex_values.flat.astype(precision)
     1334            A = self.vertex_values.ravel().astype(precision)
    13461335
    13471336
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity_ext.c

    r5306 r5892  
    1111
    1212#include "Python.h"
    13 #include "Numeric/arrayobject.h"
     13#include "numpy/arrayobject.h"
    1414#include "math.h"
    1515
  • anuga_core/source/anuga/abstract_2d_finite_volumes/region.py

    r5208 r5892  
    88# FIXME (DSG-DSG) add better comments
    99
    10 from Numeric import average
     10import numpy
     11
     12
    1113class Region:
    1214    """Base class for modifying quantities based on a region.
     
    101103                values = Q.get_values(indices=self.build_indices(elements, domain),
    102104                                      location=self.location)
    103                 av = average(values)
     105                av = numpy.average(values)
    104106                if self.location == "vertices":
    105                     av = average(av)
     107                    av = numpy.average(av)
    106108                new_values = av + self.X   
    107109            else:
  • anuga_core/source/anuga/abstract_2d_finite_volumes/show_balanced_limiters.py

    r4204 r5892  
    1818
    1919from mesh_factory import rectangular
    20 from Numeric import array
    21    
     20
    2221
    2322######################
     
    7877domain.set_quantity('stage', Z)
    7978
    80 from Numeric import allclose
    81 
    8279#Evolve
    8380for t in domain.evolve(yieldstep = 0.1, finaltime = 30):
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_domain.py

    r4932 r5892  
    66from domain import *
    77from anuga.config import epsilon
    8 from Numeric import allclose, array, ones, Float
     8import numpy
    99
    1010
     
    6464
    6565
    66         assert domain.get_conserved_quantities(0, edge=1) == 0.
     66        assert numpy.alltrue(domain.get_conserved_quantities(0, edge=1) == 0.)
    6767
    6868
     
    9595        #Centroids
    9696        q = domain.get_conserved_quantities(0)
    97         assert allclose(q, [2., 2., 0.])
     97        assert numpy.allclose(q, [2., 2., 0.])
    9898
    9999        q = domain.get_conserved_quantities(1)
    100         assert allclose(q, [5., 5., 0.])
     100        assert numpy.allclose(q, [5., 5., 0.])
    101101
    102102        q = domain.get_conserved_quantities(2)
    103         assert allclose(q, [3., 3., 0.])
     103        assert numpy.allclose(q, [3., 3., 0.])
    104104
    105105        q = domain.get_conserved_quantities(3)
    106         assert allclose(q, [0., 0., 0.])
     106        assert numpy.allclose(q, [0., 0., 0.])
    107107
    108108
    109109        #Edges
    110110        q = domain.get_conserved_quantities(0, edge=0)
    111         assert allclose(q, [2.5, 2.5, 0.])
     111        assert numpy.allclose(q, [2.5, 2.5, 0.])
    112112        q = domain.get_conserved_quantities(0, edge=1)
    113         assert allclose(q, [2., 2., 0.])
     113        assert numpy.allclose(q, [2., 2., 0.])
    114114        q = domain.get_conserved_quantities(0, edge=2)
    115         assert allclose(q, [1.5, 1.5, 0.])
     115        assert numpy.allclose(q, [1.5, 1.5, 0.])
    116116
    117117        for i in range(3):
    118118            q = domain.get_conserved_quantities(1, edge=i)
    119             assert allclose(q, [5, 5, 0.])
     119            assert numpy.allclose(q, [5, 5, 0.])
    120120
    121121
    122122        q = domain.get_conserved_quantities(2, edge=0)
    123         assert allclose(q, [4.5, 4.5, 0.])
     123        assert numpy.allclose(q, [4.5, 4.5, 0.])
    124124        q = domain.get_conserved_quantities(2, edge=1)
    125         assert allclose(q, [4.5, 4.5, 0.])
     125        assert numpy.allclose(q, [4.5, 4.5, 0.])
    126126        q = domain.get_conserved_quantities(2, edge=2)
    127         assert allclose(q, [0., 0., 0.])
     127        assert numpy.allclose(q, [0., 0., 0.])
    128128
    129129
    130130        q = domain.get_conserved_quantities(3, edge=0)
    131         assert allclose(q, [3., 3., 0.])
     131        assert numpy.allclose(q, [3., 3., 0.])
    132132        q = domain.get_conserved_quantities(3, edge=1)
    133         assert allclose(q, [-1.5, -1.5, 0.])
     133        assert numpy.allclose(q, [-1.5, -1.5, 0.])
    134134        q = domain.get_conserved_quantities(3, edge=2)
    135         assert allclose(q, [-1.5, -1.5, 0.])
     135        assert numpy.allclose(q, [-1.5, -1.5, 0.])
    136136
    137137
     
    179179        Q = domain.create_quantity_from_expression(expression)
    180180
    181         assert allclose(Q.vertex_values, [[2,3,4], [6,6,6],
    182                                       [1,1,10], [-5, 4, 4]])
     181        assert numpy.allclose(Q.vertex_values, [[2,3,4], [6,6,6],
     182                                                [1,1,10], [-5, 4, 4]])
    183183
    184184        expression = '(xmomentum*xmomentum + ymomentum*ymomentum)**0.5'
     
    188188        Y = domain.quantities['ymomentum'].vertex_values
    189189
    190         assert allclose(Q.vertex_values, (X**2 + Y**2)**0.5)
     190        assert numpy.allclose(Q.vertex_values, (X**2 + Y**2)**0.5)
    191191
    192192
     
    314314        Q = domain.quantities['depth']
    315315
    316         assert allclose(Q.vertex_values, [[2,3,4], [6,6,6],
    317                                       [1,1,10], [-5, 4, 4]])
     316        assert numpy.allclose(Q.vertex_values, [[2,3,4], [6,6,6],
     317                                                [1,1,10], [-5, 4, 4]])
    318318
    319319
     
    382382        domain.check_integrity()
    383383
    384         assert allclose(domain.neighbours, [[-1,-2,-3]])
     384        assert numpy.allclose(domain.neighbours, [[-1,-2,-3]])
    385385
    386386
     
    471471                                      [0,0,9], [-6, 3, 3]])
    472472
    473         assert allclose( domain.quantities['stage'].centroid_values,
    474                          [2,5,3,0] )
     473        assert numpy.allclose( domain.quantities['stage'].centroid_values,
     474                               [2,5,3,0] )
    475475
    476476        domain.set_quantity('xmomentum', [[1,1,1], [2,2,2],
     
    484484
    485485        #First order extrapolation
    486         assert allclose( domain.quantities['stage'].vertex_values,
    487                          [[ 2.,  2.,  2.],
    488                           [ 5.,  5.,  5.],
    489                           [ 3.,  3.,  3.],
    490                           [ 0.,  0.,  0.]])
     486        assert numpy.allclose( domain.quantities['stage'].vertex_values,
     487                               [[ 2.,  2.,  2.],
     488                                [ 5.,  5.,  5.],
     489                                [ 3.,  3.,  3.],
     490                                [ 0.,  0.,  0.]])
    491491
    492492
     
    527527
    528528        for name in domain.conserved_quantities:
    529             domain.quantities[name].explicit_update = array([4.,3.,2.,1.])
    530             domain.quantities[name].semi_implicit_update = array([1.,1.,1.,1.])
     529            domain.quantities[name].explicit_update = numpy.array([4.,3.,2.,1.])
     530            domain.quantities[name].semi_implicit_update = numpy.array([1.,1.,1.,1.])
    531531
    532532
     
    535535        domain.update_conserved_quantities()
    536536
    537         sem = array([1.,1.,1.,1.])/array([1, 2, 3, 4])
    538         denom = ones(4, Float)-domain.timestep*sem
     537        sem = numpy.array([1.,1.,1.,1.])/numpy.array([1, 2, 3, 4])
     538        denom = numpy.ones(4, numpy.float)-domain.timestep*sem
    539539
    540540#        x = array([1, 2, 3, 4]) + array( [.4,.3,.2,.1] )
    541541#        x /= denom
    542542
    543         x = array([1., 2., 3., 4.])
     543        x = numpy.array([1., 2., 3., 4.])
    544544        x /= denom
    545         x += domain.timestep*array( [4,3,2,1] )
     545        x += domain.timestep*numpy.array( [4,3,2,1] )
    546546
    547547        for name in domain.conserved_quantities:
    548             assert allclose(domain.quantities[name].centroid_values, x)
     548            assert numpy.allclose(domain.quantities[name].centroid_values, x)
    549549
    550550
     
    578578                                      [0,0,9], [-6, 3, 3]])
    579579
    580         assert allclose( domain.quantities['stage'].centroid_values,
    581                          [2,5,3,0] )
     580        assert numpy.allclose( domain.quantities['stage'].centroid_values,
     581                               [2,5,3,0] )
    582582
    583583        domain.set_quantity('xmomentum', [[1,1,1], [2,2,2],
     
    591591
    592592        #First order extrapolation
    593         assert allclose( domain.quantities['stage'].vertex_values,
    594                          [[ 2.,  2.,  2.],
    595                           [ 5.,  5.,  5.],
    596                           [ 3.,  3.,  3.],
    597                           [ 0.,  0.,  0.]])
     593        assert numpy.allclose( domain.quantities['stage'].vertex_values,
     594                               [[ 2.,  2.,  2.],
     595                                [ 5.,  5.,  5.],
     596                                [ 3.,  3.,  3.],
     597                                [ 0.,  0.,  0.]])
    598598
    599599        domain.build_tagged_elements_dictionary({'mound':[0,1]})
     
    610610        from mesh_factory import rectangular
    611611        from shallow_water import Domain
    612         from Numeric import zeros, Float
    613612
    614613        #Create basic mesh
     
    627626        from mesh_factory import rectangular
    628627        from shallow_water import Domain
    629         from Numeric import zeros, Float
    630628
    631629        #Create basic mesh
     
    645643        domain.set_region([set_bottom_friction, set_top_friction])
    646644        #print domain.quantities['friction'].get_values()
    647         assert allclose(domain.quantities['friction'].get_values(),\
    648                         [[ 0.09,  0.09,  0.09],
    649                          [ 0.09,  0.09,  0.09],
    650                          [ 0.07,  0.07,  0.07],
    651                          [ 0.07,  0.07,  0.07],
    652                          [ 1.0,  1.0,  1.0],
    653                          [ 1.0,  1.0,  1.0]])
     645        assert numpy.allclose(domain.quantities['friction'].get_values(),\
     646                              [[ 0.09,  0.09,  0.09],
     647                               [ 0.09,  0.09,  0.09],
     648                               [ 0.07,  0.07,  0.07],
     649                               [ 0.07,  0.07,  0.07],
     650                               [ 1.0,  1.0,  1.0],
     651                               [ 1.0,  1.0,  1.0]])
    654652
    655653        domain.set_region([set_all_friction])
    656654        #print domain.quantities['friction'].get_values()
    657         assert allclose(domain.quantities['friction'].get_values(),
    658                         [[ 10.09, 10.09, 10.09],
    659                          [ 10.09, 10.09, 10.09],
    660                          [ 10.07, 10.07, 10.07],
    661                          [ 10.07, 10.07, 10.07],
    662                          [ 11.0,  11.0,  11.0],
    663                          [ 11.0,  11.0,  11.0]])
     655        assert numpy.allclose(domain.quantities['friction'].get_values(),
     656                              [[ 10.09, 10.09, 10.09],
     657                               [ 10.09, 10.09, 10.09],
     658                               [ 10.07, 10.07, 10.07],
     659                               [ 10.07, 10.07, 10.07],
     660                               [ 11.0,  11.0,  11.0],
     661                               [ 11.0,  11.0,  11.0]])
    664662
    665663
     
    670668        from mesh_factory import rectangular
    671669        from shallow_water import Domain
    672         from Numeric import zeros, Float
    673670
    674671        #Create basic mesh
     
    690687       
    691688        #print domain.quantities['friction'].get_values()
    692         assert allclose(domain.quantities['friction'].get_values(),\
    693                         [[ 0.09,  0.09,  0.09],
    694                          [ 0.09,  0.09,  0.09],
    695                          [ 0.07,  0.07,  0.07],
    696                          [ 0.07,  0.07,  0.07],
    697                          [ 1.0,  1.0,  1.0],
    698                          [ 1.0,  1.0,  1.0]])
     689        assert numpy.allclose(domain.quantities['friction'].get_values(),
     690                              [[ 0.09,  0.09,  0.09],
     691                               [ 0.09,  0.09,  0.09],
     692                               [ 0.07,  0.07,  0.07],
     693                               [ 0.07,  0.07,  0.07],
     694                               [ 1.0,  1.0,  1.0],
     695                               [ 1.0,  1.0,  1.0]])
    699696       
    700697        domain.set_region([set_bottom_friction, set_top_friction])
    701698        #print domain.quantities['friction'].get_values()
    702         assert allclose(domain.quantities['friction'].get_values(),\
    703                         [[ 0.09,  0.09,  0.09],
    704                          [ 0.09,  0.09,  0.09],
    705                          [ 0.07,  0.07,  0.07],
    706                          [ 0.07,  0.07,  0.07],
    707                          [ 1.0,  1.0,  1.0],
    708                          [ 1.0,  1.0,  1.0]])
     699        assert numpy.allclose(domain.quantities['friction'].get_values(),
     700                              [[ 0.09,  0.09,  0.09],
     701                               [ 0.09,  0.09,  0.09],
     702                               [ 0.07,  0.07,  0.07],
     703                               [ 0.07,  0.07,  0.07],
     704                               [ 1.0,  1.0,  1.0],
     705                               [ 1.0,  1.0,  1.0]])
    709706
    710707        domain.set_region([set_all_friction])
    711708        #print domain.quantities['friction'].get_values()
    712         assert allclose(domain.quantities['friction'].get_values(),
    713                         [[ 10.09, 10.09, 10.09],
    714                          [ 10.09, 10.09, 10.09],
    715                          [ 10.07, 10.07, 10.07],
    716                          [ 10.07, 10.07, 10.07],
    717                          [ 11.0,  11.0,  11.0],
    718                          [ 11.0,  11.0,  11.0]])
     709        assert numpy.allclose(domain.quantities['friction'].get_values(),
     710                              [[ 10.09, 10.09, 10.09],
     711                               [ 10.09, 10.09, 10.09],
     712                               [ 10.07, 10.07, 10.07],
     713                               [ 10.07, 10.07, 10.07],
     714                               [ 11.0,  11.0,  11.0],
     715                               [ 11.0,  11.0,  11.0]])
    719716
    720717#-------------------------------------------------------------
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_ermapper.py

    r1813 r5892  
    55
    66import ermapper_grids
    7 import Numeric
     7import numpy
    88from os import remove
    99
     
    1919        data_filename = 'test_write_ermapper_grid'
    2020       
    21         original_grid = Numeric.array([[0.0, 0.1, 1.0], [2.0, 3.0, 4.0]])
     21        original_grid = numpy.array([[0.0, 0.1, 1.0], [2.0, 3.0, 4.0]])
    2222
    2323        # Check that the function works when passing the filename without
     
    2525        ermapper_grids.write_ermapper_grid(data_filename, original_grid)
    2626        new_grid = ermapper_grids.read_ermapper_grid(data_filename)
    27         assert Numeric.allclose(original_grid, new_grid)
     27        assert numpy.allclose(original_grid, new_grid)
    2828
    2929        # Check that the function works when passing the filename with
     
    3131        ermapper_grids.write_ermapper_grid(header_filename, original_grid)
    3232        new_grid = ermapper_grids.read_ermapper_grid(header_filename)
    33         assert Numeric.allclose(original_grid, new_grid)
     33        assert numpy.allclose(original_grid, new_grid)
    3434
    3535        # Clean up created files
     
    4040        # Setup test data
    4141        filename = 'test_write_ermapper_grid'
    42         original_grid = Numeric.array([0.0, 0.1, 1.0, 2.0, 3.0, 4.0])
     42        original_grid = numpy.array([0.0, 0.1, 1.0, 2.0, 3.0, 4.0])
    4343
    4444        # Write test data
    45         ermapper_grids.write_ermapper_data(original_grid, filename, Numeric.Float64)
     45        ermapper_grids.write_ermapper_data(original_grid, filename, numpy.float64)
    4646
    4747        # Read in the test data
    48         new_grid = ermapper_grids.read_ermapper_data(filename, Numeric.Float64)
     48        new_grid = ermapper_grids.read_ermapper_data(filename, numpy.float64)
    4949
    5050        # Check that the test data that has been read in matches the original data
    51         assert Numeric.allclose(original_grid, new_grid)
     51        assert numpy.allclose(original_grid, new_grid)
    5252
    5353        # Clean up created files
     
    5757        # Setup test data
    5858        filename = 'test_write_ermapper_grid'
    59         original_grid = Numeric.array([0.0, 0.1, 1.0, 2.0, 3.0, 4.0])
     59        original_grid = numpy.array([0.0, 0.1, 1.0, 2.0, 3.0, 4.0])
    6060
    6161        # Write test data
     
    6666
    6767        # Check that the test data that has been read in matches the original data
    68         assert Numeric.allclose(original_grid, new_grid)
     68        assert numpy.allclose(original_grid, new_grid)
    6969
    7070        # Clean up created files
     
    7575
    7676        # setup test data
    77         original_grid = Numeric.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])
     77        original_grid = numpy.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]])
    7878        # Write test data
    7979        ermapper_grids.write_ermapper_data(original_grid, data_filename)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r5843 r5892  
    77
    88from anuga.config import epsilon
    9 from Numeric import allclose, array, ones, Float
     9import numpy
    1010from general_mesh import General_mesh
    1111from anuga.coordinate_transforms.geo_reference import Geo_reference
     
    2323    def test_get_vertex_coordinates(self):
    2424        from mesh_factory import rectangular
    25         from Numeric import zeros, Float
    2625
    2726        #Create basic mesh
     
    3029
    3130
    32         assert allclose(domain.get_nodes(), nodes)
     31        assert numpy.allclose(domain.get_nodes(), nodes)
    3332
    3433
     
    4140            for j in range(3):
    4241                k = triangles[i,j]  #Index of vertex j in triangle i
    43                 assert allclose(V[3*i+j,:], nodes[k])
     42                assert numpy.allclose(V[3*i+j,:], nodes[k])
    4443
    4544    def test_get_vertex_coordinates_with_geo_ref(self):
     
    5554        f = [4.0, 0.0]
    5655
    57         nodes = array([a, b, c, d, e, f])
     56        nodes = numpy.array([a, b, c, d, e, f])
    5857
    5958        nodes_absolute = geo.get_absolute(nodes)
    6059       
    6160        #bac, bce, ecf, dbe, daf, dae
    62         triangles = array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     61        triangles = numpy.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    6362
    6463        domain = General_mesh(nodes, triangles,
    6564                       geo_reference = geo)
    6665        verts = domain.get_vertex_coordinates(triangle_id=0)       
    67         self.assert_(allclose(array([b,a,c]), verts))
     66        self.assert_(numpy.allclose(numpy.array([b,a,c]), verts))
    6867        verts = domain.get_vertex_coordinates(triangle_id=0)       
    69         self.assert_(allclose(array([b,a,c]), verts))
     68        self.assert_(numpy.allclose(numpy.array([b,a,c]), verts))
    7069        verts = domain.get_vertex_coordinates(triangle_id=0,
    7170                                              absolute=True)       
    72         self.assert_(allclose(array([nodes_absolute[1],
    73                                      nodes_absolute[0],
    74                                      nodes_absolute[2]]), verts))
     71        self.assert_(numpy.allclose(numpy.array([nodes_absolute[1],
     72                                                 nodes_absolute[0],
     73                                                 nodes_absolute[2]]), verts))
    7574        verts = domain.get_vertex_coordinates(triangle_id=0,
    7675                                              absolute=True)       
    77         self.assert_(allclose(array([nodes_absolute[1],
    78                                      nodes_absolute[0],
    79                                      nodes_absolute[2]]), verts))
     76        self.assert_(numpy.allclose(numpy.array([nodes_absolute[1],
     77                                                 nodes_absolute[0],
     78                                                 nodes_absolute[2]]), verts))
    8079       
    8180       
     
    8685        """
    8786        from mesh_factory import rectangular
    88         from Numeric import zeros, Float
    8987
    9088        #Create basic mesh
     
    9391
    9492
    95         assert allclose(domain.get_nodes(), nodes)
     93        assert numpy.allclose(domain.get_nodes(), nodes)
    9694
    9795
     
    104102            for j in range(3):
    105103                k = triangles[i,j]  #Index of vertex j in triangle i
    106                 assert allclose(V[j,:], nodes[k])
     104                assert numpy.allclose(V[j,:], nodes[k])
    107105
    108106
     
    114112        """
    115113        from mesh_factory import rectangular
    116         from Numeric import zeros, Float
    117114
    118115        #Create basic mesh
     
    121118
    122119        value = [7]
    123         assert allclose(domain.get_triangles(), triangles)
    124         assert allclose(domain.get_triangles([0,4]),
    125                         [triangles[0], triangles[4]])
     120        assert numpy.allclose(domain.get_triangles(), triangles)
     121        assert numpy.allclose(domain.get_triangles([0,4]),
     122                              [triangles[0], triangles[4]])
    126123       
    127124
     
    130127        """
    131128        from mesh_factory import rectangular
    132         from Numeric import zeros, Float, array
    133 
    134         a = [0.0, 0.0]
    135         b = [0.0, 2.0]
    136         c = [2.0, 0.0]
    137         d = [0.0, 4.0]
    138         e = [2.0, 2.0]
    139         f = [4.0, 0.0]
    140 
    141         nodes = array([a, b, c, d, e, f])
     129
     130        a = [0.0, 0.0]
     131        b = [0.0, 2.0]
     132        c = [2.0, 0.0]
     133        d = [0.0, 4.0]
     134        e = [2.0, 2.0]
     135        f = [4.0, 0.0]
     136
     137        nodes = numpy.array([a, b, c, d, e, f])
    142138        #bac, bce, ecf, dbe, daf, dae
    143         triangles = array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     139        triangles = numpy.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    144140
    145141        domain1 = General_mesh(nodes, triangles)
     
    162158            #print count
    163159            #
    164             assert allclose(count, domain.number_of_triangles_per_node)
     160            assert numpy.allclose(count, domain.number_of_triangles_per_node)
    165161           
    166162            # Check indices
     
    196192        f = [4.0, 0.0]
    197193
    198         nodes = array([a, b, c, d, e, f])
     194        nodes = numpy.array([a, b, c, d, e, f])
    199195        #bac, bce, ecf, dbe, daf, dae
    200         triangles = array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     196        triangles = numpy.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    201197
    202198        domain = General_mesh(nodes, triangles)
     
    204200        # One node
    205201        L = domain.get_triangles_and_vertices_per_node(node=2)
    206         assert allclose(L[0], [0, 2])
    207         assert allclose(L[1], [1, 1])
    208         assert allclose(L[2], [2, 1])
     202        print 'L=%s' % str(L)
     203        assert numpy.allclose(L[0], [0, 2])
     204        assert numpy.allclose(L[1], [1, 1])
     205        assert numpy.allclose(L[2], [2, 1])
    209206
    210207        # All nodes
     
    213210        for i, Lref in enumerate(ALL):
    214211            L = domain.get_triangles_and_vertices_per_node(node=i)
    215             assert allclose(L, Lref)
     212            assert numpy.allclose(L, Lref)
    216213           
    217214
     
    224221        from mesh_factory import rectangular
    225222        from shallow_water import Domain
    226         from Numeric import zeros, Float
    227223
    228224        #Create basic mesh
     
    239235        from mesh_factory import rectangular
    240236        from shallow_water import Domain
    241         from Numeric import zeros, Float
    242237
    243238        #Create basic mesh
     
    273268        f = [4.0, 0.0]
    274269
    275         nodes = array([a, b, c, d, e, f])
     270        nodes = numpy.array([a, b, c, d, e, f])
    276271
    277272        nodes_absolute = geo.get_absolute(nodes)
    278273       
    279274        #bac, bce, ecf, dbe, daf, dae
    280         triangles = array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     275        triangles = numpy.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    281276
    282277        domain = General_mesh(nodes, triangles,
    283278                       geo_reference = geo)
    284279        node = domain.get_node(2)       
    285         self.assertEqual(c, node)
     280        self.assertTrue(numpy.alltrue(c == node))
    286281       
    287282        node = domain.get_node(2, absolute=True)     
    288         self.assertEqual(nodes_absolute[2], node)
     283        self.assertTrue(numpy.alltrue(nodes_absolute[2] == node))
    289284       
    290285        node = domain.get_node(2, absolute=True)     
    291         self.assertEqual(nodes_absolute[2], node)
     286        self.assertTrue(numpy.alltrue(nodes_absolute[2] == node))
    292287       
    293288
     
    310305        f = [4.0, 0.0]
    311306
    312         nodes = array([a, b, c, d, e, f])
     307        nodes = numpy.array([a, b, c, d, e, f])
    313308
    314309        nodes_absolute = geo.get_absolute(nodes)
    315310       
    316311        # max index is 5, use 5, expect success
    317         triangles = array([[1,5,2], [1,2,4], [4,2,5], [3,1,4]])
     312        triangles = numpy.array([[1,5,2], [1,2,4], [4,2,5], [3,1,4]])
    318313        General_mesh(nodes, triangles, geo_reference=geo)
    319314       
    320315        # max index is 5, use 6, expect assert failure
    321         triangles = array([[1,6,2], [1,2,4], [4,2,5], [3,1,4]])
     316        triangles = numpy.array([[1,6,2], [1,2,4], [4,2,5], [3,1,4]])
    322317        self.failUnlessRaises(AssertionError, General_mesh,
    323318                              nodes, triangles, geo_reference=geo)
    324319       
    325320        # max index is 5, use 10, expect assert failure
    326         triangles = array([[1,10,2], [1,2,4], [4,2,5], [3,1,4]])
     321        triangles = numpy.array([[1,10,2], [1,2,4], [4,2,5], [3,1,4]])
    327322        self.failUnlessRaises(AssertionError, General_mesh,
    328323                              nodes, triangles, geo_reference=geo)
     
    333328if __name__ == "__main__":
    334329    suite = unittest.makeSuite(Test_General_Mesh,'test')
    335     #suite = unittest.makeSuite(Test_General_Mesh,'test_get_node')   
    336330    runner = unittest.TextTestRunner()
    337331    runner.run(suite)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_boundary_conditions.py

    r5666 r5892  
    66from generic_boundary_conditions import *
    77from anuga.config import epsilon
    8 from Numeric import allclose, array
     8import numpy
    99
    1010
     
    4444
    4545        q = Bd.evaluate()
    46         assert allclose(q, x)
     46        assert numpy.allclose(q, x)
    4747
    4848
     
    9898        q = T.evaluate(0, 2)  #Vol=0, edge=2
    9999
    100         assert allclose(q, [1.5, 2.5])
     100        assert numpy.allclose(q, [1.5, 2.5])
    101101
    102102
     
    175175
    176176        #Check that midpoint coordinates at boundary are correctly computed
    177         assert allclose( F.midpoint_coordinates,
    178                          [[1.0, 0.0], [0.0, 1.0], [3.0, 0.0],
    179                           [3.0, 1.0], [1.0, 3.0], [0.0, 3.0]])
    180 
    181         #assert allclose(F.midpoint_coordinates[(3,2)], [0.0, 3.0])
    182         #assert allclose(F.midpoint_coordinates[(3,1)], [1.0, 3.0])
    183         #assert allclose(F.midpoint_coordinates[(0,2)], [0.0, 1.0])
    184         #assert allclose(F.midpoint_coordinates[(0,0)], [1.0, 0.0])
    185         #assert allclose(F.midpoint_coordinates[(2,0)], [3.0, 0.0])
    186         #assert allclose(F.midpoint_coordinates[(2,1)], [3.0, 1.0])
     177        assert numpy.allclose( F.midpoint_coordinates,
     178                               [[1.0, 0.0], [0.0, 1.0], [3.0, 0.0],
     179                                [3.0, 1.0], [1.0, 3.0], [0.0, 3.0]])
     180
     181        #assert numpy.allclose(F.midpoint_coordinates[(3,2)], [0.0, 3.0])
     182        #assert numpy.allclose(F.midpoint_coordinates[(3,1)], [1.0, 3.0])
     183        #assert numpy.allclose(F.midpoint_coordinates[(0,2)], [0.0, 1.0])
     184        #assert numpy.allclose(F.midpoint_coordinates[(0,0)], [1.0, 0.0])
     185        #assert numpy.allclose(F.midpoint_coordinates[(2,0)], [3.0, 0.0])
     186        #assert numpy.allclose(F.midpoint_coordinates[(2,1)], [3.0, 1.0])
    187187
    188188
     
    193193        domain.time = 5*30/2  #A quarter way through first step
    194194        q = F.evaluate()
    195         assert allclose(q, [1.0/4, sin(2*pi/10)/4])
     195        assert numpy.allclose(q, [1.0/4, sin(2*pi/10)/4])
    196196
    197197
    198198        domain.time = 2.5*5*60  #Half way between steps 2 and 3
    199199        q = F.evaluate()
    200         assert allclose(q, [2.5, (sin(2*2*pi/10) + sin(3*2*pi/10))/2])
     200        assert numpy.allclose(q, [2.5, (sin(2*2*pi/10) + sin(3*2*pi/10))/2])
    201201
    202202
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_ghost.py

    r3514 r5892  
    66from domain import *
    77from anuga.config import epsilon
    8 from Numeric import allclose, array, ones, Float
    9 
    10 
     8import numpy
    119
    1210
     
    4341
    4442
    45         assert domain.get_conserved_quantities(0, edge=1) == 0.
     43        assert numpy.alltrue(domain.get_conserved_quantities(0, edge=1) == 0.)
    4644
    4745
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_neighbour_mesh.py

    r5288 r5892  
    11#!/usr/bin/env python
    2 
    3 
    42
    53#FIXME: Seperate the tests for mesh and general_mesh
     
    1311from mesh_factory import rectangular
    1412from anuga.config import epsilon
    15 from Numeric import allclose, array, Int
     13import numpy
    1614
    1715from anuga.coordinate_transforms.geo_reference import Geo_reference
     
    2018
    2119def distance(x, y):
    22     return sqrt( sum( (array(x)-array(y))**2 ))
     20    return sqrt( sum( (numpy.array(x)-numpy.array(y))**2 ))
    2321
    2422class Test_Mesh(unittest.TestCase):
     
    6361        #Normals
    6462        normals = mesh.get_normals()
    65         assert allclose(normals[0, 0:2], [3.0/5, 4.0/5])
    66         assert allclose(normals[0, 2:4], [-1.0, 0.0])
    67         assert allclose(normals[0, 4:6], [0.0, -1.0])
    68 
    69         assert allclose(mesh.get_normal(0,0), [3.0/5, 4.0/5])
    70         assert allclose(mesh.get_normal(0,1), [-1.0, 0.0])
    71         assert allclose(mesh.get_normal(0,2), [0.0, -1.0])
     63        assert numpy.allclose(normals[0, 0:2], [3.0/5, 4.0/5])
     64        assert numpy.allclose(normals[0, 2:4], [-1.0, 0.0])
     65        assert numpy.allclose(normals[0, 4:6], [0.0, -1.0])
     66
     67        assert numpy.allclose(mesh.get_normal(0,0), [3.0/5, 4.0/5])
     68        assert numpy.allclose(mesh.get_normal(0,1), [-1.0, 0.0])
     69        assert numpy.allclose(mesh.get_normal(0,2), [0.0, -1.0])
    7270
    7371        #Edge lengths
    74         assert allclose(mesh.edgelengths[0], [5.0, 3.0, 4.0])
     72        assert numpy.allclose(mesh.edgelengths[0], [5.0, 3.0, 4.0])
    7573
    7674
     
    8179
    8280        V = mesh.get_vertex_coordinates()
    83         assert allclose(V, [ [0.0, 0.0],
    84                              [4.0, 0.0],
    85                              [0.0, 3.0] ])
     81        assert numpy.allclose(V, [ [0.0, 0.0],
     82                                   [4.0, 0.0],
     83                                   [0.0, 3.0] ])
    8684
    8785        V0 = mesh.get_vertex_coordinate(0, 0)
    88         assert allclose(V0, [0.0, 0.0])
     86        assert numpy.allclose(V0, [0.0, 0.0])
    8987
    9088        V1 = mesh.get_vertex_coordinate(0, 1)
    91         assert allclose(V1, [4.0, 0.0])
     89        assert numpy.allclose(V1, [4.0, 0.0])
    9290
    9391        V2 = mesh.get_vertex_coordinate(0, 2)
    94         assert allclose(V2, [0.0, 3.0])
     92        assert numpy.allclose(V2, [0.0, 3.0])
    9593
    9694
     
    237235
    238236        mesh = Mesh(points, vertices,use_inscribed_circle=False)
    239         assert allclose(mesh.radii[0],sqrt(3.0)/3),'Steve''s doesn''t work'
     237        assert numpy.allclose(mesh.radii[0],sqrt(3.0)/3),'Steve''s doesn''t work'
    240238
    241239        mesh = Mesh(points, vertices,use_inscribed_circle=True)
    242         assert allclose(mesh.radii[0],sqrt(3.0)/3),'inscribed circle doesn''t work'
     240        assert numpy.allclose(mesh.radii[0],sqrt(3.0)/3),'inscribed circle doesn''t work'
    243241
    244242    def test_inscribed_circle_rightangle_triangle(self):
     
    252250
    253251        mesh = Mesh(points, vertices,use_inscribed_circle=False)
    254         assert allclose(mesh.radii[0],5.0/6),'Steve''s doesn''t work'
     252        assert numpy.allclose(mesh.radii[0],5.0/6),'Steve''s doesn''t work'
    255253
    256254        mesh = Mesh(points, vertices,use_inscribed_circle=True)
    257         assert allclose(mesh.radii[0],1.0),'inscribed circle doesn''t work'
     255        assert numpy.allclose(mesh.radii[0],1.0),'inscribed circle doesn''t work'
    258256
    259257
     
    269267        assert mesh.areas[0] == 2.0
    270268
    271         assert allclose(mesh.centroid_coordinates[0], [2.0/3, 2.0/3])
     269        assert numpy.allclose(mesh.centroid_coordinates[0], [2.0/3, 2.0/3])
    272270
    273271
     
    303301        assert mesh.edgelengths[1,2] == sqrt(8.0)
    304302
    305         assert allclose(mesh.centroid_coordinates[0], [2.0/3, 2.0/3])
    306         assert allclose(mesh.centroid_coordinates[1], [4.0/3, 4.0/3])
    307         assert allclose(mesh.centroid_coordinates[2], [8.0/3, 2.0/3])
    308         assert allclose(mesh.centroid_coordinates[3], [2.0/3, 8.0/3])
     303        assert numpy.allclose(mesh.centroid_coordinates[0], [2.0/3, 2.0/3])
     304        assert numpy.allclose(mesh.centroid_coordinates[1], [4.0/3, 4.0/3])
     305        assert numpy.allclose(mesh.centroid_coordinates[2], [8.0/3, 2.0/3])
     306        assert numpy.allclose(mesh.centroid_coordinates[3], [2.0/3, 8.0/3])
    309307
    310308    def test_mesh_and_neighbours(self):
     
    697695        get values based on triangle lists.
    698696        """
     697
    699698        from mesh_factory import rectangular
    700         from Numeric import zeros, Float
    701699
    702700        #Create basic mesh
     
    716714    def test_boundary_polygon(self):
    717715        from mesh_factory import rectangular
    718         #from mesh import Mesh
    719         from Numeric import zeros, Float
    720716
    721717        #Create basic mesh
     
    727723
    728724        assert len(P) == 8
    729         assert allclose(P, [[0.0, 0.0], [0.5, 0.0], [1.0, 0.0],
    730                             [1.0, 0.5], [1.0, 1.0], [0.5, 1.0],
    731                             [0.0, 1.0], [0.0, 0.5]])
     725        assert numpy.allclose(P, [[0.0, 0.0], [0.5, 0.0], [1.0, 0.0],
     726                                  [1.0, 0.5], [1.0, 1.0], [0.5, 1.0],
     727                                  [0.0, 1.0], [0.0, 0.5]])
    732728        for p in points:
    733729            #print p, P
     
    736732
    737733    def test_boundary_polygon_II(self):
    738         from Numeric import zeros, Float
    739        
    740 
    741734        #Points
    742735        a = [0.0, 0.0] #0
     
    764757
    765758        assert len(P) == 8
    766         assert allclose(P, [a, d, f, i, h, e, c, b])
     759        assert numpy.allclose(P, [a, d, f, i, h, e, c, b])
    767760
    768761        for p in points:
     
    774767        """Same as II but vertices ordered differently
    775768        """
    776 
    777         from Numeric import zeros, Float
    778 
    779769
    780770        #Points
     
    804794
    805795        assert len(P) == 8
    806         assert allclose(P, [a, d, f, i, h, e, c, b])
     796        assert numpy.allclose(P, [a, d, f, i, h, e, c, b])
    807797
    808798        for p in points:
     
    815805        is partitioned using pymetis.
    816806        """
    817 
    818         from Numeric import zeros, Float
    819 
    820807
    821808        #Points
     
    847834       
    848835        # Note that point e appears twice!
    849         assert allclose(P, [a, d, f, e, g, h, e, c, b])
     836        assert numpy.allclose(P, [a, d, f, e, g, h, e, c, b])
    850837
    851838        for p in points:
     
    864851        """
    865852
    866         from Numeric import zeros, Float
    867853        from mesh_factory import rectangular       
    868854
     
    907893       
    908894        """
    909         from Numeric import zeros, Float
    910        
    911895
    912896        #Points
     
    955939       
    956940        assert len(P) == 8
    957         assert allclose(P, [a, d, f, i, h, e, c, b])
    958         assert allclose(P, [(0.0, 0.0), (0.5, 0.0), (1.0, 0.0), (1.5, 0.5), (1.0, 1.0), (0.5, 0.5), (0.0, 1.0), (0.0, 0.5)])
     941        assert numpy.allclose(P, [a, d, f, i, h, e, c, b])
     942        assert numpy.allclose(P, [(0.0, 0.0), (0.5, 0.0), (1.0, 0.0), (1.5, 0.5), (1.0, 1.0), (0.5, 0.5), (0.0, 1.0), (0.0, 0.5)])
    959943       
    960944
     
    998982                  [  52341.70703125,  38563.39453125]]
    999983
    1000         ##points = ensure_numeric(points, Int)/1000  # Simplify for ease of interpretation       
     984        ##points = ensure_numeric(points, int)/1000  # Simplify for ease of interpretation       
    1001985
    1002986        triangles = [[19, 0,15],
     
    11011085                  [  35406.3359375 ,  79332.9140625 ]]
    11021086
    1103         scaled_points = ensure_numeric(points, Int)/1000  # Simplify for ease of interpretation
     1087        scaled_points = ensure_numeric(points, int)/1000  # Simplify for ease of interpretation
    11041088
    11051089        triangles = [[ 0, 1, 2],
     
    11421126            assert is_inside_polygon(p, P)           
    11431127
    1144         assert allclose(P, Pref)   
     1128        assert numpy.allclose(P, Pref)   
    11451129
    11461130    def test_lone_vertices(self):
     
    11941178        boundary_polygon = mesh.get_boundary_polygon()
    11951179
    1196         assert allclose(absolute_points, boundary_polygon)
     1180        assert numpy.allclose(absolute_points, boundary_polygon)
    11971181
    11981182    def test_get_triangle_containing_point(self):
     
    12411225
    12421226        neighbours = mesh.get_triangle_neighbours(0)
    1243         assert allclose(neighbours, [-1,1,-1])
     1227        assert numpy.allclose(neighbours, [-1,1,-1])
    12441228        neighbours = mesh.get_triangle_neighbours(-10)
    12451229        assert neighbours == []
     
    12901274            for x in L:
    12911275                if x.triangle_id % 2 == 0:
    1292                     assert allclose(x.length, ceiling-y_line)
     1276                    assert numpy.allclose(x.length, ceiling-y_line)
    12931277                else:
    1294                     assert allclose(x.length, y_line-floor)               
     1278                    assert numpy.allclose(x.length, y_line-floor)               
    12951279
    12961280               
    1297                 assert allclose(x.normal, [0,-1])
    1298 
    1299                 assert allclose(x.segment[1][0], x.segment[0][0] + x.length)
    1300                 assert allclose(x.segment[0][1], y_line)
    1301                 assert allclose(x.segment[1][1], y_line)               
     1281                assert numpy.allclose(x.normal, [0,-1])
     1282
     1283                assert numpy.allclose(x.segment[1][0], x.segment[0][0] + x.length)
     1284                assert numpy.allclose(x.segment[0][1], y_line)
     1285                assert numpy.allclose(x.segment[1][1], y_line)               
    13021286
    13031287                assert x.triangle_id in intersected_triangles
     
    13061290
    13071291            msg = 'Segments do not add up'
    1308             assert allclose(total_length, 2), msg
     1292            assert numpy.allclose(total_length, 2), msg
    13091293           
    13101294
     
    13411325        total_length = 0
    13421326        for x in L:
    1343             assert allclose(x.length, 1.0)
    1344             assert allclose(x.normal, [0,-1])
    1345 
    1346             assert allclose(x.segment[1][0], x.segment[0][0] + x.length)
    1347             assert allclose(x.segment[0][1], y_line)
    1348             assert allclose(x.segment[1][1], y_line)                           
     1327            assert numpy.allclose(x.length, 1.0)
     1328            assert numpy.allclose(x.normal, [0,-1])
     1329
     1330            assert numpy.allclose(x.segment[1][0], x.segment[0][0] + x.length)
     1331            assert numpy.allclose(x.segment[0][1], y_line)
     1332            assert numpy.allclose(x.segment[1][1], y_line)                           
    13491333
    13501334
     
    13551339
    13561340        msg = 'Segments do not add up'
    1357         assert allclose(total_length, 2), msg
     1341        assert numpy.allclose(total_length, 2), msg
    13581342       
    13591343
     
    13951379        for x in L:
    13961380            if x.triangle_id == 1:
    1397                 assert allclose(x.length, 1)       
    1398                 assert allclose(x.normal, [0, -1])
     1381                assert numpy.allclose(x.length, 1)       
     1382                assert numpy.allclose(x.normal, [0, -1])
    13991383               
    14001384            if x.triangle_id == 5:
    1401                 assert allclose(x.length, 0.5)
    1402                 assert allclose(x.normal, [0, -1])
     1385                assert numpy.allclose(x.length, 0.5)
     1386                assert numpy.allclose(x.normal, [0, -1])
    14031387
    14041388
     
    14081392
    14091393        msg = 'Segments do not add up'
    1410         assert allclose(total_length, 1.5), msg           
     1394        assert numpy.allclose(total_length, 1.5), msg           
    14111395
    14121396
     
    14421426        total_length = 0
    14431427        for i, x in enumerate(L):
    1444             assert allclose(x.length, s2)
    1445             assert allclose(x.normal, [-s2, -s2])
    1446             assert allclose(sum(x.normal**2), 1)
     1428            assert numpy.allclose(x.length, s2)
     1429            assert numpy.allclose(x.normal, [-s2, -s2])
     1430            assert numpy.allclose(sum(x.normal**2), 1)
    14471431           
    14481432            assert x.triangle_id in intersected_triangles
     
    14511435
    14521436        msg = 'Segments do not add up'
    1453         assert allclose(total_length, 4*s2), msg
     1437        assert numpy.allclose(total_length, 4*s2), msg
    14541438
    14551439
     
    14661450        total_length = 0
    14671451        for i, x in enumerate(L):
    1468             assert allclose(x.length, s2)
    1469             assert allclose(x.normal, [s2, s2])
    1470             assert allclose(sum(x.normal**2), 1)
     1452            assert numpy.allclose(x.length, s2)
     1453            assert numpy.allclose(x.normal, [s2, s2])
     1454            assert numpy.allclose(sum(x.normal**2), 1)
    14711455           
    14721456            assert x.triangle_id in intersected_triangles
     
    14751459
    14761460        msg = 'Segments do not add up'
    1477         assert allclose(total_length, 4*s2), msg                   
     1461        assert numpy.allclose(total_length, 4*s2), msg                   
    14781462
    14791463
     
    14911475        total_length = 0
    14921476        for i, x in enumerate(L):
    1493             assert allclose(x.length, 2*s2)
    1494             assert allclose(x.normal, [-s2, s2])
    1495             assert allclose(sum(x.normal**2), 1)
     1477            assert numpy.allclose(x.length, 2*s2)
     1478            assert numpy.allclose(x.normal, [-s2, s2])
     1479            assert numpy.allclose(sum(x.normal**2), 1)
    14961480           
    14971481            assert x.triangle_id in intersected_triangles
     
    15001484
    15011485        msg = 'Segments do not add up'
    1502         assert allclose(total_length, 4*s2), msg                       
     1486        assert numpy.allclose(total_length, 4*s2), msg                       
    15031487
    15041488
     
    15151499        total_length = 0
    15161500        for i, x in enumerate(L):
    1517             assert allclose(x.length, 2*s2)
    1518             assert allclose(x.normal, [s2, -s2])
    1519             assert allclose(sum(x.normal**2), 1)
     1501            assert numpy.allclose(x.length, 2*s2)
     1502            assert numpy.allclose(x.normal, [s2, -s2])
     1503            assert numpy.allclose(sum(x.normal**2), 1)
    15201504           
    15211505            assert x.triangle_id in intersected_triangles
     
    15241508
    15251509        msg = 'Segments do not add up'
    1526         assert allclose(total_length, 4*s2), msg                       
     1510        assert numpy.allclose(total_length, 4*s2), msg                       
    15271511
    15281512
     
    15401524        total_length = 0
    15411525        for i, x in enumerate(L):
    1542             assert allclose(x.length, s2)
    1543             assert allclose(x.normal, [-s2, -s2])
    1544             assert allclose(sum(x.normal**2), 1)
     1526            assert numpy.allclose(x.length, s2)
     1527            assert numpy.allclose(x.normal, [-s2, -s2])
     1528            assert numpy.allclose(sum(x.normal**2), 1)
    15451529           
    15461530            assert x.triangle_id in intersected_triangles
     
    15491533
    15501534        msg = 'Segments do not add up'
    1551         assert allclose(total_length, 2*s2), msg
     1535        assert numpy.allclose(total_length, 2*s2), msg
    15521536
    15531537
     
    15621546        total_length = 0
    15631547        for i, x in enumerate(L):
    1564             assert allclose(x.normal, [-s2, -s2])
    1565             assert allclose(sum(x.normal**2), 1)
     1548            assert numpy.allclose(x.normal, [-s2, -s2])
     1549            assert numpy.allclose(sum(x.normal**2), 1)
    15661550
    15671551            msg = 'Triangle %d' %x.triangle_id + ' is not in %s' %(intersected_triangles)
     
    15981582        assert len(L) == 1
    15991583        assert L[0].triangle_id == 3
    1600         assert allclose(L[0].length, 0.5)       
    1601         assert allclose(L[0].normal, [-1,0])               
     1584        assert numpy.allclose(L[0].length, 0.5)       
     1585        assert numpy.allclose(L[0].normal, [-1,0])               
    16021586
    16031587
     
    16101594        assert len(L) == 1
    16111595        assert L[0].triangle_id == 3
    1612         assert allclose(L[0].length, 0.4)
    1613         assert allclose(L[0].normal, [-1,0])
     1596        assert numpy.allclose(L[0].length, 0.4)
     1597        assert numpy.allclose(L[0].normal, [-1,0])
    16141598
    16151599        intersected_triangles = [3]
     
    16231607        assert len(L) == 1
    16241608        assert L[0].triangle_id == 3
    1625         assert allclose(L[0].length, 0.4)
    1626         assert allclose(L[0].normal, [1,0])               
     1609        assert numpy.allclose(L[0].length, 0.4)
     1610        assert numpy.allclose(L[0].normal, [1,0])               
    16271611       
    16281612
     
    16581642        for x in L:
    16591643            if x.triangle_id == 3:
    1660                 assert allclose(x.length, 0.5)       
    1661                 assert allclose(x.normal, [-1,0])
     1644                assert numpy.allclose(x.length, 0.5)       
     1645                assert numpy.allclose(x.normal, [-1,0])
    16621646               
    16631647            if x.triangle_id == 2:
    1664                 assert allclose(x.length, s2)
    1665                 assert allclose(x.normal, [-s2,-s2])
     1648                assert numpy.allclose(x.length, s2)
     1649                assert numpy.allclose(x.normal, [-s2,-s2])
    16661650
    16671651
     
    16961680        for x in L:
    16971681            if x.triangle_id == 3:
    1698                 assert allclose(x.length, 0.5)       
    1699                 assert allclose(x.normal, [-1,0])
     1682                assert numpy.allclose(x.length, 0.5)       
     1683                assert numpy.allclose(x.normal, [-1,0])
    17001684               
    17011685            if x.triangle_id == 2:
    17021686                msg = str(x.length)
    1703                 assert allclose(x.length, s2), msg
    1704                 assert allclose(x.normal, [-s2,-s2])
     1687                assert numpy.allclose(x.length, s2), msg
     1688                assert numpy.allclose(x.normal, [-s2,-s2])
    17051689
    17061690            if x.triangle_id == 5:
    1707                 segvec = array([line[2][0]-1,
    1708                                 line[2][1]-1])
     1691                segvec = numpy.array([line[2][0]-1,
     1692                                      line[2][1]-1])
    17091693                msg = str(x.length)
    1710                 assert allclose(x.length, sqrt(sum(segvec**2))), msg
    1711                 assert allclose(x.normal, [-s2,-s2])                                               
     1694                assert numpy.allclose(x.length, sqrt(sum(segvec**2))), msg
     1695                assert numpy.allclose(x.normal, [-s2,-s2])                                               
    17121696
    17131697
     
    17471731        for x in L:
    17481732            if x.triangle_id == 3:
    1749                 assert allclose(x.length, 0.5)       
    1750                 assert allclose(x.normal, [-1,0])
     1733                assert numpy.allclose(x.length, 0.5)       
     1734                assert numpy.allclose(x.normal, [-1,0])
    17511735               
    17521736            if x.triangle_id == 2:
    17531737                msg = str(x.length)
    1754                 assert allclose(x.length, s2), msg
    1755                 assert allclose(x.normal, [-s2,-s2])
     1738                assert numpy.allclose(x.length, s2), msg
     1739                assert numpy.allclose(x.normal, [-s2,-s2])
    17561740
    17571741            if x.triangle_id == 5:
    17581742                if x.segment == ((1.0, 1.0), (1.25, 0.75)):                   
    1759                     segvec = array([line[2][0]-1,
    1760                                     line[2][1]-1])
     1743                    segvec = numpy.array([line[2][0]-1,
     1744                                          line[2][1]-1])
    17611745                    msg = str(x.length)
    1762                     assert allclose(x.length, sqrt(sum(segvec**2))), msg
    1763                     assert allclose(x.normal, [-s2,-s2])
     1746                    assert numpy.allclose(x.length, sqrt(sum(segvec**2))), msg
     1747                    assert numpy.allclose(x.normal, [-s2,-s2])
    17641748                elif x.segment == ((1.25, 0.75), (1.5, 1.0)):
    1765                     segvec = array([1.5-line[2][0],
    1766                                     1.0-line[2][1]])
     1749                    segvec = numpy.array([1.5-line[2][0],
     1750                                          1.0-line[2][1]])
    17671751                   
    1768                     assert allclose(x.length, sqrt(sum(segvec**2))), msg
    1769                     assert allclose(x.normal, [s2,-s2])
     1752                    assert numpy.allclose(x.length, sqrt(sum(segvec**2))), msg
     1753                    assert numpy.allclose(x.normal, [s2,-s2])
    17701754                else:
    17711755                    msg = 'Unknow segment: %s' %x.segment
     
    17751759                   
    17761760            if x.triangle_id == 6:
    1777                 assert allclose(x.normal, [s2,-s2])
    1778                 assert allclose(x.segment, ((1.5, 1.0), (2, 1.5)))
     1761                assert numpy.allclose(x.normal, [s2,-s2])
     1762                assert numpy.allclose(x.segment, ((1.5, 1.0), (2, 1.5)))
    17791763
    17801764
     
    18421826            ref_length = line[1][1] - line[0][1]
    18431827            #print ref_length, total_length
    1844             assert allclose(total_length, ref_length)
     1828            assert numpy.allclose(total_length, ref_length)
    18451829
    18461830
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_pmesh2domain.py

    r3563 r5892  
    33
    44import unittest
    5 
    6 from Numeric import allclose, array
    7 
     5import numpy
    86
    97#from anuga.pyvolution.pmesh2domain import *
     
    6664
    6765         tags = {}
    68          b1 =  Dirichlet_boundary(conserved_quantities = array([0.0]))
    69          b2 =  Dirichlet_boundary(conserved_quantities = array([1.0]))
    70          b3 =  Dirichlet_boundary(conserved_quantities = array([2.0]))
     66         b1 =  Dirichlet_boundary(conserved_quantities = numpy.array([0.0]))
     67         b2 =  Dirichlet_boundary(conserved_quantities = numpy.array([1.0]))
     68         b3 =  Dirichlet_boundary(conserved_quantities = numpy.array([2.0]))
    7169         tags["1"] = b1
    7270         tags["2"] = b2
     
    8078         answer = [[0., 8., 0.],
    8179                   [0., 10., 8.]]
    82          assert allclose(domain.quantities['elevation'].vertex_values,
    83                         answer)
     80         assert numpy.allclose(domain.quantities['elevation'].vertex_values,
     81                               answer)
    8482
    8583         #print domain.quantities['stage'].vertex_values
    8684         answer = [[0., 12., 10.],
    8785                   [0., 10., 12.]]
    88          assert allclose(domain.quantities['stage'].vertex_values,
    89                         answer)
     86         assert numpy.allclose(domain.quantities['stage'].vertex_values,
     87                               answer)
    9088
    9189         #print domain.quantities['friction'].vertex_values
    9290         answer = [[0.01, 0.04, 0.03],
    9391                   [0.01, 0.02, 0.04]]
    94          assert allclose(domain.quantities['friction'].vertex_values,
    95                         answer)
    96 
    97          #print domain.quantities['friction'].vertex_values
    98          assert allclose(domain.tagged_elements['dsg'][0],0)
    99          assert allclose(domain.tagged_elements['ole nielsen'][0],1)
     92         assert numpy.allclose(domain.quantities['friction'].vertex_values,
     93                               answer)
     94
     95         #print domain.quantities['friction'].vertex_values
     96         assert numpy.allclose(domain.tagged_elements['dsg'][0],0)
     97         assert numpy.allclose(domain.tagged_elements['ole nielsen'][0],1)
    10098
    10199         self.failUnless( domain.boundary[(1, 0)]  == '1',
     
    159157       
    160158         tags = {}
    161          b1 =  Dirichlet_boundary(conserved_quantities = array([0.0]))
    162          b2 =  Dirichlet_boundary(conserved_quantities = array([1.0]))
    163          b3 =  Dirichlet_boundary(conserved_quantities = array([2.0]))
     159         b1 =  Dirichlet_boundary(conserved_quantities = numpy.array([0.0]))
     160         b2 =  Dirichlet_boundary(conserved_quantities = numpy.array([1.0]))
     161         b3 =  Dirichlet_boundary(conserved_quantities = numpy.array([2.0]))
    164162         tags["1"] = b1
    165163         tags["2"] = b2
     
    174172         answer = [[0., 8., 0.],
    175173                   [0., 10., 8.]]
    176          assert allclose(domain.quantities['elevation'].vertex_values,
    177                         answer)
     174         assert numpy.allclose(domain.quantities['elevation'].vertex_values,
     175                               answer)
    178176
    179177         #print domain.quantities['stage'].vertex_values
    180178         answer = [[0., 12., 10.],
    181179                   [0., 10., 12.]]
    182          assert allclose(domain.quantities['stage'].vertex_values,
    183                         answer)
     180         assert numpy.allclose(domain.quantities['stage'].vertex_values,
     181                               answer)
    184182
    185183         #print domain.quantities['friction'].vertex_values
    186184         answer = [[0.01, 0.04, 0.03],
    187185                   [0.01, 0.02, 0.04]]
    188          assert allclose(domain.quantities['friction'].vertex_values,
    189                         answer)
    190 
    191          #print domain.quantities['friction'].vertex_values
    192          assert allclose(domain.tagged_elements['dsg'][0],0)
    193          assert allclose(domain.tagged_elements['ole nielsen'][0],1)
     186         assert numpy.allclose(domain.quantities['friction'].vertex_values,
     187                               answer)
     188
     189         #print domain.quantities['friction'].vertex_values
     190         assert numpy.allclose(domain.tagged_elements['dsg'][0],0)
     191         assert numpy.allclose(domain.tagged_elements['ole nielsen'][0],1)
    194192
    195193         self.failUnless( domain.boundary[(1, 0)]  == '1',
     
    228226         #domain.set_tag_dict(tag_dict)
    229227         #Boundary tests
    230          b1 =  Dirichlet_boundary(conserved_quantities = array([0.0]))
    231          b2 =  Dirichlet_boundary(conserved_quantities = array([1.0]))
    232          b3 =  Dirichlet_boundary(conserved_quantities = array([1.0]))
     228         b1 =  Dirichlet_boundary(conserved_quantities = numpy.array([0.0]))
     229         b2 =  Dirichlet_boundary(conserved_quantities = numpy.array([1.0]))
     230         b3 =  Dirichlet_boundary(conserved_quantities = numpy.array([1.0]))
    233231         #test adding a boundary
    234232         tags = {}
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r5776 r5892  
    77from quantity import *
    88from anuga.config import epsilon
    9 from Numeric import allclose, array, ones, Float
     9import numpy
    1010
    1111from anuga.fit_interpolate.fit import fit_to_mesh
     
    1818#Aux for fit_interpolate.fit example
    1919def linear_function(point):
    20     point = array(point)
     20    point = numpy.array(point)
    2121    return point[:,0]+point[:,1]
    2222
     
    6363
    6464        quantity = Quantity(self.mesh1, [[1,2,3]])
    65         assert allclose(quantity.vertex_values, [[1.,2.,3.]])
     65        assert numpy.allclose(quantity.vertex_values, [[1.,2.,3.]])
    6666
    6767        try:
     
    8484
    8585        quantity = Quantity(self.mesh1)
    86         assert allclose(quantity.vertex_values, [[0.,0.,0.]])
    87 
    88 
    89         quantity = Quantity(self.mesh4)
    90         assert allclose(quantity.vertex_values, [[0.,0.,0.], [0.,0.,0.],
     86        assert numpy.allclose(quantity.vertex_values, [[0.,0.,0.]])
     87
     88
     89        quantity = Quantity(self.mesh4)
     90        assert numpy.allclose(quantity.vertex_values, [[0.,0.,0.], [0.,0.,0.],
    9191                                                 [0.,0.,0.], [0.,0.,0.]])
    9292
     
    9494    def test_interpolation(self):
    9595        quantity = Quantity(self.mesh1, [[1,2,3]])
    96         assert allclose(quantity.centroid_values, [2.0]) #Centroid
    97 
    98         assert allclose(quantity.edge_values, [[2.5, 2.0, 1.5]])
     96        assert numpy.allclose(quantity.centroid_values, [2.0]) #Centroid
     97
     98        assert numpy.allclose(quantity.edge_values, [[2.5, 2.0, 1.5]])
    9999
    100100
     
    102102        quantity = Quantity(self.mesh4,
    103103                            [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    104         assert allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
     104        assert numpy.allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
    105105
    106106
     
    108108
    109109        #print quantity.vertex_values
    110         assert allclose(quantity.vertex_values, [[3.5, -1.0, 3.5],
    111                                                  [3.+2./3, 6.+2./3, 4.+2./3],
    112                                                  [4.6, 3.4, 1.],
    113                                                  [-5.0, 1.0, 4.0]])
     110        assert numpy.allclose(quantity.vertex_values, [[3.5, -1.0, 3.5],
     111                                                       [3.+2./3, 6.+2./3, 4.+2./3],
     112                                                       [4.6, 3.4, 1.],
     113                                                       [-5.0, 1.0, 4.0]])
    114114
    115115        #print quantity.edge_values
    116         assert allclose(quantity.edge_values, [[1.25, 3.5, 1.25],
    117                                                [5. + 2/3.0, 4.0 + 1.0/6, 5.0 + 1.0/6],
    118                                                [2.2, 2.8, 4.0],
    119                                                [2.5, -0.5, -2.0]])
    120 
    121 
    122         #assert allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
    123         #                                       [5., 5., 5.],
    124         #                                       [4.5, 4.5, 0.],
    125         #                                       [3.0, -1.5, -1.5]])
     116        assert numpy.allclose(quantity.edge_values, [[1.25, 3.5, 1.25],
     117                                                     [5. + 2/3.0, 4.0 + 1.0/6, 5.0 + 1.0/6],
     118                                                     [2.2, 2.8, 4.0],
     119                                                     [2.5, -0.5, -2.0]])
     120
     121
     122        #assert numpy.allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
     123        #                                             [5., 5., 5.],
     124        #                                             [4.5, 4.5, 0.],
     125        #                                             [3.0, -1.5, -1.5]])
    126126
    127127    def test_get_extrema_1(self):
    128128        quantity = Quantity(self.mesh4,
    129129                                      [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    130         assert allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroids
     130        assert numpy.allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroids
    131131
    132132        v = quantity.get_maximum_value()
     
    148148
    149149        v = quantity.get_values(interpolation_points = [[x,y]])
    150         assert allclose(v, 5)
     150        assert numpy.allclose(v, 5)
    151151
    152152
    153153        x,y = quantity.get_minimum_location()
    154154        v = quantity.get_values(interpolation_points = [[x,y]])
    155         assert allclose(v, 0)
     155        assert numpy.allclose(v, 0)
    156156
    157157
     
    192192
    193193        v = quantity.get_values(interpolation_points = [[x,y]])
    194         assert allclose(v, 6)
     194        assert numpy.allclose(v, 6)
    195195
    196196        x,y = quantity.get_minimum_location()       
    197197        v = quantity.get_values(interpolation_points = [[x,y]])
    198         assert allclose(v, 2)
     198        assert numpy.allclose(v, 2)
    199199
    200200        #Multiple locations for maximum -
    201201        #Test that the algorithm picks the first occurrence       
    202202        v = quantity.get_maximum_value(indices=[0,1,2])
    203         assert allclose(v, 4)
     203        assert numpy.allclose(v, 4)
    204204
    205205        i = quantity.get_maximum_index(indices=[0,1,2])
     
    212212
    213213        v = quantity.get_values(interpolation_points = [[x,y]])
    214         assert allclose(v, 4)       
     214        assert numpy.allclose(v, 4)       
    215215
    216216        # More test of indices......
    217217        v = quantity.get_maximum_value(indices=[2,3])
    218         assert allclose(v, 6)
     218        assert numpy.allclose(v, 6)
    219219
    220220        i = quantity.get_maximum_index(indices=[2,3])
     
    227227
    228228        v = quantity.get_values(interpolation_points = [[x,y]])
    229         assert allclose(v, 6)       
     229        assert numpy.allclose(v, 6)       
    230230
    231231       
     
    244244        quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]],
    245245                            location = 'vertices')
    246         assert allclose(quantity.vertex_values,
    247                         [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    248         assert allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
    249         assert allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
    250                                                [5., 5., 5.],
    251                                                [4.5, 4.5, 0.],
    252                                                [3.0, -1.5, -1.5]])
     246        assert numpy.allclose(quantity.vertex_values,
     247                              [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
     248        assert numpy.allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
     249        assert numpy.allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
     250                                                     [5., 5., 5.],
     251                                                     [4.5, 4.5, 0.],
     252                                                     [3.0, -1.5, -1.5]])
    253253
    254254
    255255        # Test default
    256256        quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    257         assert allclose(quantity.vertex_values,
    258                         [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
    259         assert allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
    260         assert allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
    261                                                [5., 5., 5.],
    262                                                [4.5, 4.5, 0.],
    263                                                [3.0, -1.5, -1.5]])
     257        assert numpy.allclose(quantity.vertex_values,
     258                              [[1,2,3], [5,5,5], [0,0,9], [-6, 3, 3]])
     259        assert numpy.allclose(quantity.centroid_values, [2., 5., 3., 0.]) #Centroid
     260        assert numpy.allclose(quantity.edge_values, [[2.5, 2.0, 1.5],
     261                                                     [5., 5., 5.],
     262                                                     [4.5, 4.5, 0.],
     263                                                     [3.0, -1.5, -1.5]])
    264264
    265265        # Test centroids
    266266        quantity.set_values([1,2,3,4], location = 'centroids')
    267         assert allclose(quantity.centroid_values, [1., 2., 3., 4.]) #Centroid
     267        assert numpy.allclose(quantity.centroid_values, [1., 2., 3., 4.]) #Centroid
    268268
    269269        # Test exceptions
     
    288288
    289289        quantity.set_values(1.0, location = 'vertices')
    290         assert allclose(quantity.vertex_values,
    291                         [[1,1,1], [1,1,1], [1,1,1], [1, 1, 1]])
    292 
    293         assert allclose(quantity.centroid_values, [1, 1, 1, 1]) #Centroid
    294         assert allclose(quantity.edge_values, [[1, 1, 1],
    295                                                [1, 1, 1],
    296                                                [1, 1, 1],
    297                                                [1, 1, 1]])
     290        assert numpy.allclose(quantity.vertex_values,
     291                              [[1,1,1], [1,1,1], [1,1,1], [1, 1, 1]])
     292
     293        assert numpy.allclose(quantity.centroid_values, [1, 1, 1, 1]) #Centroid
     294        assert numpy.allclose(quantity.edge_values, [[1, 1, 1],
     295                                                     [1, 1, 1],
     296                                                     [1, 1, 1],
     297                                                     [1, 1, 1]])
    298298
    299299
    300300        quantity.set_values(2.0, location = 'centroids')
    301         assert allclose(quantity.centroid_values, [2, 2, 2, 2])
     301        assert numpy.allclose(quantity.centroid_values, [2, 2, 2, 2])
    302302
    303303
     
    310310        quantity.set_values(f, location = 'vertices')
    311311        #print "quantity.vertex_values",quantity.vertex_values
    312         assert allclose(quantity.vertex_values,
    313                         [[2,0,2], [2,2,4], [4,2,4], [4,2,4]])
    314         assert allclose(quantity.centroid_values,
    315                         [4.0/3, 8.0/3, 10.0/3, 10.0/3])
    316         assert allclose(quantity.edge_values,
    317                         [[1,2,1], [3,3,2], [3,4,3], [3,4,3]])
     312        assert numpy.allclose(quantity.vertex_values,
     313                              [[2,0,2], [2,2,4], [4,2,4], [4,2,4]])
     314        assert numpy.allclose(quantity.centroid_values,
     315                              [4.0/3, 8.0/3, 10.0/3, 10.0/3])
     316        assert numpy.allclose(quantity.edge_values,
     317                              [[1,2,1], [3,3,2], [3,4,3], [3,4,3]])
    318318
    319319
    320320        quantity.set_values(f, location = 'centroids')
    321         assert allclose(quantity.centroid_values,
    322                         [4.0/3, 8.0/3, 10.0/3, 10.0/3])
     321        assert numpy.allclose(quantity.centroid_values,
     322                              [4.0/3, 8.0/3, 10.0/3, 10.0/3])
    323323
    324324
     
    331331        #print 'Q', quantity.get_integral()
    332332
    333         assert allclose(quantity.get_integral(), self.mesh4.get_area() * const)
     333        assert numpy.allclose(quantity.get_integral(), self.mesh4.get_area() * const)
    334334
    335335        #Try with a linear function
     
    342342        ref_integral = (4.0/3 + 8.0/3 + 10.0/3 + 10.0/3) * 2
    343343
    344         assert allclose (quantity.get_integral(), ref_integral)
     344        assert numpy.allclose (quantity.get_integral(), ref_integral)
    345345
    346346
     
    350350        quantity.set_vertex_values([0,1,2,3,4,5])
    351351
    352         assert allclose(quantity.vertex_values,
    353                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    354         assert allclose(quantity.centroid_values,
    355                         [1., 7./3, 11./3, 8./3]) #Centroid
    356         assert allclose(quantity.edge_values, [[1., 1.5, 0.5],
    357                                                [3., 2.5, 1.5],
    358                                                [3.5, 4.5, 3.],
    359                                                [2.5, 3.5, 2]])
     352        assert numpy.allclose(quantity.vertex_values,
     353                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     354        assert numpy.allclose(quantity.centroid_values,
     355                              [1., 7./3, 11./3, 8./3]) #Centroid
     356        assert numpy.allclose(quantity.edge_values, [[1., 1.5, 0.5],
     357                                                     [3., 2.5, 1.5],
     358                                                     [3.5, 4.5, 3.],
     359                                                     [2.5, 3.5, 2]])
    360360
    361361
     
    365365        quantity.set_vertex_values([0,20,30,50], indices = [0,2,3,5])
    366366
    367         assert allclose(quantity.vertex_values,
    368                         [[1,0,20], [1,20,4], [4,20,50], [30,1,4]])
     367        assert numpy.allclose(quantity.vertex_values,
     368                              [[1,0,20], [1,20,4], [4,20,50], [30,1,4]])
    369369
    370370
     
    376376
    377377
    378         assert allclose(quantity.vertex_values,
    379                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     378        assert numpy.allclose(quantity.vertex_values,
     379                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    380380
    381381        #Centroid
    382         assert allclose(quantity.centroid_values, [1., 7./3, 11./3, 8./3])
    383 
    384         assert allclose(quantity.edge_values, [[1., 1.5, 0.5],
    385                                                [3., 2.5, 1.5],
    386                                                [3.5, 4.5, 3.],
    387                                                [2.5, 3.5, 2]])
     382        assert numpy.allclose(quantity.centroid_values, [1., 7./3, 11./3, 8./3])
     383
     384        assert numpy.allclose(quantity.edge_values, [[1., 1.5, 0.5],
     385                                                     [3., 2.5, 1.5],
     386                                                     [3.5, 4.5, 3.],
     387                                                     [2.5, 3.5, 2]])
    388388
    389389
     
    399399
    400400        quantity.set_values([0,2,3,5], indices=[0,2,3,5])
    401         assert allclose(quantity.vertex_values,
    402                         [[0,0,2], [0,2,0], [0,2,5], [3,0,0]])
     401        assert numpy.allclose(quantity.vertex_values,
     402                              [[0,0,2], [0,2,0], [0,2,5], [3,0,0]])
    403403
    404404
     
    408408
    409409        # Indices refer to triangle numbers
    410         assert allclose(quantity.vertex_values,
    411                         [[3.14,3.14,3.14], [0,0,0],
    412                          [3.14,3.14,3.14], [0,0,0]])       
     410        assert numpy.allclose(quantity.vertex_values,
     411                              [[3.14,3.14,3.14], [0,0,0],
     412                               [3.14,3.14,3.14], [0,0,0]])       
    413413       
    414414
     
    419419        quantity.set_values(3.14, polygon=polygon)
    420420       
    421         assert allclose(quantity.vertex_values,
    422                         [[0,0,0], [0,0,0], [0,0,0],
    423                          [3.14,3.14,3.14]])               
     421        assert numpy.allclose(quantity.vertex_values,
     422                              [[0,0,0], [0,0,0], [0,0,0],
     423                               [3.14,3.14,3.14]])               
    424424
    425425
     
    429429        quantity.set_values(0.0)
    430430        quantity.set_values(3.14, location='centroids', polygon=polygon)
    431         assert allclose(quantity.vertex_values,
    432                         [[0,0,0],
    433                          [3.14,3.14,3.14],
    434                          [3.14,3.14,3.14],                         
    435                          [0,0,0]])               
     431        assert numpy.allclose(quantity.vertex_values,
     432                              [[0,0,0],
     433                               [3.14,3.14,3.14],
     434                               [3.14,3.14,3.14],                         
     435                               [0,0,0]])               
    436436
    437437
     
    441441        #print 'Here 2'
    442442        quantity.set_values(3.14, polygon=polygon)
    443         assert allclose(quantity.vertex_values,
    444                         [[0,0,0],
    445                          [3.14,3.14,3.14],
    446                          [3.14,3.14,3.14],                         
    447                          [0,0,0]])               
     443        assert numpy.allclose(quantity.vertex_values,
     444                              [[0,0,0],
     445                               [3.14,3.14,3.14],
     446                               [3.14,3.14,3.14],                         
     447                               [0,0,0]])               
    448448       
    449449
     
    478478
    479479        # Indices refer to triangle numbers here - not vertices (why?)
    480         assert allclose(quantity.vertex_values,
    481                         [[3.14,3.14,3.14], [0,0,0],
    482                          [3.14,3.14,3.14], [0,0,0]])       
     480        assert numpy.allclose(quantity.vertex_values,
     481                              [[3.14,3.14,3.14], [0,0,0],
     482                               [3.14,3.14,3.14], [0,0,0]])       
    483483       
    484484
    485485
    486486        # Now try with polygon (pick points where y>2)
    487         polygon = array([[0,2.1], [4,2.1], [4,7], [0,7]])
     487        polygon = numpy.array([[0,2.1], [4,2.1], [4,7], [0,7]])
    488488        polygon += [G.xllcorner, G.yllcorner]
    489489       
     
    491491        quantity.set_values(3.14, polygon=polygon, location='centroids')
    492492       
    493         assert allclose(quantity.vertex_values,
    494                         [[0,0,0], [0,0,0], [0,0,0],
    495                          [3.14,3.14,3.14]])               
     493        assert numpy.allclose(quantity.vertex_values,
     494                              [[0,0,0], [0,0,0], [0,0,0],
     495                               [3.14,3.14,3.14]])               
    496496
    497497
    498498        # Another polygon (pick triangle 1 and 2 (rightmost triangles)
    499         polygon = array([[2.1, 0.0], [3.5,0.1], [2,2.2], [0.2,2]])
     499        polygon = numpy.array([[2.1, 0.0], [3.5,0.1], [2,2.2], [0.2,2]])
    500500        polygon += [G.xllcorner, G.yllcorner]
    501501       
     
    503503        quantity.set_values(3.14, polygon=polygon)
    504504
    505         assert allclose(quantity.vertex_values,
    506                         [[0,0,0],
    507                          [3.14,3.14,3.14],
    508                          [3.14,3.14,3.14],                         
    509                          [0,0,0]])               
     505        assert numpy.allclose(quantity.vertex_values,
     506                              [[0,0,0],
     507                               [3.14,3.14,3.14],
     508                               [3.14,3.14,3.14],                         
     509                               [0,0,0]])               
    510510
    511511
     
    540540        answer = linear_function(quantity.domain.get_vertex_coordinates())
    541541        #print quantity.vertex_values, answer
    542         assert allclose(quantity.vertex_values.flat, answer)
     542        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    543543
    544544
     
    553553        #print vertex_attributes
    554554        quantity.set_values(vertex_attributes)
    555         assert allclose(quantity.vertex_values.flat, answer)
     555        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    556556
    557557
     
    593593                          alpha = 0)
    594594
    595         assert allclose( ref, [0,5,5] )
     595        assert numpy.allclose( ref, [0,5,5] )
    596596
    597597
     
    610610        #                    data_georef = data_georef,
    611611        #                    alpha = 0)
    612         assert allclose(quantity.vertex_values.flat, ref)
     612        assert numpy.allclose(quantity.vertex_values.ravel(), ref)
    613613
    614614
     
    621621
    622622        quantity.set_values(geospatial_data = geo, alpha = 0)
    623         assert allclose(quantity.vertex_values.flat, ref)
     623        assert numpy.allclose(quantity.vertex_values.ravel(), ref)
    624624
    625625
     
    666666        answer = linear_function(quantity.domain.get_vertex_coordinates())
    667667
    668         #print quantity.vertex_values.flat
     668        #print quantity.vertex_values.ravel()
    669669        #print answer
    670670
    671671
    672         assert allclose(quantity.vertex_values.flat, answer)
     672        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    673673
    674674
    675675        #Check that values can be set from file using default attribute
    676676        quantity.set_values(filename = ptsfile, alpha = 0)
    677         assert allclose(quantity.vertex_values.flat, answer)
     677        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    678678
    679679        #Cleanup
     
    730730        #print self.mesh4.nodes
    731731        #print inside_polygon(self.mesh4.nodes, polygon)
    732         assert allclose(inside_polygon(self.mesh4.nodes, polygon), 4)
     732        assert numpy.allclose(inside_polygon(self.mesh4.nodes, polygon), 4)
    733733
    734734        #print quantity.domain.get_vertex_coordinates()
     
    748748        answer = linear_function(points)
    749749
    750         #print quantity.vertex_values.flat
     750        #print quantity.vertex_values.ravel()
    751751        #print answer
    752752
    753753        # Check vertices in polygon have been set
    754         assert allclose(take(quantity.vertex_values.flat, indices),
    755                              answer)
     754        assert numpy.allclose(take(quantity.vertex_values.ravel(), indices),
     755                                   answer)
    756756
    757757        # Check vertices outside polygon are zero
    758758        indices = outside_polygon(quantity.domain.get_vertex_coordinates(),
    759759                                  polygon)       
    760         assert allclose(take(quantity.vertex_values.flat, indices),
    761                              0.0)       
     760        assert numpy.allclose(take(quantity.vertex_values.ravel(), indices),
     761                                   0.0)       
    762762
    763763        #Cleanup
     
    815815                            verbose=False)
    816816        answer = linear_function(quantity.domain.get_vertex_coordinates())
    817         assert allclose(quantity.vertex_values.flat, answer)
     817        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    818818
    819819
     
    821821        quantity.set_values(filename=ptsfile,
    822822                            alpha=0)
    823         assert allclose(quantity.vertex_values.flat, answer)
     823        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    824824
    825825        # Check cache
     
    866866        answer = linear_function(quantity.domain.get_vertex_coordinates())
    867867
    868         #print "quantity.vertex_values.flat", quantity.vertex_values.flat
     868        #print "quantity.vertex_values.ravel()", quantity.vertex_values.ravel()
    869869        #print "answer",answer
    870870
    871         assert allclose(quantity.vertex_values.flat, answer)
     871        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    872872
    873873
    874874        #Check that values can be set from file using default attribute
    875875        quantity.set_values(filename=txt_file, alpha=0)
    876         assert allclose(quantity.vertex_values.flat, answer)
     876        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    877877
    878878        #Cleanup
     
    910910        answer = linear_function(quantity.domain.get_vertex_coordinates())
    911911
    912         #print "quantity.vertex_values.flat", quantity.vertex_values.flat
     912        #print "quantity.vertex_values.ravel()", quantity.vertex_values.ravel()
    913913        #print "answer",answer
    914914
    915         assert allclose(quantity.vertex_values.flat, answer)
     915        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    916916
    917917
    918918        #Check that values can be set from file using default attribute
    919919        quantity.set_values(filename=txt_file, alpha=0)
    920         assert allclose(quantity.vertex_values.flat, answer)
     920        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    921921
    922922        #Cleanup
     
    957957                                      'vertices', None)
    958958        answer = linear_function(quantity.domain.get_vertex_coordinates())
    959         #print "quantity.vertex_values.flat", quantity.vertex_values.flat
     959        #print "quantity.vertex_values.ravel()", quantity.vertex_values.ravel()
    960960        #print "answer",answer
    961         assert allclose(quantity.vertex_values.flat, answer)
     961        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    962962
    963963        #Check that values can be set from file
     
    965965                            attribute_name=att, alpha=0)
    966966        answer = linear_function(quantity.domain.get_vertex_coordinates())
    967         #print "quantity.vertex_values.flat", quantity.vertex_values.flat
     967        #print "quantity.vertex_values.ravel()", quantity.vertex_values.ravel()
    968968        #print "answer",answer
    969         assert allclose(quantity.vertex_values.flat, answer)
     969        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    970970
    971971
    972972        #Check that values can be set from file using default attribute
    973973        quantity.set_values(filename=txt_file, alpha=0)
    974         assert allclose(quantity.vertex_values.flat, answer)
     974        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    975975
    976976        #Cleanup
     
    10391039                                      max_read_lines=2)
    10401040        answer = linear_function(quantity.domain.get_vertex_coordinates())
    1041         #print "quantity.vertex_values.flat", quantity.vertex_values.flat
     1041        #print "quantity.vertex_values.ravel()", quantity.vertex_values.ravel()
    10421042        #print "answer",answer
    1043         assert allclose(quantity.vertex_values.flat, answer)
     1043        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    10441044
    10451045        #Check that values can be set from file
     
    10471047                            attribute_name=att, alpha=0)
    10481048        answer = linear_function(quantity.domain.get_vertex_coordinates())
    1049         #print "quantity.vertex_values.flat", quantity.vertex_values.flat
     1049        #print "quantity.vertex_values.ravel()", quantity.vertex_values.ravel()
    10501050        #print "answer",answer
    1051         assert allclose(quantity.vertex_values.flat, answer)
     1051        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    10521052
    10531053
    10541054        #Check that values can be set from file using default attribute
    10551055        quantity.set_values(filename=txt_file, alpha=0)
    1056         assert allclose(quantity.vertex_values.flat, answer)
     1056        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    10571057
    10581058        #Cleanup
     
    11281128        answer = linear_function(quantity.domain.get_vertex_coordinates())
    11291129
    1130         assert allclose(quantity.vertex_values.flat, answer)
     1130        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    11311131
    11321132
    11331133        #Check that values can be set from file using default attribute
    11341134        quantity.set_values(filename=ptsfile, alpha=0)
    1135         assert allclose(quantity.vertex_values.flat, answer)
     1135        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    11361136
    11371137        #Cleanup
     
    12071207
    12081208
    1209         assert allclose(quantity.vertex_values.flat, answer)
     1209        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    12101210
    12111211
    12121212        #Check that values can be set from file using default attribute
    12131213        quantity.set_values(filename=ptsfile, alpha=0)
    1214         assert allclose(quantity.vertex_values.flat, answer)
     1214        assert numpy.allclose(quantity.vertex_values.ravel(), answer)
    12151215
    12161216        #Cleanup
     
    12261226        quantity1.set_vertex_values([0,1,2,3,4,5])
    12271227
    1228         assert allclose(quantity1.vertex_values,
    1229                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     1228        assert numpy.allclose(quantity1.vertex_values,
     1229                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    12301230
    12311231
    12321232        quantity2 = Quantity(self.mesh4)
    12331233        quantity2.set_values(quantity=quantity1)
    1234         assert allclose(quantity2.vertex_values,
    1235                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     1234        assert numpy.allclose(quantity2.vertex_values,
     1235                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    12361236
    12371237        quantity2.set_values(quantity = 2*quantity1)
    1238         assert allclose(quantity2.vertex_values,
    1239                         [[2,0,4], [2,4,8], [8,4,10], [6,2,8]])
     1238        assert numpy.allclose(quantity2.vertex_values,
     1239                              [[2,0,4], [2,4,8], [8,4,10], [6,2,8]])
    12401240
    12411241        quantity2.set_values(quantity = 2*quantity1 + 3)
    1242         assert allclose(quantity2.vertex_values,
    1243                         [[5,3,7], [5,7,11], [11,7,13], [9,5,11]])
     1242        assert numpy.allclose(quantity2.vertex_values,
     1243                              [[5,3,7], [5,7,11], [11,7,13], [9,5,11]])
    12441244
    12451245
    12461246        #Check detection of quantity as first orgument
    12471247        quantity2.set_values(2*quantity1 + 3)
    1248         assert allclose(quantity2.vertex_values,
    1249                         [[5,3,7], [5,7,11], [11,7,13], [9,5,11]])
     1248        assert numpy.allclose(quantity2.vertex_values,
     1249                              [[5,3,7], [5,7,11], [11,7,13], [9,5,11]])
    12501250
    12511251
     
    12621262        polygon = [[1.0, 1.0], [4.0, 1.0],
    12631263                   [4.0, 4.0], [1.0, 4.0]]
    1264         assert allclose(inside_polygon(self.mesh4.nodes, polygon), 4)                   
     1264        assert numpy.allclose(inside_polygon(self.mesh4.nodes, polygon), 4)                   
    12651265       
    12661266        quantity1 = Quantity(self.mesh4)
    12671267        quantity1.set_vertex_values([0,1,2,3,4,5])
    12681268
    1269         assert allclose(quantity1.vertex_values,
    1270                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     1269        assert numpy.allclose(quantity1.vertex_values,
     1270                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    12711271
    12721272
     
    12761276                             
    12771277        msg = 'Only node #4(e) at (2,2) should have values applied '
    1278         assert allclose(quantity2.vertex_values,
    1279                         [[0,0,0], [0,0,4], [4,0,0], [0,0,4]]), msg       
    1280                         #bac,     bce,     ecf,     dbe
     1278        assert numpy.allclose(quantity2.vertex_values,
     1279                              [[0,0,0], [0,0,4], [4,0,0], [0,0,4]]), msg       
     1280                              #bac,     bce,     ecf,     dbe
    12811281                       
    12821282
     
    12871287        quantity1.set_vertex_values([0,1,2,3,4,5])
    12881288
    1289         assert allclose(quantity1.vertex_values,
    1290                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     1289        assert numpy.allclose(quantity1.vertex_values,
     1290                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    12911291
    12921292
     
    13041304        # Negation
    13051305        Q = -quantity1
    1306         assert allclose(Q.vertex_values, -quantity1.vertex_values)
    1307         assert allclose(Q.centroid_values, -quantity1.centroid_values)
    1308         assert allclose(Q.edge_values, -quantity1.edge_values)
     1306        assert numpy.allclose(Q.vertex_values, -quantity1.vertex_values)
     1307        assert numpy.allclose(Q.centroid_values, -quantity1.centroid_values)
     1308        assert numpy.allclose(Q.edge_values, -quantity1.edge_values)
    13091309
    13101310        # Addition
    13111311        Q = quantity1 + 7
    1312         assert allclose(Q.vertex_values, quantity1.vertex_values + 7)
    1313         assert allclose(Q.centroid_values, quantity1.centroid_values + 7)
    1314         assert allclose(Q.edge_values, quantity1.edge_values + 7)
     1312        assert numpy.allclose(Q.vertex_values, quantity1.vertex_values + 7)
     1313        assert numpy.allclose(Q.centroid_values, quantity1.centroid_values + 7)
     1314        assert numpy.allclose(Q.edge_values, quantity1.edge_values + 7)
    13151315
    13161316        Q = 7 + quantity1
    1317         assert allclose(Q.vertex_values, quantity1.vertex_values + 7)
    1318         assert allclose(Q.centroid_values, quantity1.centroid_values + 7)
    1319         assert allclose(Q.edge_values, quantity1.edge_values + 7)
     1317        assert numpy.allclose(Q.vertex_values, quantity1.vertex_values + 7)
     1318        assert numpy.allclose(Q.centroid_values, quantity1.centroid_values + 7)
     1319        assert numpy.allclose(Q.edge_values, quantity1.edge_values + 7)
    13201320
    13211321        Q = quantity1 + quantity2
    1322         assert allclose(Q.vertex_values,
    1323                         quantity1.vertex_values + quantity2.vertex_values)
    1324         assert allclose(Q.centroid_values,
    1325                         quantity1.centroid_values + quantity2.centroid_values)
    1326         assert allclose(Q.edge_values,
    1327                         quantity1.edge_values + quantity2.edge_values)
     1322        assert numpy.allclose(Q.vertex_values,
     1323                              quantity1.vertex_values + quantity2.vertex_values)
     1324        assert numpy.allclose(Q.centroid_values,
     1325                              quantity1.centroid_values + quantity2.centroid_values)
     1326        assert numpy.allclose(Q.edge_values,
     1327                              quantity1.edge_values + quantity2.edge_values)
    13281328
    13291329
    13301330        Q = quantity1 + quantity2 - 3
    1331         assert allclose(Q.vertex_values,
    1332                         quantity1.vertex_values + quantity2.vertex_values - 3)
     1331        assert numpy.allclose(Q.vertex_values,
     1332                              quantity1.vertex_values + quantity2.vertex_values - 3)
    13331333
    13341334        Q = quantity1 - quantity2
    1335         assert allclose(Q.vertex_values,
    1336                         quantity1.vertex_values - quantity2.vertex_values)
     1335        assert numpy.allclose(Q.vertex_values,
     1336                              quantity1.vertex_values - quantity2.vertex_values)
    13371337
    13381338        #Scaling
    13391339        Q = quantity1*3
    1340         assert allclose(Q.vertex_values, quantity1.vertex_values*3)
    1341         assert allclose(Q.centroid_values, quantity1.centroid_values*3)
    1342         assert allclose(Q.edge_values, quantity1.edge_values*3)
     1340        assert numpy.allclose(Q.vertex_values, quantity1.vertex_values*3)
     1341        assert numpy.allclose(Q.centroid_values, quantity1.centroid_values*3)
     1342        assert numpy.allclose(Q.edge_values, quantity1.edge_values*3)
    13431343        Q = 3*quantity1
    1344         assert allclose(Q.vertex_values, quantity1.vertex_values*3)
     1344        assert numpy.allclose(Q.vertex_values, quantity1.vertex_values*3)
    13451345
    13461346        #Multiplication
     
    13511351        #print quantity2.centroid_values
    13521352
    1353         assert allclose(Q.vertex_values,
    1354                         quantity1.vertex_values * quantity2.vertex_values)
     1353        assert numpy.allclose(Q.vertex_values,
     1354                              quantity1.vertex_values * quantity2.vertex_values)
    13551355
    13561356        #Linear combinations
    13571357        Q = 4*quantity1 + 2
    1358         assert allclose(Q.vertex_values,
    1359                         4*quantity1.vertex_values + 2)
     1358        assert numpy.allclose(Q.vertex_values,
     1359                              4*quantity1.vertex_values + 2)
    13601360
    13611361        Q = quantity1*quantity2 + 2
    1362         assert allclose(Q.vertex_values,
    1363                         quantity1.vertex_values * quantity2.vertex_values + 2)
     1362        assert numpy.allclose(Q.vertex_values,
     1363                              quantity1.vertex_values * quantity2.vertex_values + 2)
    13641364
    13651365        Q = quantity1*quantity2 + quantity3
    1366         assert allclose(Q.vertex_values,
    1367                         quantity1.vertex_values * quantity2.vertex_values +
    1368                         quantity3.vertex_values)
     1366        assert numpy.allclose(Q.vertex_values,
     1367                              quantity1.vertex_values * quantity2.vertex_values +
     1368                              quantity3.vertex_values)
    13691369        Q = quantity1*quantity2 + 3*quantity3
    1370         assert allclose(Q.vertex_values,
    1371                         quantity1.vertex_values * quantity2.vertex_values +
    1372                         3*quantity3.vertex_values)
     1370        assert numpy.allclose(Q.vertex_values,
     1371                              quantity1.vertex_values * quantity2.vertex_values +
     1372                             3*quantity3.vertex_values)
    13731373        Q = quantity1*quantity2 + 3*quantity3 + 5.0
    1374         assert allclose(Q.vertex_values,
    1375                         quantity1.vertex_values * quantity2.vertex_values +
    1376                         3*quantity3.vertex_values + 5)
     1374        assert numpy.allclose(Q.vertex_values,
     1375                              quantity1.vertex_values * quantity2.vertex_values +
     1376                              3*quantity3.vertex_values + 5)
    13771377
    13781378        Q = quantity1*quantity2 - quantity3
    1379         assert allclose(Q.vertex_values,
    1380                         quantity1.vertex_values * quantity2.vertex_values -
    1381                         quantity3.vertex_values)
     1379        assert numpy.allclose(Q.vertex_values,
     1380                              quantity1.vertex_values * quantity2.vertex_values -
     1381                              quantity3.vertex_values)
    13821382        Q = 1.5*quantity1*quantity2 - 3*quantity3 + 5.0
    1383         assert allclose(Q.vertex_values,
    1384                         1.5*quantity1.vertex_values * quantity2.vertex_values -
    1385                         3*quantity3.vertex_values + 5)
     1383        assert numpy.allclose(Q.vertex_values,
     1384                              1.5*quantity1.vertex_values * quantity2.vertex_values -
     1385                              3*quantity3.vertex_values + 5)
    13861386
    13871387        #Try combining quantities and arrays and scalars
    1388         Q = 1.5*quantity1*quantity2.vertex_values -\
     1388        Q = 1.5*quantity1*quantity2.vertex_values - \
    13891389            3*quantity3.vertex_values + 5.0
    1390         assert allclose(Q.vertex_values,
    1391                         1.5*quantity1.vertex_values * quantity2.vertex_values -
    1392                         3*quantity3.vertex_values + 5)
     1390        assert numpy.allclose(Q.vertex_values,
     1391                              1.5*quantity1.vertex_values * quantity2.vertex_values -
     1392                              3*quantity3.vertex_values + 5)
    13931393
    13941394
    13951395        #Powers
    13961396        Q = quantity1**2
    1397         assert allclose(Q.vertex_values, quantity1.vertex_values**2)
     1397        assert numpy.allclose(Q.vertex_values, quantity1.vertex_values**2)
    13981398
    13991399        Q = quantity1**2 +quantity2**2
    1400         assert allclose(Q.vertex_values,
    1401                         quantity1.vertex_values**2 + \
    1402                         quantity2.vertex_values**2)
     1400        assert numpy.allclose(Q.vertex_values,
     1401                              quantity1.vertex_values**2 +
     1402                              quantity2.vertex_values**2)
    14031403
    14041404        Q = (quantity1**2 +quantity2**2)**0.5
    1405         assert allclose(Q.vertex_values,
    1406                         (quantity1.vertex_values**2 + \
    1407                         quantity2.vertex_values**2)**0.5)
     1405        assert numpy.allclose(Q.vertex_values,
     1406                              (quantity1.vertex_values**2 +
     1407                               quantity2.vertex_values**2)**0.5)
    14081408
    14091409
     
    14311431        #The central triangle (1)
    14321432        #(using standard gradient based on neigbours controid values)
    1433         assert allclose(a[1], 2.0)
    1434         assert allclose(b[1], 0.0)
     1433        assert numpy.allclose(a[1], 2.0)
     1434        assert numpy.allclose(b[1], 0.0)
    14351435
    14361436
     
    14381438        #q0 = q1 + a*(x0-x1) + b*(y0-y1)  <=>
    14391439        #2  = 4  + a*(-2/3)  + b*(-2/3)
    1440         assert allclose(a[0] + b[0], 3)
     1440        assert numpy.allclose(a[0] + b[0], 3)
    14411441        #From orthogonality (a*(y0-y1) + b*(x0-x1) == 0)
    1442         assert allclose(a[0] - b[0], 0)
     1442        assert numpy.allclose(a[0] - b[0], 0)
    14431443
    14441444
     
    14461446        #q2 = q1 + a*(x2-x1) + b*(y2-y1)  <=>
    14471447        #6  = 4  + a*(4/3)  + b*(-2/3)
    1448         assert allclose(2*a[2] - b[2], 3)
     1448        assert numpy.allclose(2*a[2] - b[2], 3)
    14491449        #From orthogonality (a*(y1-y2) + b*(x2-x1) == 0)
    1450         assert allclose(a[2] + 2*b[2], 0)
     1450        assert numpy.allclose(a[2] + 2*b[2], 0)
    14511451
    14521452
     
    14541454        #q3 = q1 + a*(x3-x1) + b*(y3-y1)  <=>
    14551455        #2  = 4  + a*(-2/3)  + b*(4/3)
    1456         assert allclose(a[3] - 2*b[3], 3)
     1456        assert numpy.allclose(a[3] - 2*b[3], 3)
    14571457        #From orthogonality (a*(y1-y3) + b*(x3-x1) == 0)
    1458         assert allclose(2*a[3] + b[3], 0)
     1458        assert numpy.allclose(2*a[3] + b[3], 0)
    14591459
    14601460
     
    14641464
    14651465        #Apply q(x,y) = qc + a*(x-xc) + b*(y-yc)
    1466         assert allclose(quantity.vertex_values[0,:], [3., 0.,  3.])
    1467         assert allclose(quantity.vertex_values[1,:], [4./3, 16./3,  16./3])
     1466        assert numpy.allclose(quantity.vertex_values[0,:], [3., 0.,  3.])
     1467        assert numpy.allclose(quantity.vertex_values[1,:], [4./3, 16./3,  16./3])
    14681468
    14691469
    14701470        #a = 1.2, b=-0.6
    14711471        #q(4,0) = 6 + a*(4 - 8/3) + b*(-2/3)
    1472         assert allclose(quantity.vertex_values[2,2], 8)
     1472        assert numpy.allclose(quantity.vertex_values[2,2], 8)
    14731473
    14741474    def test_get_gradients(self):
     
    14891489        #The central triangle (1)
    14901490        #(using standard gradient based on neigbours controid values)
    1491         assert allclose(a[1], 2.0)
    1492         assert allclose(b[1], 0.0)
     1491        assert numpy.allclose(a[1], 2.0)
     1492        assert numpy.allclose(b[1], 0.0)
    14931493
    14941494
     
    14961496        #q0 = q1 + a*(x0-x1) + b*(y0-y1)  <=>
    14971497        #2  = 4  + a*(-2/3)  + b*(-2/3)
    1498         assert allclose(a[0] + b[0], 3)
     1498        assert numpy.allclose(a[0] + b[0], 3)
    14991499        #From orthogonality (a*(y0-y1) + b*(x0-x1) == 0)
    1500         assert allclose(a[0] - b[0], 0)
     1500        assert numpy.allclose(a[0] - b[0], 0)
    15011501
    15021502
     
    15041504        #q2 = q1 + a*(x2-x1) + b*(y2-y1)  <=>
    15051505        #6  = 4  + a*(4/3)  + b*(-2/3)
    1506         assert allclose(2*a[2] - b[2], 3)
     1506        assert numpy.allclose(2*a[2] - b[2], 3)
    15071507        #From orthogonality (a*(y1-y2) + b*(x2-x1) == 0)
    1508         assert allclose(a[2] + 2*b[2], 0)
     1508        assert numpy.allclose(a[2] + 2*b[2], 0)
    15091509
    15101510
     
    15121512        #q3 = q1 + a*(x3-x1) + b*(y3-y1)  <=>
    15131513        #2  = 4  + a*(-2/3)  + b*(4/3)
    1514         assert allclose(a[3] - 2*b[3], 3)
     1514        assert numpy.allclose(a[3] - 2*b[3], 3)
    15151515        #From orthogonality (a*(y1-y3) + b*(x3-x1) == 0)
    1516         assert allclose(2*a[3] + b[3], 0)
     1516        assert numpy.allclose(2*a[3] + b[3], 0)
    15171517
    15181518
     
    15321532        #print a, b
    15331533
    1534         assert allclose(a[1], 3.0)
    1535         assert allclose(b[1], 1.0)
     1534        assert numpy.allclose(a[1], 3.0)
     1535        assert numpy.allclose(b[1], 1.0)
    15361536
    15371537        #Work out the others
     
    15401540
    15411541        #print quantity.vertex_values
    1542         assert allclose(quantity.vertex_values[1,0], 2.0)
    1543         assert allclose(quantity.vertex_values[1,1], 6.0)
    1544         assert allclose(quantity.vertex_values[1,2], 8.0)
     1542        assert numpy.allclose(quantity.vertex_values[1,0], 2.0)
     1543        assert numpy.allclose(quantity.vertex_values[1,1], 6.0)
     1544        assert numpy.allclose(quantity.vertex_values[1,2], 8.0)
    15451545
    15461546
     
    15501550
    15511551        #Set up for a gradient of (3,1), f(x) = 3x+y
    1552         c_values = array([2.0+2.0/3, 4.0+4.0/3, 8.0+2.0/3, 2.0+8.0/3])
    1553         d_values = array([1.0, 2.0, 3.0, 4.0])
     1552        c_values = numpy.array([2.0+2.0/3, 4.0+4.0/3, 8.0+2.0/3, 2.0+8.0/3])
     1553        d_values = numpy.array([1.0, 2.0, 3.0, 4.0])
    15541554        quantity.set_values(c_values, location = 'centroids')
    15551555
     
    15581558
    15591559        #print quantity.vertex_values
    1560         assert allclose(quantity.centroid_values, quantity.centroid_backup_values)
     1560        assert numpy.allclose(quantity.centroid_values, quantity.centroid_backup_values)
    15611561
    15621562
     
    15741574        #Test centroids
    15751575        quantity.set_values([1.,2.,3.,4.], location = 'centroids')
    1576         assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
     1576        assert numpy.allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
    15771577
    15781578        #Extrapolate
     
    15811581        #Check that gradient is zero
    15821582        a,b = quantity.get_gradients()
    1583         assert allclose(a, [0,0,0,0])
    1584         assert allclose(b, [0,0,0,0])
     1583        assert numpy.allclose(a, [0,0,0,0])
     1584        assert numpy.allclose(b, [0,0,0,0])
    15851585
    15861586        #Check vertices but not edge values
    1587         assert allclose(quantity.vertex_values,
    1588                         [[1,1,1], [2,2,2], [3,3,3], [4, 4, 4]])
     1587        assert numpy.allclose(quantity.vertex_values,
     1588                              [[1,1,1], [2,2,2], [3,3,3], [4, 4, 4]])
    15891589
    15901590
     
    16141614
    16151615        #Assert that quantities are conserved
    1616         from Numeric import sum
    16171616        for k in range(quantity.centroid_values.shape[0]):
    1618             assert allclose (quantity.centroid_values[k],
    1619                              sum(quantity.vertex_values[k,:])/3)
     1617            assert numpy.allclose (quantity.centroid_values[k],
     1618                                   numpy.sum(quantity.vertex_values[k,:])/3)
    16201619
    16211620
     
    16461645
    16471646        #Assert that quantities are conserved
    1648         from Numeric import sum
    16491647        for k in range(quantity.centroid_values.shape[0]):
    1650             assert allclose (quantity.centroid_values[k],
    1651                              sum(quantity.vertex_values[k,:])/3)
     1648            assert numpy.allclose (quantity.centroid_values[k],
     1649                                   numpy.sum(quantity.vertex_values[k,:])/3)
    16521650
    16531651
     
    16761674
    16771675        #Assert that quantities are conserved
    1678         from Numeric import sum
    16791676        for k in range(quantity.centroid_values.shape[0]):
    1680             assert allclose (quantity.centroid_values[k],
    1681                              sum(quantity.vertex_values[k,:])/3)
     1677            assert numpy.allclose (quantity.centroid_values[k],
     1678                                   numpy.sum(quantity.vertex_values[k,:])/3)
    16821679
    16831680
     
    17051702
    17061703        #Assert that quantities are conserved
    1707         from Numeric import sum
    17081704        for k in range(quantity.centroid_values.shape[0]):
    1709             assert allclose (quantity.centroid_values[k],
    1710                              sum(quantity.vertex_values[k,:])/3)
     1705            assert numpy.allclose (quantity.centroid_values[k],
     1706                                   numpy.sum(quantity.vertex_values[k,:])/3)
    17111707
    17121708    def test_limiter2(self):
     
    17181714        #Test centroids
    17191715        quantity.set_values([2.,4.,8.,2.], location = 'centroids')
    1720         assert allclose(quantity.centroid_values, [2, 4, 8, 2]) #Centroid
     1716        assert numpy.allclose(quantity.centroid_values, [2, 4, 8, 2]) #Centroid
    17211717
    17221718
     
    17241720        quantity.extrapolate_second_order()
    17251721
    1726         assert allclose(quantity.vertex_values[1,:], [0.0, 6, 6])
     1722        assert numpy.allclose(quantity.vertex_values[1,:], [0.0, 6, 6])
    17271723
    17281724        #Limit
     
    17311727        # limited value for beta_w = 0.9
    17321728       
    1733         assert allclose(quantity.vertex_values[1,:], [2.2, 4.9, 4.9])
     1729        assert numpy.allclose(quantity.vertex_values[1,:], [2.2, 4.9, 4.9])
    17341730        # limited values for beta_w = 0.5
    1735         #assert allclose(quantity.vertex_values[1,:], [3.0, 4.5, 4.5])
     1731        #assert numpy.allclose(quantity.vertex_values[1,:], [3.0, 4.5, 4.5])
    17361732
    17371733
    17381734        #Assert that quantities are conserved
    1739         from Numeric import sum
    17401735        for k in range(quantity.centroid_values.shape[0]):
    1741             assert allclose (quantity.centroid_values[k],
    1742                              sum(quantity.vertex_values[k,:])/3)
     1736            assert numpy.allclose (quantity.centroid_values[k],
     1737                                   numpy.sum(quantity.vertex_values[k,:])/3)
    17431738
    17441739
     
    17511746        #Test centroids
    17521747        quantity.set_values([1.,2.,3.,4.], location = 'centroids')
    1753         assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
     1748        assert numpy.allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
    17541749
    17551750
     
    17601755        #quantity.interpolate_from_vertices_to_edges()
    17611756
    1762         assert allclose(quantity.vertex_values,
    1763                         [[1,1,1], [2,2,2], [3,3,3], [4, 4, 4]])
    1764         assert allclose(quantity.edge_values, [[1,1,1], [2,2,2],
    1765                                                [3,3,3], [4, 4, 4]])
     1757        assert numpy.allclose(quantity.vertex_values,
     1758                              [[1,1,1], [2,2,2], [3,3,3], [4, 4, 4]])
     1759        assert numpy.allclose(quantity.edge_values, [[1,1,1], [2,2,2],
     1760                                                     [3,3,3], [4, 4, 4]])
    17661761
    17671762
     
    17691764        quantity = Quantity(self.mesh4)
    17701765
    1771         quantity.vertex_values = array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]],Float)
     1766        quantity.vertex_values = numpy.array([[1,0,2], [1,2,4], [4,2,5], [3,1,4]], numpy.float)
    17721767
    17731768        quantity.interpolate_from_vertices_to_edges()
    17741769
    1775         assert allclose(quantity.edge_values, [[1., 1.5, 0.5],
    1776                                                [3., 2.5, 1.5],
    1777                                                [3.5, 4.5, 3.],
    1778                                                [2.5, 3.5, 2]])
     1770        assert numpy.allclose(quantity.edge_values, [[1., 1.5, 0.5],
     1771                                                     [3., 2.5, 1.5],
     1772                                                     [3.5, 4.5, 3.],
     1773                                                     [2.5, 3.5, 2]])
    17791774
    17801775
     
    17821777        quantity = Quantity(self.mesh4)
    17831778
    1784         quantity.edge_values = array([[1., 1.5, 0.5],
    1785                                 [3., 2.5, 1.5],
    1786                                 [3.5, 4.5, 3.],
    1787                                 [2.5, 3.5, 2]],Float)
     1779        quantity.edge_values = numpy.array([[1., 1.5, 0.5],
     1780                                            [3., 2.5, 1.5],
     1781                                            [3.5, 4.5, 3.],
     1782                                            [2.5, 3.5, 2]], numpy.float)
    17881783
    17891784        quantity.interpolate_from_edges_to_vertices()
    17901785
    1791         assert allclose(quantity.vertex_values,
    1792                         [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
     1786        assert numpy.allclose(quantity.vertex_values,
     1787                              [[1,0,2], [1,2,4], [4,2,5], [3,1,4]])
    17931788
    17941789
     
    17991794        #Test centroids
    18001795        quantity.set_values([2.,4.,8.,2.], location = 'centroids')
    1801         assert allclose(quantity.centroid_values, [2, 4, 8, 2]) #Centroid
     1796        assert numpy.allclose(quantity.centroid_values, [2, 4, 8, 2]) #Centroid
    18021797
    18031798
     
    18051800        quantity.extrapolate_second_order()
    18061801
    1807         assert allclose(quantity.vertex_values[1,:], [0.0, 6, 6])
     1802        assert numpy.allclose(quantity.vertex_values[1,:], [0.0, 6, 6])
    18081803
    18091804
     
    18131808        #Test centroids
    18141809        quantity.set_values([1.,2.,3.,4.], location = 'centroids')
    1815         assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
     1810        assert numpy.allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
    18161811
    18171812        #Set explicit_update
    1818         quantity.explicit_update = array( [1.,1.,1.,1.] )
     1813        quantity.explicit_update = numpy.array( [1.,1.,1.,1.] )
    18191814
    18201815        #Update with given timestep
    18211816        quantity.update(0.1)
    18221817
    1823         x = array([1, 2, 3, 4]) + array( [.1,.1,.1,.1] )
    1824         assert allclose( quantity.centroid_values, x)
     1818        x = numpy.array([1, 2, 3, 4]) + numpy.array( [.1,.1,.1,.1] )
     1819        assert numpy.allclose( quantity.centroid_values, x)
    18251820
    18261821    def test_update_semi_implicit(self):
     
    18291824        #Test centroids
    18301825        quantity.set_values([1.,2.,3.,4.], location = 'centroids')
    1831         assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
     1826        assert numpy.allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
    18321827
    18331828        #Set semi implicit update
    1834         quantity.semi_implicit_update = array([1.,1.,1.,1.])
     1829        quantity.semi_implicit_update = numpy.array([1.,1.,1.,1.])
    18351830
    18361831        #Update with given timestep
     
    18381833        quantity.update(timestep)
    18391834
    1840         sem = array([1.,1.,1.,1.])/array([1, 2, 3, 4])
    1841         denom = ones(4, Float)-timestep*sem
    1842 
    1843         x = array([1, 2, 3, 4])/denom
    1844         assert allclose( quantity.centroid_values, x)
     1835        sem = numpy.array([1.,1.,1.,1.])/numpy.array([1, 2, 3, 4])
     1836        denom = numpy.ones(4, numpy.float)-timestep*sem
     1837
     1838        x = numpy.array([1, 2, 3, 4])/denom
     1839        assert numpy.allclose( quantity.centroid_values, x)
    18451840
    18461841
     
    18501845        #Test centroids
    18511846        quantity.set_values([1.,2.,3.,4.], location = 'centroids')
    1852         assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
     1847        assert numpy.allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid
    18531848
    18541849        #Set explicit_update
    1855         quantity.explicit_update = array( [4.,3.,2.,1.] )
     1850        quantity.explicit_update = numpy.array( [4.,3.,2.,1.] )
    18561851
    18571852        #Set semi implicit update
    1858         quantity.semi_implicit_update = array( [1.,1.,1.,1.] )
     1853        quantity.semi_implicit_update = numpy.array( [1.,1.,1.,1.] )
    18591854
    18601855        #Update with given timestep
     
    18621857        quantity.update(0.1)
    18631858
    1864         sem = array([1.,1.,1.,1.])/array([1, 2, 3, 4])
    1865         denom = ones(4, Float)-timestep*sem
    1866 
    1867         x = array([1., 2., 3., 4.])
     1859        sem = numpy.array([1.,1.,1.,1.])/numpy.array([1, 2, 3, 4])
     1860        denom = numpy.ones(4, numpy.float)-timestep*sem
     1861
     1862        x = numpy.array([1., 2., 3., 4.])
    18681863        x /= denom
    1869         x += timestep*array( [4.0, 3.0, 2.0, 1.0] )
    1870 
    1871         assert allclose( quantity.centroid_values, x)
     1864        x += timestep*numpy.array( [4.0, 3.0, 2.0, 1.0] )
     1865
     1866        assert numpy.allclose( quantity.centroid_values, x)
    18721867
    18731868
     
    18791874        from mesh_factory import rectangular
    18801875        from shallow_water import Domain, Transmissive_boundary
    1881         from Numeric import zeros, Float
    18821876        from anuga.utilities.numerical_tools import mean
    18831877
     
    19061900
    19071901        bed = domain.quantities['elevation'].vertex_values
    1908         stage = zeros(bed.shape, Float)
     1902        stage = numpy.zeros(bed.shape, numpy.float)
    19091903
    19101904        h = 0.03
     
    19291923
    19301924        #First four points
    1931         assert allclose(A[0], (Q[0,2] + Q[1,1])/2)
    1932         assert allclose(A[1], (Q[1,0] + Q[3,1] + Q[2,2])/3)
    1933         assert allclose(A[2], Q[3,0])
    1934         assert allclose(A[3], (Q[0,0] + Q[5,1] + Q[4,2])/3)
     1925        assert numpy.allclose(A[0], (Q[0,2] + Q[1,1])/2)
     1926        assert numpy.allclose(A[1], (Q[1,0] + Q[3,1] + Q[2,2])/3)
     1927        assert numpy.allclose(A[2], Q[3,0])
     1928        assert numpy.allclose(A[3], (Q[0,0] + Q[5,1] + Q[4,2])/3)
    19351929
    19361930        #Center point
    1937         assert allclose(A[4], (Q[0,1] + Q[1,2] + Q[2,0] +\
    1938                                Q[5,0] + Q[6,2] + Q[7,1])/6)
     1931        assert numpy.allclose(A[4], (Q[0,1] + Q[1,2] + Q[2,0] +\
     1932                                     Q[5,0] + Q[6,2] + Q[7,1])/6)
    19391933
    19401934
    19411935        #Check V
    1942         assert allclose(V[0,:], [3,4,0])
    1943         assert allclose(V[1,:], [1,0,4])
    1944         assert allclose(V[2,:], [4,5,1])
    1945         assert allclose(V[3,:], [2,1,5])
    1946         assert allclose(V[4,:], [6,7,3])
    1947         assert allclose(V[5,:], [4,3,7])
    1948         assert allclose(V[6,:], [7,8,4])
    1949         assert allclose(V[7,:], [5,4,8])
     1936        assert numpy.allclose(V[0,:], [3,4,0])
     1937        assert numpy.allclose(V[1,:], [1,0,4])
     1938        assert numpy.allclose(V[2,:], [4,5,1])
     1939        assert numpy.allclose(V[3,:], [2,1,5])
     1940        assert numpy.allclose(V[4,:], [6,7,3])
     1941        assert numpy.allclose(V[5,:], [4,3,7])
     1942        assert numpy.allclose(V[6,:], [7,8,4])
     1943        assert numpy.allclose(V[7,:], [5,4,8])
    19501944
    19511945        #Get smoothed stage with XY
    19521946        X, Y, A1, V1 = stage.get_vertex_values(xy=True, smooth=True)
    19531947
    1954         assert allclose(A, A1)
    1955         assert allclose(V, V1)
     1948        assert numpy.allclose(A, A1)
     1949        assert numpy.allclose(V, V1)
    19561950
    19571951        #Check XY
    1958         assert allclose(X[4], 0.5)
    1959         assert allclose(Y[4], 0.5)
    1960 
    1961         assert allclose(X[7], 1.0)
    1962         assert allclose(Y[7], 0.5)
     1952        assert numpy.allclose(X[4], 0.5)
     1953        assert numpy.allclose(Y[4], 0.5)
     1954
     1955        assert numpy.allclose(X[7], 1.0)
     1956        assert numpy.allclose(Y[7], 0.5)
    19631957
    19641958
     
    19691963        from mesh_factory import rectangular
    19701964        from shallow_water import Domain, Transmissive_boundary
    1971         from Numeric import zeros, Float
    19721965        from anuga.utilities.numerical_tools import mean
    19731966
     
    19911984
    19921985        bed = domain.quantities['elevation'].vertex_values
    1993         stage = zeros(bed.shape, Float)
     1986        stage = numpy.zeros(bed.shape, numpy.float)
    19941987
    19951988        h = 0.03
     
    20051998        stage = domain.quantities['stage']
    20061999        A, V = stage.get_vertex_values(xy=False, smooth=False)
    2007         Q = stage.vertex_values.flat
     2000        Q = stage.vertex_values.ravel()
    20082001
    20092002        for k in range(8):
    2010             assert allclose(A[k], Q[k])
     2003            assert numpy.allclose(A[k], Q[k])
    20112004
    20122005
     
    20212014
    20222015
    2023         assert allclose(A, A1)
    2024         assert allclose(V, V1)
     2016        assert numpy.allclose(A, A1)
     2017        assert numpy.allclose(V, V1)
    20252018
    20262019        #Check XY
    2027         assert allclose(X[1], 0.5)
    2028         assert allclose(Y[1], 0.5)
    2029         assert allclose(X[4], 0.0)
    2030         assert allclose(Y[4], 0.0)
    2031         assert allclose(X[12], 1.0)
    2032         assert allclose(Y[12], 0.0)
     2020        assert numpy.allclose(X[1], 0.5)
     2021        assert numpy.allclose(Y[1], 0.5)
     2022        assert numpy.allclose(X[4], 0.0)
     2023        assert numpy.allclose(Y[4], 0.0)
     2024        assert numpy.allclose(X[12], 1.0)
     2025        assert numpy.allclose(Y[12], 0.0)
    20332026
    20342027
     
    20382031        from mesh_factory import rectangular
    20392032        from shallow_water import Domain
    2040         from Numeric import zeros, Float
    20412033
    20422034        #Create basic mesh
     
    20542046        #print "quantity.centroid_values",quantity.centroid_values
    20552047
    2056         assert allclose(quantity.centroid_values, [1,7])
     2048        assert numpy.allclose(quantity.centroid_values, [1,7])
    20572049
    20582050        quantity.set_array_values([15,20,25], indices = indices)
    2059         assert allclose(quantity.centroid_values, [1,20])
     2051        assert numpy.allclose(quantity.centroid_values, [1,20])
    20602052
    20612053        quantity.set_array_values([15,20,25], indices = indices)
    2062         assert allclose(quantity.centroid_values, [1,20])
     2054        assert numpy.allclose(quantity.centroid_values, [1,20])
    20632055
    20642056    def test_setting_some_vertex_values(self):
     
    20682060        from mesh_factory import rectangular
    20692061        from shallow_water import Domain
    2070         from Numeric import zeros, Float
    20712062
    20722063        #Create basic mesh
     
    20872078                            indices = indices)
    20882079        #print "quantity.centroid_values",quantity.centroid_values
    2089         assert allclose(quantity.centroid_values, [1,7,3,4,5,6])
     2080        assert numpy.allclose(quantity.centroid_values, [1,7,3,4,5,6])
    20902081       
    20912082        value = [7]
     
    20952086                            indices = indices)
    20962087        #print "quantity.centroid_values",quantity.centroid_values
    2097         assert allclose(quantity.centroid_values, [1,7,3,4,5,6])
     2088        assert numpy.allclose(quantity.centroid_values, [1,7,3,4,5,6])
    20982089
    20992090        value = [[15,20,25]]
    21002091        quantity.set_values(value, indices = indices)
    21012092        #print "1 quantity.vertex_values",quantity.vertex_values
    2102         assert allclose(quantity.vertex_values[1], value[0])
     2093        assert numpy.allclose(quantity.vertex_values[1], value[0])
    21032094
    21042095
     
    21072098        quantity.set_values(values, indices = [0,1,5], location = 'centroids')
    21082099        #print "2 quantity.vertex_values",quantity.vertex_values
    2109         assert allclose(quantity.vertex_values[0], [10,10,10])
    2110         assert allclose(quantity.vertex_values[5], [50,50,50])
     2100        assert numpy.allclose(quantity.vertex_values[0], [10,10,10])
     2101        assert numpy.allclose(quantity.vertex_values[5], [50,50,50])
    21112102        #quantity.interpolate()
    21122103        #print "quantity.centroid_values",quantity.centroid_values
    2113         assert allclose(quantity.centroid_values, [10,100,3,4,5,50])
     2104        assert numpy.allclose(quantity.centroid_values, [10,100,3,4,5,50])
    21142105
    21152106
     
    21212112        quantity.set_values(values, indices = [0,1,5])
    21222113        #print "quantity.vertex_values",quantity.vertex_values
    2123         assert allclose(quantity.vertex_values[0], [1,50,10])
    2124         assert allclose(quantity.vertex_values[5], [6,6,6])
    2125         assert allclose(quantity.vertex_values[1], [100,10,50])
     2114        assert numpy.allclose(quantity.vertex_values[0], [1,50,10])
     2115        assert numpy.allclose(quantity.vertex_values[5], [6,6,6])
     2116        assert numpy.allclose(quantity.vertex_values[1], [100,10,50])
    21262117
    21272118        quantity = Quantity(domain,[[1,1,1],[2,2,2],[3,3,3],
     
    21302121        quantity.set_values(values, indices = [3,3,5])
    21312122        quantity.interpolate()
    2132         assert allclose(quantity.centroid_values, [1,2,3,400,5,999])
     2123        assert numpy.allclose(quantity.centroid_values, [1,2,3,400,5,999])
    21332124
    21342125        values = [[1,1,1],[2,2,2],[3,3,3],
     
    21422133        quantity.set_values(values)
    21432134        #print "1 quantity.vertex_values",quantity.vertex_values
    2144         assert allclose(quantity.vertex_values,[[ 4.,  5.,  0.],
    2145                                                 [ 1.,  0.,  5.],
    2146                                                 [ 5.,  6.,  1.],
    2147                                                 [ 2.,  1.,  6.],
    2148                                                 [ 6.,  7.,  2.],
    2149                                                 [ 3.,  2.,  7.]])
     2135        assert numpy.allclose(quantity.vertex_values,[[ 4.,  5.,  0.],
     2136                                                      [ 1.,  0.,  5.],
     2137                                                      [ 5.,  6.,  1.],
     2138                                                      [ 2.,  1.,  6.],
     2139                                                      [ 6.,  7.,  2.],
     2140                                                      [ 3.,  2.,  7.]])
    21502141
    21512142    def test_setting_unique_vertex_values(self):
     
    21552146        from mesh_factory import rectangular
    21562147        from shallow_water import Domain
    2157         from Numeric import zeros, Float
    21582148
    21592149        #Create basic mesh
     
    21712161                            indices = indices)
    21722162        #print "quantity.centroid_values",quantity.centroid_values
    2173         assert allclose(quantity.vertex_values[0], [0,7,0])
    2174         assert allclose(quantity.vertex_values[1], [7,1,7])
    2175         assert allclose(quantity.vertex_values[2], [7,2,7])
     2163        assert numpy.allclose(quantity.vertex_values[0], [0,7,0])
     2164        assert numpy.allclose(quantity.vertex_values[1], [7,1,7])
     2165        assert numpy.allclose(quantity.vertex_values[2], [7,2,7])
    21762166
    21772167
     
    21822172        from mesh_factory import rectangular
    21832173        from shallow_water import Domain
    2184         from Numeric import zeros, Float
    21852174
    21862175        #Create basic mesh
     
    22052194
    22062195        answer = [0.5,2,4,5,0,1,3,4.5]
    2207         assert allclose(answer,
    2208                         quantity.get_values(location = 'unique vertices'))
     2196        assert numpy.allclose(answer,
     2197                              quantity.get_values(location = 'unique vertices'))
    22092198
    22102199        indices = [0,5,3]
    22112200        answer = [0.5,1,5]
    2212         assert allclose(answer,
    2213                         quantity.get_values(indices=indices, \
    2214                                             location = 'unique vertices'))
     2201        assert numpy.allclose(answer,
     2202                              quantity.get_values(indices=indices,
     2203                                                  location = 'unique vertices'))
    22152204        #print "quantity.centroid_values",quantity.centroid_values
    22162205        #print "quantity.get_values(location = 'centroids') ",\
     
    22412230        quantity.set_values(lambda x, y: x+2*y) #2 4 4 6
    22422231       
    2243         assert allclose(quantity.get_values(location='centroids'), [2,4,4,6])
    2244         assert allclose(quantity.get_values(location='centroids', indices=[1,3]), [4,6])
    2245 
    2246 
    2247         assert allclose(quantity.get_values(location='vertices'), [[4,0,2],
    2248                                                                    [4,2,6],
    2249                                                                    [6,2,4],
    2250                                                                    [8,4,6]])
    2251        
    2252         assert allclose(quantity.get_values(location='vertices', indices=[1,3]), [[4,2,6],
    2253                                                                                   [8,4,6]])
    2254 
    2255 
    2256         assert allclose(quantity.get_values(location='edges'), [[1,3,2],
    2257                                                                 [4,5,3],
    2258                                                                 [3,5,4],
    2259                                                                 [5,7,6]])
    2260         assert allclose(quantity.get_values(location='edges', indices=[1,3]),
    2261                         [[4,5,3],
    2262                          [5,7,6]])       
     2232        assert numpy.allclose(quantity.get_values(location='centroids'), [2,4,4,6])
     2233        assert numpy.allclose(quantity.get_values(location='centroids', indices=[1,3]), [4,6])
     2234
     2235
     2236        assert numpy.allclose(quantity.get_values(location='vertices'), [[4,0,2],
     2237                                                                         [4,2,6],
     2238                                                                         [6,2,4],
     2239                                                                         [8,4,6]])
     2240       
     2241        assert numpy.allclose(quantity.get_values(location='vertices', indices=[1,3]), [[4,2,6],
     2242                                                                                        [8,4,6]])
     2243
     2244
     2245        assert numpy.allclose(quantity.get_values(location='edges'), [[1,3,2],
     2246                                                                      [4,5,3],
     2247                                                                      [3,5,4],
     2248                                                                      [5,7,6]])
     2249        assert numpy.allclose(quantity.get_values(location='edges', indices=[1,3]),
     2250                              [[4,5,3],
     2251                               [5,7,6]])       
    22632252
    22642253        # Check averaging over vertices
     
    22802269        from mesh_factory import rectangular
    22812270        from shallow_water import Domain
    2282         from Numeric import zeros, Float
    22832271
    22842272        #Create basic mesh
     
    22982286       
    22992287        #print quantity.get_values(points=interpolation_points)
    2300         assert allclose(answer, quantity.get_values(interpolation_points=interpolation_points))
     2288        assert numpy.allclose(answer, quantity.get_values(interpolation_points=interpolation_points))
    23012289
    23022290
     
    23112299        #print answer
    23122300        #print quantity.get_values(interpolation_points=interpolation_points)
    2313         assert allclose(answer, quantity.get_values(interpolation_points=interpolation_points,
    2314                                                     verbose=False))       
     2301        assert numpy.allclose(answer, quantity.get_values(interpolation_points=interpolation_points,
     2302                                                          verbose=False))       
    23152303                       
    23162304
     
    23182306        #indices = [0,5,3]
    23192307        #answer = [0.5,1,5]
    2320         #assert allclose(answer,
    2321         #                quantity.get_values(indices=indices, \
    2322         #                                    location = 'unique vertices'))
     2308        #assert numpy.allclose(answer,
     2309        #                      quantity.get_values(indices=indices,
     2310        #                                          location = 'unique vertices'))
    23232311
    23242312
     
    23452333        x, y = 2.0/3, 8.0/3
    23462334        v = quantity.get_values(interpolation_points = [[x,y]])
    2347         assert allclose(v, 6)       
     2335        assert numpy.allclose(v, 6)       
    23482336
    23492337        # Then another to test that algorithm won't blindly
     
    23512339        x, y = 4.0/3, 4.0/3
    23522340        v = quantity.get_values(interpolation_points = [[x,y]])
    2353         assert allclose(v, 4)       
     2341        assert numpy.allclose(v, 4)       
    23542342
    23552343
     
    23802368        x, y = 2.0/3, 8.0/3
    23812369        v = quantity.get_values(interpolation_points = [[x+xllcorner,y+yllcorner]])
    2382         assert allclose(v, 6)
     2370        assert numpy.allclose(v, 6)
    23832371       
    23842372
     
    23872375        x, y = 4.0/3, 4.0/3
    23882376        v = quantity.get_values(interpolation_points = [[x+xllcorner,y+yllcorner]])
    2389         assert allclose(v, 4)       
     2377        assert numpy.allclose(v, 4)       
    23902378       
    23912379        # Try two points
     
    23932381               [4.0/3 + xllcorner, 4.0/3 + yllcorner]]         
    23942382        v = quantity.get_values(interpolation_points=pts)
    2395         assert allclose(v, [6, 4])               
     2383        assert numpy.allclose(v, [6, 4])               
    23962384       
    23972385        # Test it using the geospatial data format with absolute input points and default georef
    23982386        pts = Geospatial_data(data_points=pts)
    23992387        v = quantity.get_values(interpolation_points=pts)
    2400         assert allclose(v, [6, 4])                               
     2388        assert numpy.allclose(v, [6, 4])                               
    24012389       
    24022390       
     
    24052393                              geo_reference=Geo_reference(zone,xllcorner,yllcorner))
    24062394        v = quantity.get_values(interpolation_points=pts)
    2407         assert allclose(v, [6, 4])                       
     2395        assert numpy.allclose(v, [6, 4])                       
    24082396       
    24092397       
     
    24162404        from mesh_factory import rectangular
    24172405        from shallow_water import Domain
    2418         from Numeric import zeros, Float
    24192406
    24202407        #Create basic mesh
     
    24382425        #print "quantity.get_values(location = 'centroids') ",\
    24392426        #      quantity.get_values(location = 'centroids')
    2440         assert allclose(quantity.centroid_values,
    2441                         quantity.get_values(location = 'centroids'))
     2427        assert numpy.allclose(quantity.centroid_values,
     2428                              quantity.get_values(location = 'centroids'))
    24422429
    24432430
     
    24452432        quantity.set_values(value, indices = indices)
    24462433        #print "1 quantity.vertex_values",quantity.vertex_values
    2447         assert allclose(quantity.vertex_values, quantity.get_values())
    2448 
    2449         assert allclose(quantity.edge_values,
    2450                         quantity.get_values(location = 'edges'))
     2434        assert numpy.allclose(quantity.vertex_values, quantity.get_values())
     2435
     2436        assert numpy.allclose(quantity.edge_values,
     2437                              quantity.get_values(location = 'edges'))
    24512438
    24522439        # get a subset of elements
    24532440        subset = quantity.get_values(location='centroids', indices=[0,5])
    24542441        answer = [quantity.centroid_values[0],quantity.centroid_values[5]]
    2455         assert allclose(subset, answer)
     2442        assert numpy.allclose(subset, answer)
    24562443
    24572444
     
    24602447        #print "subset",subset
    24612448        #print "answer",answer
    2462         assert allclose(subset, answer)
     2449        assert numpy.allclose(subset, answer)
    24632450
    24642451        subset = quantity.get_values( indices=[1,5])
     
    24662453        #print "subset",subset
    24672454        #print "answer",answer
    2468         assert allclose(subset, answer)
     2455        assert numpy.allclose(subset, answer)
    24692456
    24702457    def test_smooth_vertex_values(self):
     
    24742461        from mesh_factory import rectangular
    24752462        from shallow_water import Domain
    2476         from Numeric import zeros, Float
    24772463
    24782464        #Create basic mesh
     
    25012487       
    25022488        #answer = [0.5, 2, 3, 3, 3.5, 4, 4, 5, 6.5]
    2503         #assert allclose(answer,
    2504         #                quantity.get_values(location = 'unique vertices'))
     2489        #assert numpy.allclose(answer,
     2490        #                      quantity.get_values(location = 'unique vertices'))
    25052491
    25062492        quantity.smooth_vertex_values()
     
    25122498                                [4,5,3],[3.5,3,5],[5,6.5,3.5],[4,3.5,6.5]]
    25132499       
    2514         assert allclose(answer_vertex_values,
    2515                         quantity.vertex_values)
     2500        assert numpy.allclose(answer_vertex_values,
     2501                              quantity.vertex_values)
    25162502        #print "quantity.centroid_values",quantity.centroid_values
    25172503        #print "quantity.get_values(location = 'centroids') ",\
     
    25222508#-------------------------------------------------------------
    25232509if __name__ == "__main__":
    2524     suite = unittest.makeSuite(Test_Quantity, 'test')   
    2525     #suite = unittest.makeSuite(Test_Quantity, 'test_set_values_from_file_using_polygon')
    2526 
    2527     #suite = unittest.makeSuite(Test_Quantity, 'test_set_vertex_values_using_general_interface_with_subset')
    2528     #print "restricted test"
    2529     #suite = unittest.makeSuite(Test_Quantity,'verbose_test_set_values_from_UTM_pts')
     2510#    suite = unittest.makeSuite(Test_Quantity, 'test')   
     2511    suite = unittest.makeSuite(Test_Quantity, 'test_get_extrema_1')
    25302512    runner = unittest.TextTestRunner()
    25312513    runner.run(suite)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_region.py

    r5211 r5892  
    66from domain import *
    77from region import *
    8 #from anuga.config import epsilon
    9 from Numeric import allclose, average #, array, ones, Float
     8import numpy
     9
    1010"""
    1111This is what the mesh in these tests look like;
     
    4444        from mesh_factory import rectangular
    4545        from shallow_water import Domain
    46         from Numeric import zeros, Float
    4746
    4847        #Create basic mesh
     
    6463        domain.set_region([a, b])
    6564        #print domain.quantities['friction'].get_values()
    66         assert allclose(domain.quantities['friction'].get_values(),\
    67                         [[ 0.09,  0.09,  0.09],
    68                          [ 0.09,  0.09,  0.09],
    69                          [ 0.07,  0.07,  0.07],
    70                          [ 0.07,  0.07,  0.07],
    71                          [ 1.0,  1.0,  1.0],
    72                          [ 1.0,  1.0,  1.0]])
     65        assert numpy.allclose(domain.quantities['friction'].get_values(),
     66                              [[ 0.09,  0.09,  0.09],
     67                               [ 0.09,  0.09,  0.09],
     68                               [ 0.07,  0.07,  0.07],
     69                               [ 0.07,  0.07,  0.07],
     70                               [ 1.0,  1.0,  1.0],
     71                               [ 1.0,  1.0,  1.0]])
    7372
    7473        #c = Add_Value_To_region('all', 'friction', 10.0)
    7574        domain.set_region(Add_value_to_region('all', 'friction', 10.0))
    7675        #print domain.quantities['friction'].get_values()
    77         assert allclose(domain.quantities['friction'].get_values(),
    78                         [[ 10.09, 10.09, 10.09],
    79                          [ 10.09, 10.09, 10.09],
    80                          [ 10.07, 10.07, 10.07],
    81                          [ 10.07, 10.07, 10.07],
    82                          [ 11.0,  11.0,  11.0],
    83                          [ 11.0,  11.0,  11.0]])
     76        assert numpy.allclose(domain.quantities['friction'].get_values(),
     77                              [[ 10.09, 10.09, 10.09],
     78                               [ 10.09, 10.09, 10.09],
     79                               [ 10.07, 10.07, 10.07],
     80                               [ 10.07, 10.07, 10.07],
     81                               [ 11.0,  11.0,  11.0],
     82                               [ 11.0,  11.0,  11.0]])
    8483
    8584        # trying a function
    8685        domain.set_region(Set_region('top', 'friction', add_x_y))
    8786        #print domain.quantities['friction'].get_values()
    88         assert allclose(domain.quantities['friction'].get_values(),
    89                         [[ 10.09, 10.09, 10.09],
    90                          [ 10.09, 10.09, 10.09],
    91                          [ 10.07, 10.07, 10.07],
    92                          [ 10.07, 10.07, 10.07],
    93                          [ 5./3,  2.0,  2./3],
    94                          [ 1.0,  2./3,  2.0]])
     87        assert numpy.allclose(domain.quantities['friction'].get_values(),
     88                              [[ 10.09, 10.09, 10.09],
     89                               [ 10.09, 10.09, 10.09],
     90                               [ 10.07, 10.07, 10.07],
     91                               [ 10.07, 10.07, 10.07],
     92                               [ 5./3,  2.0,  2./3],
     93                               [ 1.0,  2./3,  2.0]])
    9594
    9695        domain.set_quantity('elevation', 10.0)
     
    9897        domain.set_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation'))
    9998        #print domain.quantities['stage'].get_values()
    100         assert allclose(domain.quantities['stage'].get_values(),
    101                         [[ 10., 10., 10.],
    102                          [ 10., 10., 10.],
    103                          [ 10., 10., 10.],
    104                          [ 10., 10., 10.],
    105                          [ 11.0,  11.0,  11.0],
    106                          [ 11.0,  11.0,  11.0]])
     99        assert numpy.allclose(domain.quantities['stage'].get_values(),
     100                              [[ 10., 10., 10.],
     101                               [ 10., 10., 10.],
     102                               [ 10., 10., 10.],
     103                               [ 10., 10., 10.],
     104                               [ 11.0,  11.0,  11.0],
     105                               [ 11.0,  11.0,  11.0]])
    107106
    108107       
     
    115114        domain.set_region(Add_quantities('top', 'elevation','stage'))
    116115        #print domain.quantities['stage'].get_values()
    117         assert allclose(domain.quantities['elevation'].get_values(),
    118                         [[ 10., 10., 10.],
    119                          [ 10., 10., 10.],
    120                          [ 10., 10., 10.],
    121                          [ 10., 10., 10.],
    122                          [ 33.,  33.0,  33.],
    123                          [ 33.0,  33.,  33.]])
     116        assert numpy.allclose(domain.quantities['elevation'].get_values(),
     117                              [[ 10., 10., 10.],
     118                               [ 10., 10., 10.],
     119                               [ 10., 10., 10.],
     120                               [ 10., 10., 10.],
     121                               [ 33.,  33.0,  33.],
     122                               [ 33.0,  33.,  33.]])
    124123       
    125124    def test_unique_vertices(self):
     
    129128        from mesh_factory import rectangular
    130129        from shallow_water import Domain
    131         from Numeric import zeros, Float
    132130
    133131        #Create basic mesh
     
    147145        domain.set_region(a)
    148146        #print domain.quantities['friction'].get_values()
    149         assert allclose(domain.quantities['friction'].get_values(),\
    150                         [[ 0.09,  0.09,  0.09],
    151                          [ 0.09,  0.09,  0.09],
    152                          [ 0.09,  0.07,  0.09],
    153                          [ 0.07,  0.09,  0.07],
    154                          [ 0.07,  0.07,  0.07],
    155                          [ 0.07,  0.07,  0.07]])
     147        assert numpy.allclose(domain.quantities['friction'].get_values(),\
     148                              [[ 0.09,  0.09,  0.09],
     149                               [ 0.09,  0.09,  0.09],
     150                               [ 0.09,  0.07,  0.09],
     151                               [ 0.07,  0.09,  0.07],
     152                               [ 0.07,  0.07,  0.07],
     153                               [ 0.07,  0.07,  0.07]])
    156154
    157155
     
    162160        from mesh_factory import rectangular
    163161        from shallow_water import Domain
    164         from Numeric import zeros, Float
    165162
    166163        #Create basic mesh
     
    180177
    181178        #print domain.quantities['friction'].get_values()
    182         assert allclose(domain.quantities['friction'].get_values(),\
    183                         [[ 1.07,  1.07,  1.07],
    184                          [ 1.07,  1.07,  1.07],
    185                          [ 1.07,  0.07,  1.07],
    186                          [ 0.07,  1.07,  0.07],
    187                          [ 0.07,  0.07,  0.07],
    188                          [ 0.07,  0.07,  0.07]])
     179        assert numpy.allclose(domain.quantities['friction'].get_values(),\
     180                              [[ 1.07,  1.07,  1.07],
     181                               [ 1.07,  1.07,  1.07],
     182                               [ 1.07,  0.07,  1.07],
     183                               [ 0.07,  1.07,  0.07],
     184                               [ 0.07,  0.07,  0.07],
     185                               [ 0.07,  0.07,  0.07]])
    189186                         
    190187    def test_unique_vertices_average_loc_vert(self):
     
    194191        from mesh_factory import rectangular
    195192        from shallow_water import Domain
    196         from Numeric import zeros, Float
    197193
    198194        #Create basic mesh
     
    218214        #print domain.quantities['friction'].get_values()
    219215        frict_points = domain.quantities['friction'].get_values()
    220         assert allclose(frict_points[0],\
    221                         [ calc_frict, calc_frict, calc_frict])
    222         assert allclose(frict_points[1],\
    223                         [ calc_frict, calc_frict, calc_frict])
     216        assert numpy.allclose(frict_points[0],
     217                              [ calc_frict, calc_frict, calc_frict])
     218        assert numpy.allclose(frict_points[1],
     219                              [ calc_frict, calc_frict, calc_frict])
    224220 
    225221    def test_unique_vertices_average_loc_unique_vert(self):
     
    229225        from mesh_factory import rectangular
    230226        from shallow_water import Domain
    231         from Numeric import zeros, Float
    232227
    233228        #Create basic mesh
     
    252247        #print domain.quantities['friction'].get_values()
    253248        frict_points = domain.quantities['friction'].get_values()
    254         assert allclose(frict_points[0],\
    255                         [ calc_frict, calc_frict, calc_frict])
    256         assert allclose(frict_points[1],\
    257                         [ calc_frict, calc_frict, calc_frict])
    258         assert allclose(frict_points[2],\
    259                         [ calc_frict, 1.0 + 2.0/3.0, calc_frict])
    260         assert allclose(frict_points[3],\
    261                         [ 2.0/3.0,calc_frict, 1.0 + 2.0/3.0])
     249        assert numpy.allclose(frict_points[0],
     250                              [ calc_frict, calc_frict, calc_frict])
     251        assert numpy.allclose(frict_points[1],
     252                              [ calc_frict, calc_frict, calc_frict])
     253        assert numpy.allclose(frict_points[2],
     254                              [ calc_frict, 1.0 + 2.0/3.0, calc_frict])
     255        assert numpy.allclose(frict_points[3],
     256                              [ 2.0/3.0,calc_frict, 1.0 + 2.0/3.0])
    262257                                               
    263258                         
     
    265260if __name__ == "__main__":
    266261    suite = unittest.makeSuite(Test_Region,'test')
     262##    suite = unittest.makeSuite(Test_Region,'test_unique_vertices_average_loc_unique_vert')
    267263    runner = unittest.TextTestRunner()
    268264    runner.run(suite)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r5657 r5892  
    11#!/usr/bin/env python
    22
    3 
    43import unittest
    5 from Numeric import zeros, array, allclose, Float
     4import numpy
     5
    66from math import sqrt, pi
    77import tempfile, os
     
    9191
    9292            #Exact linear intpolation
    93             assert allclose(q[0], 2*t)
     93            assert numpy.allclose(q[0], 2*t)
    9494            if i%6 == 0:
    95                 assert allclose(q[1], t**2)
    96                 assert allclose(q[2], sin(t*pi/600))
     95                assert numpy.allclose(q[1], t**2)
     96                assert numpy.allclose(q[2], sin(t*pi/600))
    9797
    9898        #Check non-exact
     
    100100        t = 90 #Halfway between 60 and 120
    101101        q = F(t)
    102         assert allclose( (120**2 + 60**2)/2, q[1] )
    103         assert allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
     102        assert numpy.allclose( (120**2 + 60**2)/2, q[1] )
     103        assert numpy.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
    104104
    105105
    106106        t = 100 #Two thirds of the way between between 60 and 120
    107107        q = F(t)
    108         assert allclose( 2*120**2/3 + 60**2/3, q[1] )
    109         assert allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
     108        assert numpy.allclose( 2*120**2/3 + 60**2/3, q[1] )
     109        assert numpy.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
    110110
    111111        os.remove(filename + '.txt')
     
    125125        from shallow_water import Domain, Dirichlet_boundary
    126126        from mesh_factory import rectangular
    127         from Numeric import take, concatenate, reshape
    128127
    129128        #Create basic mesh and shallow water domain
     
    148147
    149148        # Boundary conditions
     149        print 'test_util: 0'
    150150        B0 = Dirichlet_boundary([0,0,0])
    151151        B6 = Dirichlet_boundary([0.6,0,0])
     152        print 'test_util: 1'
    152153        domain1.set_boundary({'left': B6, 'top': B6, 'right': B0, 'bottom': B0})
    153154        domain1.check_integrity()
     155        print 'test_util: 2'
    154156
    155157        finaltime = 8
    156158        #Evolution
    157159        t0 = -1
     160        print 'test_util: 3'
     161# crash at following line
    158162        for t in domain1.evolve(yieldstep = 0.1, finaltime = finaltime):
     163            print 'test_util: 4'
    159164            #print 'Timesteps: %.16f, %.16f' %(t0, t)
    160165            #if t == t0:
     
    164169             
    165170            #domain1.write_time()
     171        print 'test_util: 5'
    166172
    167173
     
    182188
    183189        last_time_index = len(time)-1 #Last last_time_index
    184         d_stage = reshape(take(stage[last_time_index, :], [0,5,10,15]), (4,1))
    185         d_uh = reshape(take(xmomentum[last_time_index, :], [0,5,10,15]), (4,1))
    186         d_vh = reshape(take(ymomentum[last_time_index, :], [0,5,10,15]), (4,1))
    187         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     190        d_stage = numpy.reshape(numpy.take(stage[last_time_index, :], [0,5,10,15], axis=0), (4,1))
     191        d_uh = numpy.reshape(numpy.take(xmomentum[last_time_index, :], [0,5,10,15], axis=0), (4,1))
     192        d_vh = numpy.reshape(numpy.take(ymomentum[last_time_index, :], [0,5,10,15], axis=0), (4,1))
     193        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    188194
    189195        #Reference interpolated values at midpoints on diagonal at
     
    194200
    195201        #And the midpoints are found now
    196         Dx = take(reshape(x, (16,1)), [0,5,10,15])
    197         Dy = take(reshape(y, (16,1)), [0,5,10,15])
    198 
    199         diag = concatenate( (Dx, Dy), axis=1)
     202        Dx = numpy.take(numpy.reshape(x, (16,1)), [0,5,10,15], axis=0)
     203        Dy = numpy.take(numpy.reshape(y, (16,1)), [0,5,10,15], axis=0)
     204
     205        diag = numpy.concatenate( (Dx, Dy), axis=1)
    200206        d_midpoints = (diag[1:] + diag[:-1])/2
    201207
     
    209215        assert not T[-1] == T[-2], msg
    210216        t = time[last_time_index]
    211         q = f(t, point_id=0); assert allclose(r0, q)
    212         q = f(t, point_id=1); assert allclose(r1, q)
    213         q = f(t, point_id=2); assert allclose(r2, q)
     217        q = f(t, point_id=0); assert numpy.allclose(r0, q)
     218        q = f(t, point_id=1); assert numpy.allclose(r1, q)
     219        q = f(t, point_id=2); assert numpy.allclose(r2, q)
    214220
    215221
     
    218224
    219225        timestep = 0 #First timestep
    220         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    221         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    222         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    223         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     226        d_stage = numpy.reshape(numpy.take(stage[timestep, :], [0,5,10,15], axis=0), (4,1))
     227        d_uh = numpy.reshape(numpy.take(xmomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     228        d_vh = numpy.reshape(numpy.take(ymomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     229        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    224230
    225231        #Reference interpolated values at midpoints on diagonal at
     
    231237        #Let us see if the file function can find the correct
    232238        #values
    233         q = f(0, point_id=0); assert allclose(r0, q)
    234         q = f(0, point_id=1); assert allclose(r1, q)
    235         q = f(0, point_id=2); assert allclose(r2, q)
     239        q = f(0, point_id=0); assert numpy.allclose(r0, q)
     240        q = f(0, point_id=1); assert numpy.allclose(r1, q)
     241        q = f(0, point_id=2); assert numpy.allclose(r2, q)
    236242
    237243
     
    240246
    241247        timestep = 33
    242         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    243         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    244         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    245         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     248        d_stage = numpy.reshape(numpy.take(stage[timestep, :], [0,5,10,15], axis=0), (4,1))
     249        d_uh = numpy.reshape(numpy.take(xmomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     250        d_vh = numpy.reshape(numpy.take(ymomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     251        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    246252
    247253        #Reference interpolated values at midpoints on diagonal at
     
    251257        r2 = (D[2] + D[3])/2
    252258
    253         q = f(timestep/10., point_id=0); assert allclose(r0, q)
    254         q = f(timestep/10., point_id=1); assert allclose(r1, q)
    255         q = f(timestep/10., point_id=2); assert allclose(r2, q)
     259        q = f(timestep/10., point_id=0); assert numpy.allclose(r0, q)
     260        q = f(timestep/10., point_id=1); assert numpy.allclose(r1, q)
     261        q = f(timestep/10., point_id=2); assert numpy.allclose(r2, q)
    256262
    257263
     
    261267
    262268        timestep = 15
    263         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    264         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    265         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    266         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     269        d_stage = numpy.reshape(numpy.take(stage[timestep, :], [0,5,10,15], axis=0), (4,1))
     270        d_uh = numpy.reshape(numpy.take(xmomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     271        d_vh = numpy.reshape(numpy.take(ymomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     272        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    267273
    268274        #Reference interpolated values at midpoints on diagonal at
     
    274280        #
    275281        timestep = 16
    276         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    277         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    278         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    279         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     282        d_stage = numpy.reshape(numpy.take(stage[timestep, :], [0,5,10,15], axis=0), (4,1))
     283        d_uh = numpy.reshape(numpy.take(xmomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     284        d_vh = numpy.reshape(numpy.take(ymomentum[timestep, :], [0,5,10,15], axis=0), (4,1))
     285        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    280286
    281287        #Reference interpolated values at midpoints on diagonal at
     
    290296        r2 = (r2_0 + r2_1)/2
    291297
    292         q = f((timestep - 0.5)/10., point_id=0); assert allclose(r0, q)
    293         q = f((timestep - 0.5)/10., point_id=1); assert allclose(r1, q)
    294         q = f((timestep - 0.5)/10., point_id=2); assert allclose(r2, q)
     298        q = f((timestep - 0.5)/10., point_id=0); assert numpy.allclose(r0, q)
     299        q = f((timestep - 0.5)/10., point_id=1); assert numpy.allclose(r1, q)
     300        q = f((timestep - 0.5)/10., point_id=2); assert numpy.allclose(r2, q)
    295301
    296302        ##################
     
    304310
    305311        #And the file function gives
    306         q = f((timestep - 1.0/3)/10., point_id=0); assert allclose(r0, q)
    307         q = f((timestep - 1.0/3)/10., point_id=1); assert allclose(r1, q)
    308         q = f((timestep - 1.0/3)/10., point_id=2); assert allclose(r2, q)
     312        q = f((timestep - 1.0/3)/10., point_id=0); assert numpy.allclose(r0, q)
     313        q = f((timestep - 1.0/3)/10., point_id=1); assert numpy.allclose(r1, q)
     314        q = f((timestep - 1.0/3)/10., point_id=2); assert numpy.allclose(r2, q)
    309315
    310316        fid.close()
     
    326332        from shallow_water import Domain, Dirichlet_boundary
    327333        from mesh_factory import rectangular
    328         from Numeric import take, concatenate, reshape
    329334
    330335
     
    386391
    387392        last_time_index = len(time)-1 #Last last_time_index     
    388         d_stage = reshape(take(stage[last_time_index, :], [0,5,10,15]), (4,1))
    389         d_uh = reshape(take(xmomentum[last_time_index, :], [0,5,10,15]), (4,1))
    390         d_vh = reshape(take(ymomentum[last_time_index, :], [0,5,10,15]), (4,1))
    391         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     393        d_stage = numpy.reshape(take(stage[last_time_index, :], [0,5,10,15]), (4,1))
     394        d_uh = numpy.reshape(take(xmomentum[last_time_index, :], [0,5,10,15]), (4,1))
     395        d_vh = numpy.reshape(take(ymomentum[last_time_index, :], [0,5,10,15]), (4,1))
     396        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    392397
    393398        #Reference interpolated values at midpoints on diagonal at
     
    398403
    399404        #And the midpoints are found now
    400         Dx = take(reshape(x, (16,1)), [0,5,10,15])
    401         Dy = take(reshape(y, (16,1)), [0,5,10,15])
    402 
    403         diag = concatenate( (Dx, Dy), axis=1)
     405        Dx = take(numpy.reshape(x, (16,1)), [0,5,10,15])
     406        Dy = take(numpy.reshape(y, (16,1)), [0,5,10,15])
     407
     408        diag = numpy.concatenate( (Dx, Dy), axis=1)
    404409        d_midpoints = (diag[1:] + diag[:-1])/2
    405410
     
    415420
    416421        t = time[last_time_index]                         
    417         q = f(t, point_id=0); assert allclose(r0, q)
    418         q = f(t, point_id=1); assert allclose(r1, q)
    419         q = f(t, point_id=2); assert allclose(r2, q)
     422        q = f(t, point_id=0); assert numpy.allclose(r0, q)
     423        q = f(t, point_id=1); assert numpy.allclose(r1, q)
     424        q = f(t, point_id=2); assert numpy.allclose(r2, q)
    420425
    421426
     
    424429
    425430        timestep = 0 #First timestep
    426         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    427         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    428         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    429         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     431        d_stage = numpy.reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
     432        d_uh = numpy.reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
     433        d_vh = numpy.reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
     434        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    430435
    431436        #Reference interpolated values at midpoints on diagonal at
     
    437442        #Let us see if the file function can find the correct
    438443        #values
    439         q = f(0, point_id=0); assert allclose(r0, q)
    440         q = f(0, point_id=1); assert allclose(r1, q)
    441         q = f(0, point_id=2); assert allclose(r2, q)
     444        q = f(0, point_id=0); assert numpy.allclose(r0, q)
     445        q = f(0, point_id=1); assert numpy.allclose(r1, q)
     446        q = f(0, point_id=2); assert numpy.allclose(r2, q)
    442447
    443448
     
    446451
    447452        timestep = 33
    448         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    449         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    450         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    451         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     453        d_stage = numpy.reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
     454        d_uh = numpy.reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
     455        d_vh = numpy.reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
     456        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    452457
    453458        #Reference interpolated values at midpoints on diagonal at
     
    457462        r2 = (D[2] + D[3])/2
    458463
    459         q = f(timestep/10., point_id=0); assert allclose(r0, q)
    460         q = f(timestep/10., point_id=1); assert allclose(r1, q)
    461         q = f(timestep/10., point_id=2); assert allclose(r2, q)
     464        q = f(timestep/10., point_id=0); assert numpy.allclose(r0, q)
     465        q = f(timestep/10., point_id=1); assert numpy.allclose(r1, q)
     466        q = f(timestep/10., point_id=2); assert numpy.allclose(r2, q)
    462467
    463468
     
    467472
    468473        timestep = 15
    469         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    470         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    471         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    472         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     474        d_stage = numpy.reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
     475        d_uh = numpy.reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
     476        d_vh = numpy.reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
     477        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    473478
    474479        #Reference interpolated values at midpoints on diagonal at
     
    480485        #
    481486        timestep = 16
    482         d_stage = reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
    483         d_uh = reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
    484         d_vh = reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
    485         D = concatenate( (d_stage, d_uh, d_vh), axis=1)
     487        d_stage = numpy.reshape(take(stage[timestep, :], [0,5,10,15]), (4,1))
     488        d_uh = numpy.reshape(take(xmomentum[timestep, :], [0,5,10,15]), (4,1))
     489        d_vh = numpy.reshape(take(ymomentum[timestep, :], [0,5,10,15]), (4,1))
     490        D = numpy.concatenate( (d_stage, d_uh, d_vh), axis=1)
    486491
    487492        #Reference interpolated values at midpoints on diagonal at
     
    496501        r2 = (r2_0 + r2_1)/2
    497502
    498         q = f((timestep - 0.5)/10., point_id=0); assert allclose(r0, q)
    499         q = f((timestep - 0.5)/10., point_id=1); assert allclose(r1, q)
    500         q = f((timestep - 0.5)/10., point_id=2); assert allclose(r2, q)
     503        q = f((timestep - 0.5)/10., point_id=0); assert numpy.allclose(r0, q)
     504        q = f((timestep - 0.5)/10., point_id=1); assert numpy.allclose(r1, q)
     505        q = f((timestep - 0.5)/10., point_id=2); assert numpy.allclose(r2, q)
    501506
    502507        ##################
     
    510515
    511516        #And the file function gives
    512         q = f((timestep - 1.0/3)/10., point_id=0); assert allclose(r0, q)
    513         q = f((timestep - 1.0/3)/10., point_id=1); assert allclose(r1, q)
    514         q = f((timestep - 1.0/3)/10., point_id=2); assert allclose(r2, q)
     517        q = f((timestep - 1.0/3)/10., point_id=0); assert numpy.allclose(r0, q)
     518        q = f((timestep - 1.0/3)/10., point_id=1); assert numpy.allclose(r1, q)
     519        q = f((timestep - 1.0/3)/10., point_id=2); assert numpy.allclose(r2, q)
    515520
    516521        fid.close()
     
    542547        import os, time
    543548        from anuga.config import time_format
    544         from Numeric import sin, pi, exp
    545549        from mesh_factory import rectangular
    546550        from shallow_water import Domain
     
    584588            domain.set_quantity('xmomentum', f2)
    585589
    586             f3 = lambda x,y: x**2 + y**2 * sin(t*pi/600)
     590            f3 = lambda x,y: x**2 + y**2 * numpy.sin(t*numpy.pi/600)
    587591            domain.set_quantity('ymomentum', f3)
    588592
     
    604608
    605609        #Check that FF updates fixes domain starttime
    606         assert allclose(domain.starttime, start)
     610        assert numpy.allclose(domain.starttime, start)
    607611
    608612        #Check that domain.starttime isn't updated if later
     
    611615                          quantities = domain.conserved_quantities,
    612616                          interpolation_points = interpolation_points)
    613         assert allclose(domain.starttime, start+1)
     617        assert numpy.allclose(domain.starttime, start+1)
    614618        domain.starttime = start
    615619
     
    645649                     self.failUnless( q == actual, 'Fail!')
    646650                else:
    647                     assert allclose(q, actual)
     651                    assert numpy.allclose(q, actual)
    648652
    649653
     
    655659            t = 90 #Halfway between 60 and 120
    656660            q = F(t, point_id=id)
    657             assert allclose( (q120+q60)/2, q )
     661            assert numpy.allclose( (q120+q60)/2, q )
    658662
    659663            t = 100 #Two thirds of the way between between 60 and 120
    660664            q = F(t, point_id=id)
    661             assert allclose(q60/3 + 2*q120/3, q)
     665            assert numpy.allclose(q60/3 + 2*q120/3, q)
    662666
    663667
     
    670674                          quantities = domain.conserved_quantities,
    671675                          interpolation_points = interpolation_points)
    672         assert allclose(domain.starttime, start+delta)
     676        assert numpy.allclose(domain.starttime, start+delta)
    673677
    674678
     
    689693
    690694                q = F(t-delta, point_id=id)
    691                 assert allclose(q, (k*q1 + (6-k)*q0)/6)
     695                assert numpy.allclose(q, (k*q1 + (6-k)*q0)/6)
    692696
    693697
     
    703707        import os, time
    704708        from anuga.config import time_format
    705         from Numeric import sin, pi, exp
    706709        from mesh_factory import rectangular
    707710        from shallow_water import Domain
     
    751754            domain.set_quantity('xmomentum', f2)
    752755
    753             f3 = lambda x,y: x**2 + y**2 * sin(t*pi/600)
     756            f3 = lambda x,y: x**2 + y**2 * numpy.sin(t*numpy.pi/600)
    754757            domain.set_quantity('ymomentum', f3)
    755758
     
    774777
    775778        #Check that FF updates fixes domain starttime
    776         assert allclose(domain.starttime, start)
     779        assert numpy.allclose(domain.starttime, start)
    777780
    778781        #Check that domain.starttime isn't updated if later
     
    781784                          quantities = domain.conserved_quantities,
    782785                          interpolation_points = interpolation_points)
    783         assert allclose(domain.starttime, start+1)
     786        assert numpy.allclose(domain.starttime, start+1)
    784787        domain.starttime = start
    785788
     
    817820                     self.failUnless( q == actual, 'Fail!')
    818821                else:
    819                     assert allclose(q, actual)
     822                    assert numpy.allclose(q, actual)
    820823
    821824        # now lets check points inside the mesh
     
    863866                     self.failUnless( q == actual, 'Fail!')
    864867                else:
    865                     assert allclose(q, actual)
     868                    assert numpy.allclose(q, actual)
    866869
    867870
     
    873876            t = 90 #Halfway between 60 and 120
    874877            q = F(t, point_id=id)
    875             assert allclose( (q120+q60)/2, q )
     878            assert numpy.allclose( (q120+q60)/2, q )
    876879
    877880            t = 100 #Two thirds of the way between between 60 and 120
    878881            q = F(t, point_id=id)
    879             assert allclose(q60/3 + 2*q120/3, q)
     882            assert numpy.allclose(q60/3 + 2*q120/3, q)
    880883
    881884
     
    888891                          quantities = domain.conserved_quantities,
    889892                          interpolation_points = interpolation_points)
    890         assert allclose(domain.starttime, start+delta)
     893        assert numpy.allclose(domain.starttime, start+delta)
    891894
    892895
     
    907910
    908911                q = F(t-delta, point_id=id)
    909                 assert allclose(q, (k*q1 + (6-k)*q0)/6)
     912                assert numpy.allclose(q, (k*q1 + (6-k)*q0)/6)
    910913
    911914
     
    955958                          domain,
    956959                          quantities = ['Attribute0', 'Attribute1', 'Attribute2']) 
    957         assert allclose(domain.starttime, start)
     960        assert numpy.allclose(domain.starttime, start)
    958961
    959962        # Check that domain.starttime is updated if too early
     
    962965                          domain,
    963966                          quantities = ['Attribute0', 'Attribute1', 'Attribute2'])
    964         assert allclose(domain.starttime, start)
     967        assert numpy.allclose(domain.starttime, start)
    965968
    966969        # Check that domain.starttime isn't updated if later
     
    969972                          domain,
    970973                          quantities = ['Attribute0', 'Attribute1', 'Attribute2'])
    971         assert allclose(domain.starttime, start+1)
     974        assert numpy.allclose(domain.starttime, start+1)
    972975
    973976        domain.starttime = start
     
    987990
    988991            #Exact linear intpolation
    989             assert allclose(q[0], 2*t)
     992            assert numpy.allclose(q[0], 2*t)
    990993            if i%6 == 0:
    991                 assert allclose(q[1], t**2)
    992                 assert allclose(q[2], sin(t*pi/600))
     994                assert numpy.allclose(q[1], t**2)
     995                assert numpy.allclose(q[2], sin(t*pi/600))
    993996
    994997        #Check non-exact
     
    996999        t = 90 #Halfway between 60 and 120
    9971000        q = F(t)
    998         assert allclose( (120**2 + 60**2)/2, q[1] )
    999         assert allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
     1001        assert numpy.allclose( (120**2 + 60**2)/2, q[1] )
     1002        assert numpy.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
    10001003
    10011004
    10021005        t = 100 #Two thirds of the way between between 60 and 120
    10031006        q = F(t)
    1004         assert allclose( 2*120**2/3 + 60**2/3, q[1] )
    1005         assert allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
     1007        assert numpy.allclose( 2*120**2/3 + 60**2/3, q[1] )
     1008        assert numpy.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
    10061009
    10071010        os.remove(filename + '.tms')
     
    10521055        F = file_function(filename + '.tms', domain,
    10531056                          quantities = ['Attribute0', 'Attribute1', 'Attribute2'])       
    1054         assert allclose(domain.starttime, start+delta)
     1057        assert numpy.allclose(domain.starttime, start+delta)
    10551058
    10561059
     
    10631066
    10641067            #Exact linear intpolation
    1065             assert allclose(q[0], 2*t)
     1068            assert numpy.allclose(q[0], 2*t)
    10661069            if i%6 == 0:
    1067                 assert allclose(q[1], t**2)
    1068                 assert allclose(q[2], sin(t*pi/600))
     1070                assert numpy.allclose(q[1], t**2)
     1071                assert numpy.allclose(q[2], sin(t*pi/600))
    10691072
    10701073        #Check non-exact
     
    10721075        t = 90 #Halfway between 60 and 120
    10731076        q = F(t-delta)
    1074         assert allclose( (120**2 + 60**2)/2, q[1] )
    1075         assert allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
     1077        assert numpy.allclose( (120**2 + 60**2)/2, q[1] )
     1078        assert numpy.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
    10761079
    10771080
    10781081        t = 100 #Two thirds of the way between between 60 and 120
    10791082        q = F(t-delta)
    1080         assert allclose( 2*120**2/3 + 60**2/3, q[1] )
    1081         assert allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
     1083        assert numpy.allclose( 2*120**2/3 + 60**2/3, q[1] )
     1084        assert numpy.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
    10821085
    10831086
     
    10911094        #FIXME: Division is not expected to work for integers.
    10921095        #This must be caught.
    1093         foo = array([[1,2,3],
    1094                      [4,5,6]], Float)
    1095 
    1096         bar = array([[-1,0,5],
    1097                      [6,1,1]], Float)                 
     1096        foo = numpy.array([[1,2,3], [4,5,6]], numpy.float)
     1097
     1098        bar = numpy.array([[-1,0,5], [6,1,1]], numpy.float)                 
    10981099
    10991100        D = {'X': foo, 'Y': bar}
    11001101
    11011102        Z = apply_expression_to_dictionary('X+Y', D)       
    1102         assert allclose(Z, foo+bar)
     1103        assert numpy.allclose(Z, foo+bar)
    11031104
    11041105        Z = apply_expression_to_dictionary('X*Y', D)       
    1105         assert allclose(Z, foo*bar)       
     1106        assert numpy.allclose(Z, foo*bar)       
    11061107
    11071108        Z = apply_expression_to_dictionary('4*X+Y', D)       
    1108         assert allclose(Z, 4*foo+bar)       
     1109        assert numpy.allclose(Z, 4*foo+bar)       
    11091110
    11101111        # test zero division is OK
    11111112        Z = apply_expression_to_dictionary('X/Y', D)
    1112         assert allclose(1/Z, 1/(foo/bar)) # can't compare inf to inf
     1113        assert numpy.allclose(1/Z, 1/(foo/bar)) # can't compare inf to inf
    11131114
    11141115        # make an error for zero on zero
     
    12681269        tris = [[0,1,2]]
    12691270        new_verts, new_tris = remove_lone_verts(verts, tris)
    1270         assert new_verts == verts
    1271         assert new_tris == tris
     1271        assert numpy.alltrue(new_verts == verts)
     1272        assert numpy.alltrue(new_tris == tris)
    12721273     
    12731274
     
    12841285        new_verts, new_tris = remove_lone_verts(verts, tris)
    12851286        #print "new_verts", new_verts
    1286         assert new_verts == [[0,0],[1,0],[0,1]]
    1287         assert new_tris == [[0,1,2]]
     1287        assert numpy.alltrue(new_verts == [[0,0],[1,0],[0,1]])
     1288        assert numpy.alltrue(new_tris == [[0,1,2]])
    12881289     
    12891290    def test_remove_lone_verts_c(self):
     
    12911292        tris = [[0,1,3]]
    12921293        new_verts, new_tris = remove_lone_verts(verts, tris)
    1293         #print "new_verts", new_verts
    1294         assert new_verts == [[0,0],[1,0],[0,1]]
    1295         assert new_tris == [[0,1,2]]
     1294        print "new_verts", new_verts
     1295        assert numpy.alltrue(new_verts == [[0,0],[1,0],[0,1]])
     1296        assert numpy.alltrue(new_tris == [[0,1,2]])
    12961297       
    12971298    def test_remove_lone_verts_b(self):
     
    12991300        tris = [[0,1,2]]
    13001301        new_verts, new_tris = remove_lone_verts(verts, tris)
    1301         assert new_verts == verts[0:3]
    1302         assert new_tris == tris
     1302        assert numpy.alltrue(new_verts == verts[0:3])
     1303        assert numpy.alltrue(new_tris == tris)
    13031304     
    13041305
     
    13071308        tris = [[0,1,2]]
    13081309        new_verts, new_tris = remove_lone_verts(verts, tris)
    1309         assert new_verts == verts[0:3]
    1310         assert new_tris == tris
     1310        assert numpy.alltrue(new_verts == verts[0:3])
     1311        assert numpy.alltrue(new_tris == tris)
    13111312       
    13121313    def test_get_min_max_values(self):
     
    14961497            line.append([float(row[0]),float(row[1]),float(row[2]),float(row[3]),float(row[4]),float(row[5])])
    14971498            #print 'assert line',line[i],'point1',point1_answers_array[i]
    1498             assert allclose(line[i], point1_answers_array[i])
     1499            assert numpy.allclose(line[i], point1_answers_array[i])
    14991500
    15001501        point2_answers_array = [[0.0,1.0,1.5,-0.5,3.0,4.0], [2.0,10.0,10.5,-0.5,3.0,4.0]]
     
    15091510            line.append([float(row[0]),float(row[1]),float(row[2]),float(row[3]),float(row[4]),float(row[5])])
    15101511            #print 'assert line',line[i],'point1',point1_answers_array[i]
    1511             assert allclose(line[i], point2_answers_array[i])
     1512            assert numpy.allclose(line[i], point2_answers_array[i])
    15121513                         
    15131514        # clean up
     
    16151616            line.append([float(row[0]),float(row[1]),float(row[2])])
    16161617            #print 'line',line[i],'point1',point1_answers_array[i]
    1617             assert allclose(line[i], point1_answers_array[i])
     1618            assert numpy.allclose(line[i], point1_answers_array[i])
    16181619
    16191620        point2_answers_array = [[0.0,1.0,-0.5], [2.0,10.0,-0.5]]
     
    16281629            line.append([float(row[0]),float(row[1]),float(row[2])])
    16291630#            print 'line',line[i],'point1',point1_answers_array[i]
    1630             assert allclose(line[i], point2_answers_array[i])
     1631            assert numpy.allclose(line[i], point2_answers_array[i])
    16311632                         
    16321633        # clean up
     
    17341735            line.append([float(row[0]),float(row[1]),float(row[2]),float(row[3]),float(row[4]),float(row[5])])
    17351736            #print 'assert line',line[i],'point1',point1_answers_array[i]
    1736             assert allclose(line[i], point1_answers_array[i])
     1737            assert numpy.allclose(line[i], point1_answers_array[i])
    17371738
    17381739        point2_answers_array = [[5.0,1.0,1.5,-0.5,3.0,4.0], [7.0,10.0,10.5,-0.5,3.0,4.0]]
     
    17471748            line.append([float(row[0]),float(row[1]),float(row[2]),float(row[3]),float(row[4]),float(row[5])])
    17481749            #print 'assert line',line[i],'point1',point1_answers_array[i]
    1749             assert allclose(line[i], point2_answers_array[i])
     1750            assert numpy.allclose(line[i], point2_answers_array[i])
    17501751                         
    17511752        # clean up
     
    18301831if __name__ == "__main__":
    18311832    suite = unittest.makeSuite(Test_Util,'test')
    1832 #    suite = unittest.makeSuite(Test_Util,'test_sww2csv')
     1833#    suite = unittest.makeSuite(Test_Util,'test_spatio_temporal_file_function_basic')
    18331834#    runner = unittest.TextTestRunner(verbosity=2)
    18341835    runner = unittest.TextTestRunner(verbosity=1)
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r5732 r5892  
    1515
    1616from anuga.utilities.numerical_tools import ensure_numeric
    17 from Numeric import arange, choose, zeros, Float, array, allclose, take, compress
     17import numpy
    1818   
    1919from anuga.geospatial_data.geospatial_data import ensure_absolute
     
    237237    from anuga.config import time_format
    238238    from Scientific.IO.NetCDF import NetCDFFile
    239     from Numeric import array, zeros, Float, alltrue, concatenate, reshape
     239##    from numpy.oldnumeric import array, zeros, Float, alltrue, concatenate, reshape
    240240
    241241    # Open NetCDF file
     
    303303    # Get variables
    304304    # if verbose: print 'Get variables'   
    305     time = fid.variables['time'][:]   
     305    time = numpy.array(fid.variables['time'][:]    )
    306306
    307307    # Get time independent stuff
     
    317317            triangles = fid.variables['volumes'][:]
    318318
    319         x = reshape(x, (len(x),1))
    320         y = reshape(y, (len(y),1))
    321         vertex_coordinates = concatenate((x,y), axis=1) #m x 2 array
     319        x = numpy.reshape(x, (len(x),1))
     320        y = numpy.reshape(y, (len(y),1))
     321        vertex_coordinates = numpy.concatenate((x,y), axis=1) #m x 2 array
    322322
    323323        if boundary_polygon is not None:
     
    331331            for i in range(len(boundary_polygon)):
    332332                for j in range(len(x)):
    333                     if allclose(vertex_coordinates[j],boundary_polygon[i],1e-4):
     333                    if numpy.allclose(vertex_coordinates[j],boundary_polygon[i],1e-4):
    334334                        #FIX ME:
    335335                        #currently gauges lat and long is stored as float and
     
    351351                gauge_neighbour_id.append(-1)
    352352            gauge_neighbour_id=ensure_numeric(gauge_neighbour_id)
    353             if len(compress(gauge_neighbour_id>=0,gauge_neighbour_id))!=len(temp)-1:
     353            if len(numpy.compress(gauge_neighbour_id>=0,gauge_neighbour_id))!=len(temp)-1:
    354354                msg='incorrect number of segments'
    355355                raise msg
     
    373373        # move time back - relative to domain's time
    374374        if domain_starttime > starttime:
     375##            print 'type(time)=%s' % type(time)
     376##            print 'type(domain_starttime)=%s' % type(domain_starttime)
     377##            print 'type(starttime)=%s' % type(starttime)
     378##            a = time - domain_starttime
    375379            time = time - domain_starttime + starttime
    376380
     
    398402        if boundary_polygon is not None:
    399403            #removes sts points that do not lie on boundary
    400             quantities[name] = take(quantities[name],gauge_id,1)
     404            quantities[name] = numpy.take(quantities[name], gauge_id, 1)
    401405           
    402406    # Close sww, tms or sts netcdf file         
     
    520524                raise 'Illegal input to get_textual_float:', value
    521525        else:
    522             return format %float(value)
     526            return format % float(value)
    523527
    524528
     
    10361040    """
    10371041#    from math import sqrt, atan, degrees
    1038     from Numeric import ones, allclose, zeros, Float, ravel
     1042##    from numpy.oldnumeric import ones, allclose, zeros, Float, ravel
    10391043    from os import sep, altsep, getcwd, mkdir, access, F_OK, environ
    10401044
     
    10771081    n0 = int(n0)
    10781082    m = len(locations)
    1079     model_time = zeros((n0,m,p), Float)
    1080     stages = zeros((n0,m,p), Float)
    1081     elevations = zeros((n0,m,p), Float)
    1082     momenta = zeros((n0,m,p), Float)
    1083     xmom = zeros((n0,m,p), Float)
    1084     ymom = zeros((n0,m,p), Float)
    1085     speed = zeros((n0,m,p), Float)
    1086     bearings = zeros((n0,m,p), Float)
    1087     due_east = 90.0*ones((n0,1), Float)
    1088     due_west = 270.0*ones((n0,1), Float)
    1089     depths = zeros((n0,m,p), Float)
    1090     eastings = zeros((n0,m,p), Float)
     1083    model_time = numpy.zeros((n0,m,p), numpy.float)
     1084    stages = numpy.zeros((n0,m,p), numpy.float)
     1085    elevations = numpy.zeros((n0,m,p), numpy.float)
     1086    momenta = numpy.zeros((n0,m,p), numpy.float)
     1087    xmom = numpy.zeros((n0,m,p), numpy.float)
     1088    ymom = numpy.zeros((n0,m,p), numpy.float)
     1089    speed = numpy.zeros((n0,m,p), numpy.float)
     1090    bearings = numpy.zeros((n0,m,p), numpy.float)
     1091    due_east = 90.0*numpy.ones((n0,1), numpy.float)
     1092    due_west = 270.0*numpy.ones((n0,1), numpy.float)
     1093    depths = numpy.zeros((n0,m,p), numpy.float)
     1094    eastings = numpy.zeros((n0,m,p), numpy.float)
    10911095    min_stages = []
    10921096    max_stages = []
     
    11001104    min_speeds = []   
    11011105    max_depths = []
    1102     model_time_plot3d = zeros((n0,m), Float)
    1103     stages_plot3d = zeros((n0,m), Float)
    1104     eastings_plot3d = zeros((n0,m),Float)
     1106    model_time_plot3d = numpy.zeros((n0,m), numpy.float)
     1107    stages_plot3d = numpy.zeros((n0,m), numpy.float)
     1108    eastings_plot3d = numpy.zeros((n0,m),numpy.float)
    11051109    if time_unit is 'mins': scale = 60.0
    11061110    if time_unit is 'hours': scale = 3600.0
     
    12021206                else:
    12031207                    #ax.plot_wireframe(model_time[:,:,j],eastings[:,:,j],stages[:,:,j])
    1204                     ax.plot3D(ravel(eastings[:,:,j]),ravel(model_time[:,:,j]),ravel(stages[:,:,j]))
     1208                    ax.plot3D(numpy.ravel(eastings[:,:,j]),numpy.ravel(model_time[:,:,j]),numpy.ravel(stages[:,:,j]))
    12051209                ax.set_xlabel('time')
    12061210                ax.set_ylabel('x')
     
    15011505   
    15021506    # initialise the array to easily find the index of the first loner
    1503     loners=arange(2*N, N, -1) # if N=3 [6,5,4]
     1507    loners=numpy.arange(2*N, N, -1) # if N=3 [6,5,4]
    15041508    for t in triangles:
    15051509        for vert in t:
     
    15351539        #print "loners", loners
    15361540        #print "triangles before", triangles
    1537         triangles = choose(triangles,loners)
     1541        triangles = numpy.choose(triangles,loners)
    15381542        #print "triangles after", triangles
    15391543    return verts, triangles
     
    15501554
    15511555       
    1552     xc = zeros(triangles.shape[0], Float) # Space for centroid info
     1556    xc = numpy.zeros(triangles.shape[0], numpy.float) # Space for centroid info
    15531557   
    15541558    for k in range(triangles.shape[0]):
     
    18321836                #add tide to stage if provided
    18331837                if quantity == 'stage':
    1834                      quantity_value[quantity]=array(quantity_value[quantity])+directory_add_tide
     1838                     quantity_value[quantity]=numpy.array(quantity_value[quantity])+directory_add_tide
    18351839
    18361840                #condition to find max and mins for all the plots
     
    19431947            #get data from dict in to list
    19441948            #do maths to list by changing to array
    1945             t=(array(directory_quantity_value[directory][filename]['time'])+directory_start_time)/seconds_in_minutes
     1949            t=(numpy.array(directory_quantity_value[directory][filename]['time'])+directory_start_time)/seconds_in_minutes
    19461950
    19471951            #finds the maximum elevation, used only as a test
     
    21242128    from csv import reader,writer
    21252129    from anuga.utilities.numerical_tools import ensure_numeric, mean, NAN
    2126     from Numeric import array, resize, shape, Float, zeros, take, argsort, argmin
     2130##    from numpy.oldnumeric import array, resize, shape, Float, zeros, take, argsort, argmin
    21272131    import string
    21282132    from anuga.shallow_water.data_manager import get_all_swwfiles
     
    21652169       
    21662170    #convert to array for file_function
    2167     points_array = array(points,Float)
     2171    points_array = numpy.array(points, numpy.float)
    21682172       
    21692173    points_array = ensure_absolute(points_array)
Note: See TracChangeset for help on using the changeset viewer.