Changeset 5908


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

NumPy? conversion.

Location:
anuga_core/source_numpy_conversion/anuga/advection
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source_numpy_conversion/anuga/advection/advection.py

    r5847 r5908  
    2020"""
    2121
     22import numpy
    2223
    2324#import logging, logging.config
     
    6667                                numproc=numproc)
    6768
    68         import Numeric
    6969        if velocity is None:
    70             self.velocity = Numeric.array([1,0],'d')
     70            self.velocity = numpy.array([1,0],'d')
    7171        else:
    72             self.velocity = Numeric.array(velocity,'d')
     72            self.velocity = numpy.array(velocity,'d')
    7373
    7474        #Only first is implemented for advection
     
    155155
    156156        import sys
    157         from Numeric import zeros, Float
    158157        from anuga.config import max_timestep
    159158
     
    228227
    229228        import sys
    230         from Numeric import zeros, Float
    231229        from anuga.config import max_timestep
    232230
     
    251249        stage_bdry = Stage.boundary_values
    252250
    253         flux = zeros(1, Float) #Work array for summing up fluxes
     251        flux = numpy.zeros(1, numpy.float) #Work array for summing up fluxes
    254252
    255253        #Loop
  • anuga_core/source_numpy_conversion/anuga/advection/advection_ext.c

    r5162 r5908  
    1010
    1111#include "Python.h"
    12 #include "Numeric/arrayobject.h"
     12#include "numpy/arrayobject.h"
    1313#include "math.h"
    1414#include "stdio.h"
  • anuga_core/source_numpy_conversion/anuga/advection/test_advection.py

    r5242 r5908  
    66
    77from anuga.config import g, epsilon
    8 from Numeric import allclose, array, zeros, ones, Float
     8import numpy
    99from anuga.advection.advection import Domain, Transmissive_boundary, Dirichlet_boundary
    1010
     
    4848
    4949        #Populate boundary array with dirichlet conditions.
    50         domain.neighbours = array([[-1,-2,-3]])
     50        domain.neighbours = numpy.array([[-1,-2,-3]])
    5151        domain.quantities['stage'].boundary_values[:] = 1.0
    5252
     
    102102
    103103        #Populate boundary array with dirichlet conditions.
    104         domain.neighbours = array([[-1,-2,-3]])
     104        domain.neighbours = numpy.array([[-1,-2,-3]])
    105105        domain.quantities['stage'].boundary_values[0] = 1.0
    106106
     
    111111        domain.compute_fluxes()
    112112        U = domain.quantities['stage'].explicit_update
    113         assert allclose(U, 0)
     113        assert numpy.allclose(U, 0)
    114114
    115115
     
    133133
    134134        #Populate boundary array with dirichlet conditions.
    135         domain.neighbours = array([[1,-1,-2], [0,-3,-4]])
     135        domain.neighbours = numpy.array([[1,-1,-2], [0,-3,-4]])
    136136        domain.set_quantity('stage', [1.0, 0.0], location='centroids')
    137137        domain.distribute_to_vertices_and_edges()
     
    157157        #Boundaries
    158158        T = Transmissive_boundary(domain)
    159         D = Dirichlet_boundary(array([3.1415]))
     159        D = Dirichlet_boundary(numpy.array([3.1415]))
    160160
    161161        domain.set_boundary( {'left': D, 'right': T, 'bottom': T, 'top': T} )
     
    164164        #Check that the boundary value gets propagated to all elements
    165165        for t in domain.evolve(yieldstep = 0.05, finaltime = 10):
    166             if allclose(domain.quantities['stage'].centroid_values, 3.1415):
     166            if numpy.allclose(domain.quantities['stage'].centroid_values, 3.1415):
    167167                break
    168168
    169         assert allclose(domain.quantities['stage'].centroid_values, 3.1415)
     169        assert numpy.allclose(domain.quantities['stage'].centroid_values, 3.1415)
    170170
    171171
Note: See TracChangeset for help on using the changeset viewer.