Ignore:
Timestamp:
Feb 10, 2009, 11:11:04 AM (16 years ago)
Author:
rwilson
Message:

Initial commit of numpy changes. Still a long way to go.

Location:
branches/numpy
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/mesh_engine/mesh_engine.py

    r6155 r6304  
    1111#import anuga.mesh_engine.list_dic as triang
    1212
    13 import Numeric as num
     13import numpy as num
    1414
    1515from anuga.utilities.numerical_tools import ensure_numeric
     
    4646       
    4747    try:
    48         points =  ensure_numeric(points, num.Float)
     48        points =  ensure_numeric(points, num.float)
    4949    except ValueError:
    5050        msg = 'ERROR: Inconsistent points array.'
     
    6060       
    6161    try:
    62         # If Int is used, instead of Int32, it fails in Linux
    63         segments = ensure_numeric(segments, num.Int32)
     62        # If int is used, instead of int32, it fails in Linux
     63        segments = ensure_numeric(segments, num.int32)
    6464       
    6565    except ValueError:
     
    7272       
    7373    try:
    74         holes = ensure_numeric(holes, num.Float)
     74        holes = ensure_numeric(holes, num.float)
    7575    except ValueError:
    7676        msg = 'ERROR: Inconsistent holess array.'
     
    8080    regions = add_area_tag(regions)
    8181    try:
    82         regions = ensure_numeric(regions, num.Float)
     82        regions = ensure_numeric(regions, num.float)
    8383    except  (ValueError, TypeError):
    8484        msg = 'ERROR: Inconsistent regions array.'
     
    9090   
    9191    try:
    92         pointatts = ensure_numeric(pointatts, num.Float)
     92        pointatts = ensure_numeric(pointatts, num.float)
    9393    except (ValueError, TypeError):
    9494        msg = 'ERROR: Inconsistent point attributes array.'
     
    103103   
    104104    try:
    105         segatts = ensure_numeric(segatts, num.Int32)
     105        segatts = ensure_numeric(segatts, num.int32)
    106106    except ValueError:
    107107        msg = 'ERROR: Inconsistent point attributes array.'
  • branches/numpy/anuga/mesh_engine/mesh_engine_c_layer.c

    r4917 r6304  
    88
    99    This code interfaces pmesh directly with "triangle", a general       
    10     purpose triangulation code. In doing so, Python Numeric data structures
     10    purpose triangulation code. In doing so, Python numeric data structures
    1111     are passed to C for  use by "triangle" and the results are then         
    1212    converted back. This was accomplished using the Python/C API.           
     
    6464#define PY_ARRAY_UNIQUE_SYMBOL API_YEAH
    6565//#define NO_IMPORT_ARRAY
    66 #include "Numeric/arrayobject.h"
     66#include "numpy/arrayobject.h"
    6767#include <sys/types.h>
    6868
     
    245245     abs quantity_ext.c compute_gradients
    246246     
    247   PyArray_FromDims allolws you to create a Numeric array with unitialized data.
     247  PyArray_FromDims allolws you to create a numeric array with unitialized data.
    248248   The first argument is the size of the second argument (
    249249   the dimensions array).
     
    351351 
    352352 
    353   /* These memory blocks are passed into Numeric arrays
     353  /* These memory blocks are passed into numeric arrays
    354354   so don't free them  */
    355355  /*
  • branches/numpy/anuga/mesh_engine/test_generate_mesh.py

    r6174 r6304  
    1212from anuga.mesh_engine.mesh_engine import generate_mesh
    1313
    14 import Numeric as num
     14import numpy as num
    1515
    1616from anuga.utilities.numerical_tools import ensure_numeric
     
    4343                              pointattlist,segattlist, mode, points)
    4444
    45         correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int)      #array default#
     45        correct = num.array([(1, 0, 2), (2, 3, 1)])
    4646        self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \
    4747                                    correct.flat),
    4848                        'trianglelist is wrong!')
    49         correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int)      #array default#
     49        correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)])
    5050        self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \
    5151                                    correct.flat),
     
    7474        data = generate_mesh(points,seglist,holelist,regionlist,
    7575                              pointattlist,segattlist, mode, points)
    76         correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int)      #array default#
     76        correct = num.array([(1, 0, 2), (2, 3, 1)])
    7777        self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \
    7878                                    correct.flat),
    7979                        'trianglelist is wrong!')
    80         correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int)      #array default#
     80        correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)])
    8181        self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \
    8282                                    correct.flat),
     
    154154                              pointattlist,segattlist, mode, points)
    155155
    156         correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int)      #array default#
     156        correct = num.array([(1, 0, 2), (2, 3, 1)])
    157157        self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \
    158158                                    correct.flat),
    159159                        'trianglelist is wrong!')
    160         correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int)      #array default#
     160        correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)])
    161161        self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \
    162162                                    correct.flat),
     
    170170       
    171171        self.failUnless(num.alltrue(data['generatedsegmentmarkerlist'] == \
    172                                     num.array([1,2,3,4], num.Int)),      #array default#
     172                                    num.array([1,2,3,4])),
    173173                        'Failed!')
    174174       
     
    388388
    389389     
    390         correct = num.array([(1, 0, 2), (2, 3, 1)], num.Int)      #array default#
     390        correct = num.array([(1, 0, 2), (2, 3, 1)])
    391391        self.failUnless(num.alltrue(data['generatedtrianglelist'].flat == \
    392392                                    correct.flat),
    393393                        'trianglelist is wrong!')
    394         correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int)      #array default#
     394        correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)])
    395395        self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \
    396396                                    correct.flat),
     
    407407                                     correct.flat),
    408408                        'Failed')
    409         correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)], num.Int)      #array default#
     409        correct = num.array([(0, 1), (1, 3), (3, 2), (2, 0)])
    410410        self.failUnless(num.alltrue(data['generatedsegmentlist'].flat == \
    411411                                    correct.flat),
    412412                        'Failed!')
    413413       
    414         correct = num.array(segattlist, num.Int)      #array default#
     414        correct = num.array(segattlist)
    415415        self.failUnless(num.allclose(data['generatedsegmentmarkerlist'].flat,
    416416                                     correct.flat),
     
    418418       
    419419        # I copied these answers from the output, so bad test..
    420         correct = num.array([(-1, 1, -1), (-1, 0, -1)], num.Int)      #array default#
     420        correct = num.array([(-1, 1, -1), (-1, 0, -1)])
    421421        self.failUnless(num.alltrue(data['generatedtriangleneighborlist'].flat == \
    422422                                    correct.flat),
     
    467467
    468468    suite = unittest.makeSuite(triangTestCase,'test')
    469     #suite = unittest.makeSuite(triangTestCase,'testrectangleIIb')
    470     #suite = unittest.makeSuite(triangTestCase,'testsegmarker')
    471     #suite = unittest.makeSuite(triangTestCase,'testrectangle_regionsII')
    472469    runner = unittest.TextTestRunner()  #verbosity=2)
    473470    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.