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?.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.