Changeset 6148
- Timestamp:
- Jan 13, 2009, 12:12:15 PM (16 years ago)
- Location:
- anuga_core/source/anuga/caching
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/caching/caching.py
r6117 r6148 50 50 else: 51 51 unix = 1 52 53 import Numeric as num 54 52 55 53 56 cache_dir = '.python_cache' … … 1341 1344 1342 1345 from types import TupleType, ListType, DictType, InstanceType 1343 from Numeric import ArrayType, average1344 1345 1346 1346 1347 if type(T) in [TupleType, ListType, DictType, InstanceType]: … … 1380 1381 I.sort() 1381 1382 val = myhash(I, ids) 1382 elif type(T) == ArrayType:1383 elif type(T) == num.ArrayType: 1383 1384 # Use mean value for efficiency 1384 val = hash( average(T.flat))1385 val = hash(num.average(T.flat)) 1385 1386 elif type(T) == InstanceType: 1386 1387 val = myhash(T.__dict__, ids) … … 1406 1407 1407 1408 from types import TupleType, ListType, DictType, InstanceType 1408 from Numeric import ArrayType, alltrue1409 1409 1410 1410 # Keep track of unique id's to protect against infinite recursion … … 1449 1449 identical = compare(a, b, ids) 1450 1450 1451 elif type(A) == ArrayType:1451 elif type(A) == num.ArrayType: 1452 1452 # Use element by element comparison 1453 identical = alltrue(A==B)1453 identical = num.alltrue(A==B) 1454 1454 1455 1455 elif type(A) == InstanceType: … … 2403 2403 else: 2404 2404 # Truncate large Numeric arrays before using str() 2405 import Numeric 2406 if type(args) == Numeric.ArrayType: 2405 if type(args) == num.ArrayType: 2407 2406 # if len(args.flat) > textwidth: 2408 2407 # Changed by Duncan and Nick 21/2/07 .flat has problems with 2409 2408 # non-contigous arrays and ravel is equal to .flat except it 2410 2409 # can work with non-contiguous arrays 2411 if len( Numeric.ravel(args)) > textwidth:2410 if len(num.ravel(args)) > textwidth: 2412 2411 args = 'Array: ' + str(args.shape) 2413 2412 -
anuga_core/source/anuga/caching/test_caching.py
r5897 r6148 1 1 2 2 import unittest 3 from Numeric import arange, array4 3 5 4 from copy import deepcopy … … 7 6 from anuga.caching import * 8 7 from anuga.caching.dummy_classes_for_testing import Dummy, Dummy_memorytest 8 9 import Numeric as num 9 10 10 11 … … 128 129 129 130 # Make some test input arguments 130 A0 = arange(5)131 B0 = array([1.1, 2.2, 0.0, -5, -5])131 A0 = num.arange(5) 132 B0 = num.array([1.1, 2.2, 0.0, -5, -5]) 132 133 133 134 A1 = A0.copy() … … 172 173 173 174 # Make test input arguments 174 A0 = arange(5)*1.0175 A0 = num.arange(5)*1.0 175 176 B = ('x', 15) 176 177 177 178 # Create different A that hashes to the same address (having the same average) 178 A1 = array([2.0, 2.0, 2.0, 2.0, 2.0])179 A1 = num.array([2.0, 2.0, 2.0, 2.0, 2.0]) 179 180 180 181 assert myhash(A0) == myhash(A1) … … 389 390 A = Dummy(5, 7) 390 391 B = {'x': 10, 'A': A} 391 C = [B, array([1.2, 3, 5, 0.1])]392 C = [B, num.array([1.2, 3, 5, 0.1])] 392 393 A.value = C # Make it circular 393 394 … … 395 396 AA = Dummy(None, None) 396 397 BB = {'A': AA, 'x': 10} 397 CC = [BB, array([1.200, 3.000, 5.00, 1.0/10])]398 CC = [BB, num.array([1.200, 3.000, 5.00, 1.0/10])] 398 399 AA.value = CC # Make it circular 399 400 AA.another = 3+4
Note: See TracChangeset
for help on using the changeset viewer.