Changeset 5889 for anuga_core/source_numpy_conversion/anuga
- Timestamp:
- Nov 5, 2008, 9:15:55 AM (16 years ago)
- Location:
- anuga_core/source_numpy_conversion/anuga/utilities
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/utilities/cg_solve.py
r2841 r5889 1 1 2 import exceptions 2 3 class VectorShapeError(exceptions.Exception): pass 3 4 class ConvergenceError(exceptions.Exception): pass 4 5 5 from Numeric import dot, array, Float, zeros 6 ##from numpy.oldnumeric import dot, array, Float, zeros 7 from numpy import dot, array, float, zeros 6 8 7 9 import logging, logging.config … … 24 26 25 27 if x0 is None: 26 x0 = zeros(b.shape, typecode=Float)28 x0 = zeros(b.shape, dtype=float) 27 29 else: 28 x0 = array(x0, typecode=Float)30 x0 = array(x0, dtype=float) 29 31 30 b = array(b, typecode=Float)32 b = array(b, dtype=float) 31 33 if len(b.shape) != 1 : 32 34 … … 57 59 58 60 59 b = array(b, typecode=Float)61 b = array(b, dtype=float) 60 62 if len(b.shape) != 1 : 61 63 raise VectorShapeError, 'input vector should consist of only one column' 62 64 63 65 if x0 is None: 64 x0 = zeros(b.shape, typecode=Float)66 x0 = zeros(b.shape, dtype=float) 65 67 else: 66 x0 = array(x0, typecode=Float)68 x0 = array(x0, dtype=float) 67 69 68 70 -
anuga_core/source_numpy_conversion/anuga/utilities/compile.py
r5138 r5889 10 10 Ole Nielsen, Duncan Gray Oct 2001 11 11 """ 12 13 #NumPy ------------------------------------ 14 # these lines recommended in "Converting from NUMARRAY to NUMPY" 15 import numpy 16 import numpy.numarray as nn 17 numpyincludedirs = numpy.get_include() 18 numarrayincludedirs = nn.get_numarray_include_dirs() 19 I_dirs = '-I"%s" ' % numpyincludedirs 20 for d in numarrayincludedirs: 21 I_dirs += '-I"%s" ' % d 22 #NumPy ------------------------------------ 12 23 13 24 # FIXME (Ole): Although this script says it works with a range of compilers, … … 255 266 else: 256 267 if FN == "triangle.c" or FN == "mesh_engine_c_layer.c": 257 s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -O3 -DTRILIBRARY=1 -DNO_TIMER=1'\ 258 %(compiler, FN, python_include, utilities_include_dir, root) 268 #NumPy s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -O3 -DTRILIBRARY=1 -DNO_TIMER=1'\ 269 s = '%s -c %s %s -I"%s" -I"%s" -o "%s.o" -O3 -DTRILIBRARY=1 -DNO_TIMER=1'\ 270 %(compiler, FN, I_dirs, python_include, utilities_include_dir, root) 259 271 else: 260 s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -Wall -O3'\ 261 %(compiler, FN, python_include, utilities_include_dir, root) 272 #NumPy s = '%s -c %s -I"%s" -I"%s" -o "%s.o" -Wall -O3'\ 273 s = '%s -c %s %s -I"%s" -I"%s" -o "%s.o" -Wall -O3'\ 274 %(compiler, FN, I_dirs, python_include, utilities_include_dir, root) 262 275 263 276 if os.name == 'posix' and os.uname()[4] == 'x86_64': -
anuga_core/source_numpy_conversion/anuga/utilities/interp.py
r5681 r5889 1 ## Automatically adapted for numpy.oldnumeric Oct 28, 2008 by alter_code1.py 2 1 3 #!/usr/bin/python -tt 2 4 #======================================================================= … … 111 113 112 114 >>> from interp import interp 113 >>> import Numeric as N115 >>> import numpy.oldnumeric as N 114 116 >>> x = N.array([1., 2., 3., 4., 5.]) 115 117 >>> y = N.array([3., 6., 2.,-5.,-3.]) … … 138 140 """ 139 141 import arrayfns 140 import MA 141 import Numeric as N 142 ## import numpy.oldnumeric.ma as MA 143 ## import numpy.oldnumeric as N 144 import numpy.ma as MA 145 import numpy as N 142 146 from where_close import where_close 143 147 … … 216 220 217 221 >>> from interp import interp 218 >>> import Numeric as N222 >>> import numpy.oldnumeric as N 219 223 >>> x = N.array([1., 2., 3., 4., 5., 6.]) 220 224 >>> y = N.array([3., 1e+20, 2., -5., -3., -4.]) … … 284 288 >>> ['%.7g' % yint[i] for i in range(len(yint))] 285 289 ['3.4', '2.3'] 286 >>> yint. typecode()290 >>> yint.dtype.char 287 291 'd' 288 292 >>> x = N.arange(6) … … 292 296 >>> ['%.7g' % yint[i] for i in range(len(yint))] 293 297 ['3', '2'] 294 >>> yint. typecode()298 >>> yint.dtype.char 295 299 'd' 296 300 """} -
anuga_core/source_numpy_conversion/anuga/utilities/numerical_tools.py
r5729 r5889 14 14 #except: 15 15 # #print 'Could not find scipy - using Numeric' 16 # from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt,16 # from numpy.oldnumeric import ArrayType, array, sum, innerproduct, ravel, sqrt, 17 17 #searchsorted, sort, concatenate, Float, arange 18 18 19 from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt,\ 20 searchsorted, sort, concatenate, Float, arange 19 ##from numpy.oldnumeric import ArrayType, array, sum, innerproduct, ravel, sqrt,\ 20 ## searchsorted, sort, concatenate, Float, arange 21 from numpy import ndarray, array, sum, inner, ravel, sqrt, searchsorted, sort, concatenate, float, arange 21 22 22 23 # Getting an infinite number to use when using Numeric … … 89 90 v2 = [1.0, 0.0] # Unit vector along the x-axis 90 91 91 v1 = ensure_numeric(v1, Float)92 v2 = ensure_numeric(v2, Float)92 v1 = ensure_numeric(v1, float) 93 v2 = ensure_numeric(v2, float) 93 94 94 95 # Normalise … … 97 98 98 99 # Compute angle 99 p = inner product(v1, v2)100 c = inner product(v1, normal_vector(v2)) # Projection onto normal100 p = inner(v1, v2) 101 c = inner(v1, normal_vector(v2)) # Projection onto normal 101 102 # (negative cross product) 102 103 … … 140 141 """ 141 142 142 return array([-v[1], v[0]], Float)143 return array([-v[1], v[0]], float) 143 144 144 145 … … 171 172 cy = y - mean(y) 172 173 173 p = inner product(cx,cy)/N174 p = inner(cx,cy)/N 174 175 return(p) 175 176 … … 221 222 222 223 y = ravel(x) 223 p = sqrt(inner product(y,y))224 p = sqrt(inner(y,y)) 224 225 return p 225 226 … … 262 263 263 264 if typecode is None: 264 if type(A) == ArrayType: 265 ##NumPy if isinstance(A, ArrayType): 266 if type(A) == ndarray: 265 267 return A 266 268 else: 267 269 return array(A) 268 270 else: 269 if type(A) == ArrayType: 270 if A.typecode == typecode: 271 ##NumPy if isinstance(A, ArrayType): 272 if type(A) == ndarray: 273 ##NumPy if A.typecode == typecode: 274 if A.dtype == typecode: 271 275 return array(A) #FIXME: Shouldn't this just return A? 272 276 else: 273 return array(A, typecode)277 return array(A, typecode) 274 278 else: 275 return array(A,typecode) 276 279 import types ## 280 from numpy import str ## 281 if isinstance(A, types.StringType): ## 282 return array(A, dtype=int) ## 283 return array(A, typecode) 277 284 278 285 -
anuga_core/source_numpy_conversion/anuga/utilities/polygon.py
r5658 r5889 10 10 # #print 'Could not find scipy - using Numeric' 11 11 12 from Numeric import Float, Int, zeros, ones, array, concatenate, reshape, dot, allclose12 from numpy import float, int, zeros, ones, array, concatenate, reshape, dot, allclose, newaxis, ascontiguousarray 13 13 14 14 … … 76 76 # FIXME (Ole): Write this in C 77 77 78 line0 = ensure_numeric(line0, Float)79 line1 = ensure_numeric(line1, Float)78 line0 = ensure_numeric(line0, float) 79 line1 = ensure_numeric(line1, float) 80 80 81 81 x0 = line0[0,0]; y0 = line0[0,1] … … 203 203 204 204 205 line0 = ensure_numeric(line0, Float)206 line1 = ensure_numeric(line1, Float)205 line0 = ensure_numeric(line0, float) 206 line1 = ensure_numeric(line1, float) 207 207 208 208 status, value = _intersection(line0[0,0], line0[0,1], … … 256 256 # converted to a numeric array. 257 257 msg = 'Points could not be converted to Numeric array' 258 raise msg258 raise TypeError, msg 259 259 260 260 try: … … 265 265 # If this fails it is going to be because the points can't be 266 266 # converted to a numeric array. 267 msg = 'Polygon %s could not be converted to Numeric array' % (str(polygon))268 raise msg267 msg = 'Polygon %s could not be converted to Numeric array' % (str(polygon)) 268 raise TypeError, msg 269 269 270 270 if len(points.shape) == 1: … … 312 312 #if verbose: print 'Checking input to outside_polygon' 313 313 try: 314 points = ensure_numeric(points, Float)314 points = ensure_numeric(points, float) 315 315 except NameError, e: 316 316 raise NameError, e … … 320 320 321 321 try: 322 polygon = ensure_numeric(polygon, Float)322 polygon = ensure_numeric(polygon, float) 323 323 except NameError, e: 324 324 raise NameError, e … … 354 354 #if verbose: print 'Checking input to outside_polygon' 355 355 try: 356 points = ensure_numeric(points, Float)356 points = ensure_numeric(points, float) 357 357 except NameError, e: 358 358 raise NameError, e … … 362 362 363 363 try: 364 polygon = ensure_numeric(polygon, Float)364 polygon = ensure_numeric(polygon, float) 365 365 except NameError, e: 366 366 raise NameError, e … … 439 439 assert isinstance(verbose, bool), 'Keyword argument "verbose" must be boolean' 440 440 441 441 ## print 'Before: points=%s, flags=%s' % (type(points), str(points.flags)) 442 442 try: 443 points = ensure_numeric(points, Float) 443 ## points = ascontiguousarray(ensure_numeric(points, float)) 444 points = ensure_numeric(points, float) 444 445 except NameError, e: 445 446 raise NameError, e 446 447 except: 447 448 msg = 'Points could not be converted to Numeric array' 448 raise msg 449 raise TypeError, msg 450 ## print 'After: points=%s, flags=%s' % (type(points), str(points.flags)) 449 451 450 452 #if verbose: print 'Checking input to separate_points_by_polygon 2' 451 453 try: 452 polygon = ensure_numeric(polygon, Float) 454 ## polygon = ascontiguousarray(ensure_numeric(polygon, float)) 455 polygon = ensure_numeric(polygon, float) 453 456 except NameError, e: 454 457 raise NameError, e 455 458 except: 456 459 msg = 'Polygon could not be converted to Numeric array' 457 raise msg460 raise TypeError, msg 458 461 459 462 msg = 'Polygon array must be a 2d array of vertices' … … 476 479 477 480 msg = 'Point array must have two columns (x,y), ' 478 msg += 'I got points.shape[1] == %d' % points.shape[0]481 msg += 'I got points.shape[1] == %d' % points.shape[1] 479 482 assert points.shape[1] == 2, msg 480 483 … … 491 494 492 495 493 indices = zeros( M, Int )496 indices = zeros( M, int ) 494 497 495 498 count = _separate_points_by_polygon(points, polygon, indices, … … 618 621 619 622 try: 620 polygon = ensure_numeric(polygon, Float)623 polygon = ensure_numeric(polygon, float) 621 624 except NameError, e: 622 625 raise NameError, e … … 680 683 """ 681 684 682 def __init__(self, regions, default=0.0, geo_reference=None ):685 def __init__(self, regions, default=0.0, geo_reference=None, verbose=False): 683 686 684 687 try: … … 723 726 self.regions.append( (P, value) ) 724 727 728 self.verbose = verbose 729 725 730 726 731 727 732 728 733 def __call__(self, x, y): 729 x = array(x).astype(Float) 730 y = array(y).astype(Float) 731 732 N = len(x) 733 assert len(y) == N 734 735 points = concatenate( (reshape(x, (N, 1)), 736 reshape(y, (N, 1))), axis=1 ) 737 734 x = array(x).astype(float) 735 y = array(y).astype(float) 736 737 assert len(x.shape) == 1 and len(y.shape) == 1 738 739 N = x.shape[0] 740 assert y.shape[0] == N 741 742 points = ascontiguousarray(concatenate( (x[:,newaxis], y[:,newaxis]), axis=1 )) 743 738 744 if callable(self.default): 739 z = self.default(x, y)745 z = self.default(x, y) 740 746 else: 741 z = ones(N, Float) * self.default747 z = ones(N, float) * self.default 742 748 743 749 for polygon, value in self.regions: 744 indices = inside_polygon(points, polygon )750 indices = inside_polygon(points, polygon, verbose=self.verbose) 745 751 746 752 # FIXME: This needs to be vectorised -
anuga_core/source_numpy_conversion/anuga/utilities/polygon_ext.c
r5570 r5889 15 15 16 16 #include "Python.h" 17 #include " Numeric/arrayobject.h"17 #include "numpy/arrayobject.h" 18 18 #include "math.h" 19 19 … … 222 222 } 223 223 for (k=0; k<M; k++) { 224 x = points[2*k]; 225 y = points[2*k + 1]; 226 224 227 if (verbose){ 225 if (k %((M+10)/10)==0) printf("Doing %d of %d \n", k, M);228 if (k %((M+10)/10)==0) printf("Doing %d of %d, x=%f, y=%f\n", k, M, x, y); 226 229 } 227 230 228 x = points[2*k];229 y = points[2*k + 1];230 231 231 inside = 0; 232 232 … … 376 376 *polygon, 377 377 *indices; 378 // PyObject *xxxx; 378 379 379 380 int closed, verbose; //Flags … … 393 394 return NULL; 394 395 } 396 397 // points = (PyArrayObject *) PyArray_ContiguousFromObject(xxxx, PyArray_DOUBLE, 1, 1); 395 398 396 399 M = points -> dimensions[0]; //Number of points -
anuga_core/source_numpy_conversion/anuga/utilities/quad.py
r4932 r5889 1 1 2 """quad.py - quad tree data structure for fast indexing of points in the plane 2 3 … … 222 223 triangles = {} 223 224 verts = self.retrieve_vertices() 224 #print "verts", verts225 print "verts", verts 225 226 for vert in verts: 226 227 triangle_list = self.mesh.get_triangles_and_vertices_per_node(vert) 228 print 'triangle_list=%s' % str(triangle_list) 227 229 for k, _ in triangle_list: 228 230 if not triangles.has_key(k): 229 231 # print 'k',k 230 tri = self.mesh.get_vertex_coordinates(k, 231 absolute=True) 232 tri = self.mesh.get_vertex_coordinates(k, absolute=True) 232 233 n0 = self.mesh.get_normal(k, 0) 233 234 n1 = self.mesh.get_normal(k, 1) … … 435 436 """ 436 437 437 from Numericimport minimum, maximum438 from numpy import minimum, maximum 438 439 439 440 -
anuga_core/source_numpy_conversion/anuga/utilities/sparse.py
r5223 r5889 1 1 2 """Proof of concept sparse matrix code 2 3 """ … … 17 18 18 19 if len(args) == 1: 19 from Numericimport array20 from numpy import array 20 21 try: 21 22 A = array(args[0]) … … 92 93 93 94 def todense(self): 94 from Numeric import zeros, Float95 96 D = zeros( (self.M, self.N), Float)95 from numpy import zeros, float 96 97 D = zeros( (self.M, self.N), float) 97 98 98 99 for i in range(self.M): … … 109 110 """ 110 111 111 from Numeric import array, zeros, Float112 from numpy import array, zeros, float 112 113 113 114 try: … … 130 131 assert B.shape[0] == self.N, msg 131 132 132 R = zeros(self.M, Float) #Result133 R = zeros(self.M, float) #Result 133 134 134 135 # Multiply nonzero elements … … 140 141 141 142 142 R = zeros((self.M, B.shape[1]), Float) #Result matrix143 R = zeros((self.M, B.shape[1]), float) #Result matrix 143 144 144 145 # Multiply nonzero elements … … 162 163 """ 163 164 164 from Numeric import array, zeros, Float165 166 165 new = other.copy() 167 166 for key in self.Data.keys(): … … 177 176 """ 178 177 179 from Numeric import array, zeros, Float180 181 178 try: 182 179 other = float(other) … … 200 197 """ 201 198 202 from Numeric import array, zeros, Float199 from numpy import array, zeros, float 203 200 204 201 try: … … 214 211 assert B.shape[0] == self.M, 'Mismatching dimensions' 215 212 216 R = zeros((self.N,), Float) #Result213 R = zeros((self.N,), float) #Result 217 214 218 215 #Multiply nonzero elements … … 251 248 """ 252 249 253 from Numeric import array, Float, Int250 from numpy import zeros, float, int 254 251 255 252 if isinstance(A,Sparse): 256 253 257 from Numeric import zeros258 254 keys = A.Data.keys() 259 255 keys.sort() 260 256 nnz = len(keys) 261 data = zeros ( (nnz,), Float)262 colind = zeros ( (nnz,), Int)263 row_ptr = zeros ( (A.M+1,), Int)257 data = zeros ( (nnz,), float) 258 colind = zeros ( (nnz,), int) 259 row_ptr = zeros ( (A.M+1,), int) 264 260 current_row = -1 265 261 k = 0 … … 299 295 300 296 def todense(self): 301 from Numeric import zeros, Float297 from numpy.oldnumeric import zeros, Float 302 298 303 299 D = zeros( (self.M, self.N), Float) … … 314 310 """ 315 311 316 from Numeric import array, zeros, Float312 from numpy.oldnumeric import array, zeros, Float 317 313 318 314 try: … … 334 330 # A little selftest 335 331 336 from Numeric import allclose, array, Float332 from numpy.oldnumeric import allclose, array, Float 337 333 338 334 A = Sparse(3,3) -
anuga_core/source_numpy_conversion/anuga/utilities/sparse_ext.c
r3730 r5889 11 11 12 12 #include "Python.h" 13 #include " Numeric/arrayobject.h"13 #include "numpy/arrayobject.h" 14 14 #include "math.h" 15 15 #include "stdio.h" -
anuga_core/source_numpy_conversion/anuga/utilities/test_cg_solve.py
r3514 r5889 6 6 7 7 8 from Numeric import dot, allclose, array, transpose, arange, ones, Float8 from numpy import dot, allclose, array, transpose, arange, ones, float 9 9 from anuga.utilities.cg_solve import * 10 10 from anuga.utilities.cg_solve import _conjugate_gradient … … 68 68 A[i,i+1] = -0.5 69 69 70 xe = ones( (n,), Float)70 xe = ones( (n,), float) 71 71 72 72 b = A*xe … … 96 96 A[I,I+1] = -1.0 97 97 98 xe = ones( (n*m,), Float)98 xe = ones( (n*m,), float) 99 99 100 100 b = A*xe … … 125 125 A[I,I+1] = -1.0 126 126 127 xe = ones( (n*m,), Float)127 xe = ones( (n*m,), float) 128 128 129 129 # Convert to csr format … … 158 158 A[I,I+1] = -1.0 159 159 160 xe = ones( (n*m,), Float)160 xe = ones( (n*m,), float) 161 161 162 162 b = A*xe -
anuga_core/source_numpy_conversion/anuga/utilities/test_data_audit.py
r5096 r5889 3 3 4 4 import unittest 5 from Numeric import zeros, array, allclose, Float5 from numpy.oldnumeric import zeros, array, allclose 6 6 from tempfile import mkstemp 7 7 import os -
anuga_core/source_numpy_conversion/anuga/utilities/test_numerical_tools.py
r5870 r5889 3 3 4 4 import unittest 5 from Numericimport zeros, array, allclose6 from Numeric import ArrayType, Float, Int, array, alltrue5 from numpy import zeros, array, allclose 6 from numpy import ndarray, float, int, array, alltrue 7 7 8 8 from math import sqrt, pi … … 68 68 A = [1,2,3,4] 69 69 B = ensure_numeric(A) 70 assert type(B) == ArrayType71 assert B. typecode()== 'l'70 assert isinstance(B, ndarray) 71 assert B.dtype.char == 'l' 72 72 assert B[0] == 1 and B[1] == 2 and B[2] == 3 and B[3] == 4 73 73 74 74 A = [1,2,3.14,4] 75 75 B = ensure_numeric(A) 76 assert type(B) == ArrayType77 assert B. typecode()== 'd'76 assert isinstance(B, ndarray) 77 assert B.dtype.char == 'd' 78 78 assert B[0] == 1 and B[1] == 2 and B[2] == 3.14 and B[3] == 4 79 79 80 80 A = [1,2,3,4] 81 B = ensure_numeric(A, Float)82 assert type(B) == ArrayType83 assert B. typecode()== 'd'81 B = ensure_numeric(A, float) 82 assert isinstance(B, ndarray) 83 assert B.dtype.char == 'd' 84 84 assert B[0] == 1.0 and B[1] == 2.0 and B[2] == 3.0 and B[3] == 4.0 85 85 86 86 A = [1,2,3,4] 87 B = ensure_numeric(A, Float)88 assert type(B) == ArrayType89 assert B. typecode()== 'd'87 B = ensure_numeric(A, float) 88 assert isinstance(B, ndarray) 89 assert B.dtype.char == 'd' 90 90 assert B[0] == 1.0 and B[1] == 2.0 and B[2] == 3.0 and B[3] == 4.0 91 91 92 92 A = array([1,2,3,4]) 93 93 B = ensure_numeric(A) 94 assert type(B) == ArrayType95 assert B. typecode()== 'l'94 assert isinstance(B, ndarray) 95 assert B.dtype.char == 'l' 96 96 assert alltrue(A == B) 97 97 assert A is B #Same object 98 98 99 99 A = array([1,2,3,4]) 100 B = ensure_numeric(A, Float)101 assert type(B) == ArrayType102 assert B. typecode()== 'd'100 B = ensure_numeric(A, float) 101 assert isinstance(B, ndarray) 102 assert B.dtype.char == 'd' 103 103 assert alltrue(A == B) 104 104 assert A is not B #Not the same object … … 106 106 # Check scalars 107 107 A = 1 108 B = ensure_numeric(A, Float)108 B = ensure_numeric(A, float) 109 109 #print A, B[0], len(B), type(B) 110 110 #print B.shape 111 111 assert alltrue(A == B) 112 112 113 B = ensure_numeric(A, Int)113 B = ensure_numeric(A, int) 114 114 #print A, B 115 115 #print B.shape 116 116 assert alltrue(A == B) 117 117 118 def NO_test_ensure_numeric_char(self): 118 119 # Error situation 119 120 B = ensure_numeric('hello', Int)120 B = ensure_numeric('hello', int) 121 print 'B=%s %s' % (str(B), type(B)) 121 122 assert allclose(B, [104, 101, 108, 108, 111]) 122 123 … … 160 161 zx, zy = gradient(x0, y0, x1, y1, x2, y2, z0, z1, z2) 161 162 a, b = gradient2(x0, y0, x1, y1, z0, z1) 162 163 163 164 assert zx == a 164 165 assert zy == b … … 281 282 from util_ext import gradient as gradient_c 282 283 283 from RandomArrayimport uniform, seed284 seed( 17, 53)284 from numpy.random import uniform, seed 285 seed(53) # numeric was seed(17, 53) 285 286 286 287 x0, x1, x2, y0, y1, y2 = uniform(0.0,3.0,6) … … 312 313 # sqrt(sum_over_x&y((xi - yi)^2)) 313 314 err__1 = err(x,y,2,False) 315 314 316 assert err__1 == sqrt(20) 315 317 #print "err_", err_ -
anuga_core/source_numpy_conversion/anuga/utilities/test_polygon.py
r5403 r5889 3 3 4 4 import unittest 5 from Numeric import zeros, array, allclose5 from numpy import zeros, array, allclose, alltrue 6 6 from math import sqrt, pi 7 7 from anuga.utilities.numerical_tools import ensure_numeric … … 43 43 p2 = [[0,0], [10,10], [15,5], [20, 10], [25,0], [30,10], [40,-10]] 44 44 45 f = Polygon_function( [(p1, 1.0)] )45 f = Polygon_function( [(p1, 1.0)], verbose=False ) 46 46 z = f([5, 5, 27, 35], [5, 9, 8, -5]) #Two first inside p1 47 47 assert allclose(z, [1,1,0,0]) … … 57 57 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 58 58 assert allclose(z, [2,1,0,2]) 59 60 61 def test_polygon_function_constants_tuple(self): 62 polygon = [[0,0], [10,0], [10,10], [0,10]] 63 points = ((5, 5), (5, 9), (27, 8), (35, -5)) 64 65 (indices, count) = separate_points_by_polygon(points, polygon, verbose=False) 59 66 60 67 def test_polygon_function_csvfile(self): … … 210 217 res = inside_polygon(points, polygon) 211 218 assert len(res) == 2 212 assert allclose(res, [0,1]) 219 assert allclose(res, [0,1]) ## alltrue? 213 220 214 221 … … 990 997 if __name__ == "__main__": 991 998 suite = unittest.makeSuite(Test_Polygon,'test') 992 #suite = unittest.makeSuite(Test_Polygon,'test_inside_polygon_geo_ref')999 ## suite = unittest.makeSuite(Test_Polygon,'test_polygon_function_constantsX') 993 1000 runner = unittest.TextTestRunner() 994 1001 runner.run(suite) -
anuga_core/source_numpy_conversion/anuga/utilities/test_quad.py
r4741 r5889 1 1 import unittest 2 from Numericimport array, allclose2 from numpy import array, allclose 3 3 4 4 from quad import Cell, build_quadtree -
anuga_core/source_numpy_conversion/anuga/utilities/test_sparse.py
r2527 r5889 5 5 6 6 from sparse import * 7 from Numeric import allclose, array, transpose, Float7 from numpy.oldnumeric import allclose, array, transpose 8 8 9 9 class Test_Sparse(unittest.TestCase): -
anuga_core/source_numpy_conversion/anuga/utilities/test_system_tools.py
r5398 r5889 3 3 4 4 import unittest 5 from Numeric import zeros, array, allclose, Float5 from numpy import zeros, array, allclose, float, dtype 6 6 import zlib 7 7 from os.path import join, split, sep … … 87 87 fid = NetCDFFile(filename1, 'w') 88 88 fid.createDimension('two', 2) 89 fid.createVariable('test_array', Float, 90 ('two', 'two')) 89 fid.createVariable('test_array', dtype(float).char, ('two', 'two')) 91 90 fid.variables['test_array'][:] = test_array 92 91 fid.close() … … 96 95 fid = NetCDFFile(filename2, 'w') 97 96 fid.createDimension('two', 2) 98 fid.createVariable('test_array', Float, 99 ('two', 'two')) 97 fid.createVariable('test_array', dtype(float).char, ('two', 'two')) 100 98 fid.variables['test_array'][:] = test_array 101 99 fid.close() -
anuga_core/source_numpy_conversion/anuga/utilities/test_xml_tools.py
r5022 r5889 3 3 4 4 import unittest 5 from Numeric import zeros, array, allclose, Float6 5 from tempfile import mkstemp, mktemp 7 6 -
anuga_core/source_numpy_conversion/anuga/utilities/util_ext.c
r3730 r5889 16 16 17 17 #include "Python.h" 18 #include " Numeric/arrayobject.h"18 #include "numpy/arrayobject.h" 19 19 #include "math.h" 20 20 -
anuga_core/source_numpy_conversion/anuga/utilities/util_ext.h
r5743 r5889 11 11 12 12 #include "Python.h" 13 #include " Numeric/arrayobject.h"13 #include "numpy/arrayobject.h" 14 14 #include "math.h" 15 15
Note: See TracChangeset
for help on using the changeset viewer.