Changeset 6148


Ignore:
Timestamp:
Jan 13, 2009, 12:12:15 PM (15 years ago)
Author:
rwilson
Message:

Change Numeric imports to general form - ready to change to NumPy?.

Location:
anuga_core/source/anuga/caching
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/caching/caching.py

    r6117 r6148  
    5050else:
    5151  unix = 1
     52
     53import Numeric as num
     54
    5255
    5356cache_dir = '.python_cache'
     
    13411344
    13421345  from types import TupleType, ListType, DictType, InstanceType 
    1343   from Numeric import ArrayType, average
    1344 
    13451346   
    13461347  if type(T) in [TupleType, ListType, DictType, InstanceType]: 
     
    13801381      I.sort()   
    13811382      val = myhash(I, ids)
    1382   elif type(T) == ArrayType:
     1383  elif type(T) == num.ArrayType:
    13831384      # Use mean value for efficiency 
    1384       val = hash(average(T.flat))
     1385      val = hash(num.average(T.flat))
    13851386  elif type(T) == InstanceType:
    13861387      val = myhash(T.__dict__, ids)
     
    14061407
    14071408    from types import TupleType, ListType, DictType, InstanceType
    1408     from Numeric import ArrayType, alltrue   
    14091409   
    14101410    # Keep track of unique id's to protect against infinite recursion
     
    14491449            identical = compare(a, b, ids)
    14501450           
    1451     elif type(A) == ArrayType:
     1451    elif type(A) == num.ArrayType:
    14521452        # Use element by element comparison
    1453         identical = alltrue(A==B)
     1453        identical = num.alltrue(A==B)
    14541454
    14551455    elif type(A) == InstanceType:
     
    24032403    else:
    24042404      # Truncate large Numeric arrays before using str()
    2405       import Numeric
    2406       if type(args) == Numeric.ArrayType:
     2405      if type(args) == num.ArrayType:
    24072406#        if len(args.flat) > textwidth: 
    24082407#        Changed by Duncan and Nick 21/2/07 .flat has problems with
    24092408#        non-contigous arrays and ravel is equal to .flat except it
    24102409#        can work with non-contiguous  arrays
    2411         if len(Numeric.ravel(args)) > textwidth:
     2410        if len(num.ravel(args)) > textwidth:
    24122411          args = 'Array: ' + str(args.shape)
    24132412
  • anuga_core/source/anuga/caching/test_caching.py

    r5897 r6148  
    11
    22import unittest
    3 from Numeric import arange, array
    43
    54from copy import deepcopy
     
    76from anuga.caching import *
    87from anuga.caching.dummy_classes_for_testing import Dummy, Dummy_memorytest
     8
     9import Numeric as num
    910
    1011
     
    128129       
    129130        # 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])
    132133       
    133134        A1 = A0.copy()
     
    172173       
    173174        # Make test input arguments
    174         A0 = arange(5)*1.0
     175        A0 = num.arange(5)*1.0
    175176        B = ('x', 15)
    176177       
    177178        # 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])       
    179180       
    180181        assert myhash(A0) == myhash(A1)
     
    389390        A = Dummy(5, 7)
    390391        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])]
    392393        A.value = C # Make it circular
    393394
     
    395396        AA = Dummy(None, None)
    396397        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])]
    398399        AA.value = CC # Make it circular
    399400        AA.another = 3+4       
Note: See TracChangeset for help on using the changeset viewer.