Changeset 9551


Ignore:
Timestamp:
Jan 30, 2015, 12:00:06 AM (9 years ago)
Author:
steve
Message:

Cleaning up the imports

Location:
trunk/anuga_core/source/anuga
Files:
47 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/pmesh2domain.py

    r9547 r9551  
    2626
    2727    if use_cache is True:
    28         from caching import cache
     28        from anuga.caching import cache
    2929        result = cache(_pmesh_to_domain_instance, (source, DomainClass),
    3030                       dependencies=[source], verbose=verbose)
     
    211211    #print segment_tags
    212212
    213     from pmesh2domain_ext import build_boundary_dictionary
     213    from anuga.abstract_2d_finite_volumes.pmesh2domain_ext import build_boundary_dictionary
    214214
    215215    tag_dict = build_boundary_dictionary(triangles, segments, segment_tags, tag_dict)
     
    277277    #print ntriangles
    278278
    279     from pmesh2domain_ext import sides_dictionary_construct
    280     sides = sides_dictionary_construct(triangles, sides)
     279    from anuga.abstract_2d_finite_volumes.pmesh2domain_ext import build_sides_dictionary
     280    sides = build_sides_dictionary(triangles, sides)
    281281
    282282
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test/test_gauge.py

    r9461 r9551  
    33
    44import unittest
    5 from math import sqrt, pi
    6 import tempfile, os
    7 from os import access, F_OK,sep, removedirs,remove,mkdir,getcwd
     5import tempfile
     6import os
     7from csv import reader
     8import time
     9import numpy as num
    810
    911import anuga
    10 #from anuga.abstract_2d_finite_volumes.util import *
     12
    1113from anuga.abstract_2d_finite_volumes.gauge import sww2csv_gauges
    12 from anuga.config import epsilon
    13 
    14 from anuga.utilities.numerical_tools import NAN,mean
    15 
    16 from sys import platform
    17 
     14from anuga.utilities.numerical_tools import mean
    1815from anuga.pmesh.mesh import Mesh
    19 
    2016from anuga.file.sww import SWW_file
    21 from anuga.file_conversion.file_conversion import timefile2netcdf
    22 from anuga.utilities.file_utils import del_dir
    23 from csv import reader, writer
    24 import time
    25 import string
    26 
    27 import numpy as num
     17
    2818
    2919
  • trunk/anuga_core/source/anuga/advection/__init__.py

    r8022 r9551  
    33    purposes.
    44"""
    5 
    6 # Add path of package to PYTHONPATH to allow C-extensions to be loaded
    7 import sys
    8 sys.path += __path__
    95
    106from advection import Advection_Domain
  • trunk/anuga_core/source/anuga/anuga_exceptions.py

    r8970 r9551  
    1616    pass
    1717
    18 class ANUGAError(Exception):
     18class ANUGAError(exceptions.Exception):
    1919    """ Generic ANUGA error. """
    2020    #def __init__(self, args=None):
  • trunk/anuga_core/source/anuga/caching/caching.py

    r9489 r9551  
    4444from os import getenv
    4545import types
     46import time
    4647
    4748import os
     
    11081109
    11091110  import time, os, sys
     1111  verbose = False
    11101112
    11111113  # PADARN NOTE 17/12/12: Adding a special case to handle the existence of a
     
    11141116  from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate
    11151117 
    1116   import quad_tree_ext
    1117   import sparse_matrix_ext
     1118  import anuga.utilities.quad_tree_ext as quad_tree_ext
     1119  import anuga.utilities.sparse_matrix_ext as sparse_matrix_ext
    11181120  from anuga.geometry.aabb import AABB
    11191121
  • trunk/anuga_core/source/anuga/caching/test/test_caching.py

    r9468 r9551  
    1212# Define a test function to be cached
    1313#
    14 def f(a,b,c,N,x=0,y='abcdefg'):
    15   """f(a,b,c,N)
    16      Do something time consuming and produce a complex result.
    17   """
    18 
    19   import string
    20 
    21   B = []
    22   for n in range(N):
    23     s = str(n+2.0/(n + 4.0))+'.a'*10
    24     B.append((a,b,c,s,n,x,y))
    25   return(B)
     14def f(a, b, c, N, x=0, y='abcdefg'):
     15    """f(a,b,c,N)
     16    Do something time consuming and produce a complex result.
     17    """
     18
     19    import string
     20   
     21    B = []
     22    for n in range(N):
     23        s = str(n + 2.0 / (n + 4.0)) + '.a' * 10
     24    B.append((a, b, c, s, n, x, y))
     25    return(B)
    2626 
    2727def f_numeric(A, B):
    28   """Operation on numeric arrays
    29   """
    30  
    31   return 3.1*A + B + 1
     28    """Operation on numeric arrays
     29    """
     30 
     31    return 3.1 * A + B + 1
    3232 
    3333 
    3434def f_object(A, B):
    35   """Operation of objecs of class Dummy
    36   """
    37  
    38   return A.value+B.value, A.another+B.another
     35    """Operation of objects of class Dummy
     36    """
     37 
     38    return A.value + B.value, A.another + B.another
    3939 
    4040
    4141def f_generic(A):
    42   return A
     42    return A
    4343 
    4444def clear_and_create_cache(Dummy, verbose=False):
    45 
    46   a = cache(Dummy, 'clear', verbose=verbose)
    47   a = cache(Dummy, args=(9,10),
     45   
     46    a = cache(Dummy, 'clear', verbose=verbose)
     47    a = cache(Dummy, args=(9, 10),
    4848            verbose=verbose)
    4949     
    5050
    5151def retrieve_cache(Dummy, verbose=False):
    52   if verbose: print('Check that cache is there')
    53  
    54   X = cache(Dummy, args=(9,10), test=1,
    55             verbose=verbose)     
    56            
    57   msg = 'Cached value was not found'
    58   assert X is not None, msg
    59 
    60      
    61 
     52    if verbose: print('Check that cache is there')
     53 
     54    X = cache(Dummy, args=(9, 10), test=1,
     55            verbose=verbose)
    6256   
    63 
     57    msg = 'Cached value was not found'
     58    assert X is not None, msg
     59   
    6460class Test_Caching(unittest.TestCase):
    6561    def setUp(self):
    66         set_option('verbose', 0)  #Why
     62        set_option('verbose', 0)  # Why
    6763
    6864        pass
     
    8379    def test_basic_caching(self):
    8480
    85         verbose=False
     81        verbose = False
    8682        # Make some test input arguments
    8783        #
    88         N = 5000  #Make N fairly small here
    89 
    90         a = [1,2]
    91         b = ('Thou shalt count the number three',4)
    92         c = {'Five is right out': 6, (7,8): 9}
     84        N = 5000  # Make N fairly small here
     85
     86        a = [1, 2]
     87        b = ('Thou shalt count the number three', 4)
     88        c = {'Five is right out': 6, (7, 8): 9}
    9389        x = 3
    9490        y = 'holy hand granate'
     
    10399            # Evaluate and store
    104100            #
    105             T1 = cache(f, (a,b,c,N), {'x':x, 'y':y}, evaluate=1, \
     101            T1 = cache(f, (a, b, c, N), {'x':x, 'y':y}, evaluate=1, \
    106102                       compression=comp, verbose=verbose)
    107103
    108104            # Retrieve
    109105            #                           
    110             T2 = cache(f, (a,b,c,N), {'x':x, 'y':y}, compression=comp)
     106            T2 = cache(f, (a, b, c, N), {'x':x, 'y':y}, compression=comp)
    111107
    112108            # Reference result
    113109            #   
    114             T3 = f(a,b,c,N,x=x,y=y)  # Compute without caching
     110            T3 = f(a, b, c, N, x=x, y=y)  # Compute without caching
    115111
    116112
     
    149145
    150146            # Retrieve
    151             T2 = cache(f_numeric, (A1, B1), 
     147            T2 = cache(f_numeric, (A1, B1),
    152148                       compression=comp, test=1, verbose=verbose)
    153149                       
     
    157153
    158154            # Reference result
    159             T3 = f_numeric(A0, B0) # Compute without caching
     155            T3 = f_numeric(A0, B0)  # Compute without caching
    160156
    161157
     
    170166       
    171167        # Make test input arguments
    172         A0 = num.arange(5)*1.0
     168        A0 = num.arange(5) * 1.0
    173169        B = ('x', 15)
    174170       
     
    197193            # Check that A1 doesn't trigger retrieval of the previous result
    198194            # even though it hashes to the same address
    199             T2 = cache(f_numeric, (A1, A1), 
     195            T2 = cache(f_numeric, (A1, A1),
    200196                       compression=comp, verbose=verbose)
    201197           
     
    217213   
    218214
    219         verbose = False #True
    220        
    221         D = {'point_attributes': None, 
    222              'use_cache': True, 
    223              'vertex_coordinates': None, 
    224              'verbose': True, 
    225              'max_read_lines': 500, 
    226              'acceptable_overshoot': 1.01, 
    227              'mesh': None, 
    228              'data_origin': None, 
    229              'alpha': 0.02, 
    230              'mesh_origin': None, 
    231              'attribute_name': None, 
     215        verbose = False  # True
     216       
     217        D = {'point_attributes': None,
     218             'use_cache': True,
     219             'vertex_coordinates': None,
     220             'verbose': True,
     221             'max_read_lines': 500,
     222             'acceptable_overshoot': 1.01,
     223             'mesh': None,
     224             'data_origin': None,
     225             'alpha': 0.02,
     226             'mesh_origin': None,
     227             'attribute_name': None,
    232228             'triangles': None}         
    233229       
    234         DD = deepcopy(D) # Mangles the dictionary ordering
     230        DD = deepcopy(D)  # Mangles the dictionary ordering
    235231       
    236232        assert myhash(DD) == myhash(D)
     
    245241
    246242            # Retrieve using copy (DD)
    247             T2 = cache(f_generic, DD, 
     243            T2 = cache(f_generic, DD,
    248244                       compression=comp, test=1, verbose=verbose)
    249245                       
     
    253249
    254250            # Reference result
    255             T3 = f_generic(D) # Compute without caching
     251            T3 = f_generic(D)  # Compute without caching
    256252
    257253           
     
    301297
    302298            # Retrieve
    303             T2 = cache(f_object, (A1, B1), 
    304                        compression=comp, 
    305                        test=1, 
     299            T2 = cache(f_object, (A1, B1),
     300                       compression=comp,
     301                       test=1,
    306302                       verbose=verbose)
    307303                       
     
    311307
    312308            # Reference result
    313             T3 = f_object(A0, B0) # Compute without caching
     309            T3 = f_object(A0, B0)  # Compute without caching
    314310
    315311
     
    331327        B = {'x': 10, 'A': A}
    332328        C = [B, 15]
    333         A.value = C # Make it circular
    334         A.x = [1,2,C,5,A] # More circular and self referential
     329        A.value = C  # Make it circular
     330        A.x = [1, 2, C, 5, A] # More circular and self referential
    335331       
    336332        AA = deepcopy(A)
     
    341337 
    342338            # Evaluate and store
    343             T1 = cache(f_generic, A, 
     339            T1 = cache(f_generic, A,
    344340                       evaluate=1,
    345341                       compression=comp, verbose=verbose)
    346342
    347343            # Retrieve
    348             T2 = cache(f_generic, AA, 
    349                        compression=comp, 
     344            T2 = cache(f_generic, AA,
     345                       compression=comp,
    350346                       test=1, verbose=verbose)
    351347                       
     
    355351
    356352            # Reference result
    357             T3 = f_generic(A) # Compute without caching
     353            T3 = f_generic(A)  # Compute without caching
    358354
    359355           
     
    380376           
    381377          def __call__(self, x):
    382             return self.a*x + self.b
     378            return self.a * x + self.b
    383379
    384380           
     
    395391
    396392          # Prior to cluster upgrades Feb 2009
    397           #f1hash = 1914027059797211698
    398           #f2hash = 1914027059807087171
     393          # f1hash = 1914027059797211698
     394          # f2hash = 1914027059807087171
    399395        else:
    400396          # 32 bit hash values
     
    461457        B = {'x': 10, 'A': A}
    462458        C = [B, num.array([1.2, 3, 5, 0.1])]
    463         A.value = C # Make it circular
     459        A.value = C  # Make it circular
    464460
    465461        # Create identical but separate object   
    466462        AA = Dummy(None, None)
    467463        BB = {'A': AA, 'x': 10}
    468         CC = [BB, num.array([1.200, 3.000, 5.00, 1.0/10])]
    469         AA.value = CC # Make it circular
    470         AA.another = 3+4       
     464        CC = [BB, num.array([1.200, 3.000, 5.00, 1.0 / 10])]
     465        AA.value = CC  # Make it circular
     466        AA.another = 3 + 4       
    471467       
    472468       
     
    484480
    485481            # Retrieve using copy (AA)
    486             T2 = cache(f_generic, AA, 
     482            T2 = cache(f_generic, AA,
    487483                       compression=comp, test=1, verbose=verbose)
    488484                       
     
    492488
    493489            # Reference result
    494             T3 = f_generic(A) # Compute without caching
     490            T3 = f_generic(A)  # Compute without caching
    495491
    496492           
     
    508504        """
    509505       
    510         verbose = False #True
     506        verbose = False  # True
    511507       
    512508        # Create input argument
    513509        A = {'x': 10, 'B': None}
    514510        B = [A, 15]
    515         A['B'] = B # Make it circular
     511        A['B'] = B  # Make it circular
    516512       
    517513        # Test caching
     
    525521
    526522            # Retrieve
    527             T2 = cache(f_generic, A, 
     523            T2 = cache(f_generic, A,
    528524                       compression=comp, test=1, verbose=verbose)
    529525                       
     
    533529
    534530            # Reference result
    535             T3 = f_generic(A) # Compute without caching
     531            T3 = f_generic(A)  # Compute without caching
    536532
    537533
     
    545541        """Test existence of cachefiles
    546542        """       
    547         N = 5000  #Make N fairly small here
    548 
    549         a = [1,2]
    550         b = ('Thou shalt count the number three',4)
    551         c = {'Five is right out': 6, (7,8): 9}
     543        N = 5000  # Make N fairly small here
     544
     545        a = [1, 2]
     546        b = ('Thou shalt count the number three', 4)
     547        c = {'Five is right out': 6, (7, 8): 9}
    552548        x = 3
    553549        y = 'holy hand granate'
    554550
    555551       
    556         FN = cache(f,(a,b,c,N), {'x':x, 'y':y}, verbose=0, \
    557                   return_filename = 1)
     552        FN = cache(f, (a, b, c, N), {'x':x, 'y':y}, verbose=0, \
     553                  return_filename=1)
    558554
    559555
     
    563559        compression = 1
    564560
    565         (datafile,compressed0) = myopen(CD+FN+'_'+file_types[0],"rb",compression)
    566         (argsfile,compressed1) = myopen(CD+FN+'_'+file_types[1],"rb",compression)
    567         (admfile,compressed2) =  myopen(CD+FN+'_'+file_types[2],"rb",compression)
     561        (datafile, compressed0) = myopen(CD + FN + '_' + file_types[0], "rb", compression)
     562        (argsfile, compressed1) = myopen(CD + FN + '_' + file_types[1], "rb", compression)
     563        (admfile, compressed2) = myopen(CD + FN + '_' + file_types[2], "rb", compression)
    568564
    569565        datafile.close()
     
    579575        N = 5 
    580576
    581         a = [1,2]
    582         b = ('Thou shalt count the number three',4)
    583         c = {'Five is right out': 6, (7,8): 9}
     577        a = [1, 2]
     578        b = ('Thou shalt count the number three', 4)
     579        c = {'Five is right out': 6, (7, 8): 9}
    584580        x = 3
    585581        y = 'holy hand granate'
    586582       
    587583
    588         T1 = cache(f, (a,b,c,N), {'x':x, 'y':y},
    589                    evaluate=1, 
     584        T1 = cache(f, (a, b, c, N), {'x':x, 'y':y},
     585                   evaluate=1,
    590586                   verbose=verbose)
    591587       
    592         T2 = cache(f, (a,b,c,N), {'x':x, 'y':y},
     588        T2 = cache(f, (a, b, c, N), {'x':x, 'y':y},
    593589                   test=1,
    594590                   verbose=verbose)
     
    606602        """
    607603
    608         N = 5000  #Make N fairly small here
    609 
    610         a = [1,2]
    611         b = ('Thou shalt count the number three',4)
    612         c = {'Five is right out': 6, (7,8): 9}
     604        N = 5000  # Make N fairly small here
     605
     606        a = [1, 2]
     607        b = ('Thou shalt count the number three', 4)
     608        c = {'Five is right out': 6, (7, 8): 9}
    613609        x = 3
    614610        y = 'holy hand granate'
    615611       
    616612
    617         T1 = cache(f,(a,b,c,N), {'x':x, 'y':y}, evaluate = 1)
    618        
    619        
    620         cache(f, (a,b,c,N), {'x':x, 'y':y}, clear = 1)   
     613        T1 = cache(f, (a, b, c, N), {'x':x, 'y':y}, evaluate=1)
     614       
     615       
     616        cache(f, (a, b, c, N), {'x':x, 'y':y}, clear=1)   
    621617
    622618 
     
    624620       
    625621       
    626         T4 = cache(f, (a,b,c,N), {'x':x, 'y':y}, test=1)
     622        T4 = cache(f, (a, b, c, N), {'x':x, 'y':y}, test=1)
    627623        assert T4 is None, "Option 'test' when cache absent failed"
    628624
     
    635631        DepFN = CD + 'testfile.tmp'
    636632        DepFN_wildcard = CD + 'test*.tmp'
    637         Depfile = open(DepFN,'w')
     633        Depfile = open(DepFN, 'w')
    638634        Depfile.write('We are the knights who say NI!')
    639635        Depfile.close()
     
    643639        #
    644640
    645         N = 5000  #Make N fairly small here
    646 
    647         a = [1,2]
    648         b = ('Thou shalt count the number three',4)
    649         c = {'Five is right out': 6, (7,8): 9}
     641        N = 5000  # Make N fairly small here
     642
     643        a = [1, 2]
     644        b = ('Thou shalt count the number three', 4)
     645        c = {'Five is right out': 6, (7, 8): 9}
    650646        x = 3
    651647        y = 'holy hand granate'
    652648       
    653         T1 = cache(f,(a,b,c,N), {'x':x, 'y':y}, dependencies=DepFN) 
    654         T2 = cache(f,(a,b,c,N), {'x':x, 'y':y}, dependencies=DepFN)                     
     649        T1 = cache(f, (a, b, c, N), {'x':x, 'y':y}, dependencies=DepFN) 
     650        T2 = cache(f, (a, b, c, N), {'x':x, 'y':y}, dependencies=DepFN)                     
    655651                       
    656652        assert T1 == T2, 'Dependencies do not work'
     
    658654
    659655        # Test basic wildcard dependency
    660         T3 = cache(f,(a,b,c,N), {'x':x, 'y':y}, dependencies=DepFN_wildcard)                     
     656        T3 = cache(f, (a, b, c, N), {'x':x, 'y':y}, dependencies=DepFN_wildcard)                     
    661657   
    662658        assert T1 == T3, 'Dependencies with wildcards do not work'
     
    666662 
    667663        # Modify dependency file
    668         Depfile = open(DepFN,'a')
     664        Depfile = open(DepFN, 'a')
    669665        Depfile.write('You must cut down the mightiest tree in the forest with a Herring')
    670666        Depfile.close()
    671667 
    672         T3 = cache(f,(a,b,c,N), {'x':x, 'y':y}, dependencies=DepFN, test = 1)
     668        T3 = cache(f, (a, b, c, N), {'x':x, 'y':y}, dependencies=DepFN, test=1)
    673669       
    674670        assert T3 is None, 'Changed dependencies not recognised'
     
    676672        # Test recomputation when dependencies have changed
    677673        #
    678         T3 = cache(f,(a,b,c,N), {'x':x, 'y':y}, dependencies=DepFN)                       
     674        T3 = cache(f, (a, b, c, N), {'x':x, 'y':y}, dependencies=DepFN)                       
    679675        assert T1 == T3, 'Recomputed value with changed dependencies failed'
    680676
    681     #def test_performance(self):       
     677    # def test_performance(self):       
    682678    #    """Performance test (with statistics)
    683679    #    Don't really rely on this as it will depend on specific computer.
     
    713709        """
    714710        import os, string
    715         statsfile  = '.cache_stat'  # Basefilename for cached statistics.
     711        statsfile = '.cache_stat'  # Basefilename for cached statistics.
    716712       
    717713        CD = checkdir(cachedir)               
     
    719715        SF = []
    720716        for FN in DIRLIST:
    721             if string.find(FN,statsfile) >= 0:
     717            if string.find(FN, statsfile) >= 0:
    722718                try:
    723                     fid = open(CD+FN,'r')
     719                    fid = open(CD + FN, 'r')
    724720                    fid.close()
    725721                except:
     
    785781     
    786782      verbose = True
    787       #verbose = False
     783      # verbose = False
    788784
    789785      for i in range(2):
     
    792788       
    793789        if verbose: print "cache for first time"
    794         a = cache(Dummy, args=(9,10), verbose=verbose)
     790        a = cache(Dummy, args=(9, 10), verbose=verbose)
    795791        hash_value = myhash(a)
    796792       
    797         #print "hash_value",hash_value
     793        # print "hash_value",hash_value
    798794        if verbose: print "cache for second time"
    799         a = cache(Dummy, args=(9,10), verbose=verbose)
    800        
    801         #print "myhash(a)",myhash(a)
     795        a = cache(Dummy, args=(9, 10), verbose=verbose)
     796       
     797        # print "myhash(a)",myhash(a)
    802798        assert hash_value == myhash(a)
    803799
     
    832828       
    833829          if verbose: print 'cache for first time'
    834           a_ref = cache(Dummy, args=(9,10),
     830          a_ref = cache(Dummy, args=(9, 10),
    835831                        compression=compression_store,
    836832                        verbose=verbose)
    837833         
    838834          if verbose: print 'Check that cache is there'
    839           assert cache(Dummy, args=(9,10), test=1,
     835          assert cache(Dummy, args=(9, 10), test=1,
    840836                       compression=compression_retrieve,
    841837                       verbose=verbose)
    842838                       
    843839          if verbose: print 'Check cached result'
    844           a = cache(Dummy, args=(9,10),
     840          a = cache(Dummy, args=(9, 10),
    845841                    compression=compression_store,
    846842                    verbose=verbose)                       
     
    849845
    850846
    851     # NOTE (Ole): This test has been commented out because,
    852     #             although the test will pass (not anymore!)
    853     #             inside the caching dir and also at the anuga_core level,
    854     #             it won't pass at the anuga_core/source/anuga level.
    855     # It may have to do with the comments above.
    856     #
    857     # But this is a very nice test to run occasionally within the caching
    858     # area
    859     def Xtest_objects_are_created_memory(self):
    860       """
    861      
    862       This test shows how instances can be created from cache
    863       as long as input arguments are unchanged - even if the class
    864       lives in different memory locations.
    865 
    866       This is using cache created in the main program below
    867       """
    868 
    869       verbose = True #False
    870 
    871       # Redefine class Dummy_memorytest
    872       class Dummy_memorytest:
    873         def __init__(self, value, another):
    874           self.value = value     
    875 
    876       # Make sure that class has been redefined to another address
    877       print
    878       print 'Initial_addr  ', initial_addr
    879       print 'Redefined addr', repr(Dummy_memorytest)
    880       msg = 'Redefined class ended up at same memory location as '
    881       msg += 'original class making this test irrelevant. Try to run '
    882       msg += 'it again and see if this error goes away.'
    883       msg += 'If it persists contact Ole.Nielsen@ga.gov.au'
    884       assert initial_addr != repr(Dummy_memorytest), msg   
    885 
    886      
    887       retrieve_cache(Dummy_memorytest, verbose=verbose)     
    888          
    889 # Cache created for use with 'test_objects_are_created_memory'
    890 #initial_addr = `Dummy_memorytest`
    891 #clear_and_create_cache(Dummy_memorytest, verbose=False)
     847#     # NOTE (Ole): This test has been commented out because,
     848#     #             although the test will pass (not anymore!)
     849#     #             inside the caching dir and also at the anuga_core level,
     850#     #             it won't pass at the anuga_core/source/anuga level.
     851#     # It may have to do with the comments above.
     852#     #
     853#     # But this is a very nice test to run occasionally within the caching
     854#     # area
     855#     def Xtest_objects_are_created_memory(self):
     856#       """
     857#      
     858#       This test shows how instances can be created from cache
     859#       as long as input arguments are unchanged - even if the class
     860#       lives in different memory locations.
     861#
     862#       This is using cache created in the main program below
     863#       """
     864#
     865#       verbose = True  # False
     866#
     867#       # Redefine class Dummy_memorytest
     868#       class Dummy_memorytest:
     869#         def __init__(self, value, another):
     870#           self.value = value     
     871#
     872#       # Make sure that class has been redefined to another address
     873#       print
     874#       print 'Initial_addr  ', initial_addr
     875#       print 'Redefined addr', repr(Dummy_memorytest)
     876#       msg = 'Redefined class ended up at same memory location as '
     877#       msg += 'original class making this test irrelevant. Try to run '
     878#       msg += 'it again and see if this error goes away.'
     879#       msg += 'If it persists contact Ole.Nielsen@ga.gov.au'
     880#       assert initial_addr != repr(Dummy_memorytest), msg   
     881#
     882#      
     883#       retrieve_cache(Dummy_memorytest, verbose=verbose)     
     884#          
     885# # Cache created for use with 'test_objects_are_created_memory'
     886# # initial_addr = `Dummy_memorytest`
     887# # clear_and_create_cache(Dummy_memorytest, verbose=False)
    892888 
    893889
  • trunk/anuga_core/source/anuga/coordinate_transforms/__init__.py

    r2253 r9551  
     1
    12from redfearn import *
    23from point import *
  • trunk/anuga_core/source/anuga/damage_modelling/__init__.py

    r3307 r9551  
    22"""
    33
    4 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    5 import sys
    6 sys.path += __path__
     4pass
    75
    86
    97
     8
  • trunk/anuga_core/source/anuga/file/__init__.py

    r7776 r9551  
    4949"""
    5050
    51 # Add path of package to PYTHONPATH to allow C-extensions to be loaded
    52 import sys
    53 sys.path += __path__
     51pass
     52
  • trunk/anuga_core/source/anuga/file/sww.py

    r9384 r9551  
    1818from anuga.file.netcdf import NetCDFFile
    1919
     20from anuga.config import minimum_storable_height as default_minimum_storable_height
     21
    2022from sts import Write_sts
    2123
     
    2325        ensure_geo_reference
    2426
    25 from file_utils import create_filename
     27from anuga.utilities.file_utils import create_filename
    2628import numpy as num
    2729
  • trunk/anuga_core/source/anuga/file/test/test_csv.py

    r9488 r9551  
    66from anuga.utilities.system_tools import get_pathname_from_package
    77
    8 from csv_file import load_csv_as_array, load_csv_as_dict, store_parameters, \
     8from anuga.file.csv_file import load_csv_as_array, load_csv_as_dict, store_parameters, \
    99                        load_csv_as_matrix, load_csv_as_polygons, \
    1010                        load_csv_as_building_polygons
  • trunk/anuga_core/source/anuga/file/test/test_mux.py

    r9488 r9551  
    1010from anuga.coordinate_transforms.geo_reference import Geo_reference
    1111
    12 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
     12from anuga.file.mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
    1313                            NORTH_VELOCITY_LABEL
    1414
    15 from mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \
     15from anuga.file.mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \
    1616                NORTH_VELOCITY_MUX2_LABEL
    1717               
    18 from mux import read_mux2_py
     18from anuga.file.mux import read_mux2_py
    1919from anuga.file_conversion.urs2sts import urs2sts
    2020from anuga.file.urs import Read_urs
     
    456456        """
    457457       
    458         from urs_ext import read_mux2
     458        from anuga.file.urs_ext import read_mux2
    459459       
    460460        verbose = False
     
    561561        """
    562562       
    563         from urs_ext import read_mux2
     563        from anuga.file.urs_ext import read_mux2
    564564       
    565565        from anuga.config import single_precision as epsilon       
     
    824824
    825825       
    826         from urs_ext import read_mux2
     826        from anuga.file.urs_ext import read_mux2
    827827       
    828828        from anuga.config import single_precision as epsilon       
  • trunk/anuga_core/source/anuga/file/test/test_read_sww.py

    r9490 r9551  
    199199            rectangular_cross
    200200        from anuga.shallow_water.shallow_water_domain import Domain
    201         from boundaries import Reflective_boundary
     201        from anuga.shallow_water.boundaries import Reflective_boundary
    202202        from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\
    203203                            import Dirichlet_boundary, Time_boundary
  • trunk/anuga_core/source/anuga/file_conversion/__init__.py

    r7814 r9551  
    1414"""
    1515
    16 # Add path of package to PYTHONPATH to allow C-extensions to be loaded
    17 import sys
    18 sys.path += __path__
     16pass
    1917
     18
  • trunk/anuga_core/source/anuga/file_conversion/sts2sww_mesh.py

    r9550 r9551  
    77from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
    88from anuga.shallow_water.shallow_water_domain import Domain
    9 from boundaries import Reflective_boundary
     9from anuga.shallow_water.boundaries import Reflective_boundary
    1010from anuga.coordinate_transforms.geo_reference import Geo_reference
    11 from forcing import *
     11from anuga.shallow_water.forcing import *
     12from anuga.utilities.numerical_tools import ensure_numeric
     13
    1214from anuga.file.sww import Write_sww 
    1315from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a, \
     
    1618def sts2sww_mesh(basename_in, basename_out=None,
    1719                 spatial_thinning=1, verbose=False):
     20   
     21    from anuga.mesh_engine.mesh_engine import NoTrianglesError
    1822    from anuga.pmesh.mesh import Mesh
    1923    if verbose:
  • trunk/anuga_core/source/anuga/file_conversion/test/test_dem2dem.py

    r9491 r9551  
    1212from anuga.config import g
    1313
    14 from boundaries import Reflective_boundary, \
     14from anuga.shallow_water.boundaries import Reflective_boundary, \
    1515            Field_boundary, Transmissive_momentum_set_stage_boundary, \
    1616            Transmissive_stage_zero_momentum_boundary
  • trunk/anuga_core/source/anuga/file_conversion/test/test_dem2pts.py

    r9476 r9551  
    1111from anuga.file.netcdf import NetCDFFile
    1212
    13 from dem2pts import dem2pts
    14 from asc2dem import asc2dem
     13from anuga.file_conversion.dem2pts import dem2pts
     14from anuga.file_conversion.asc2dem import asc2dem
    1515
    1616class Test_Dem2Pts(unittest.TestCase):
  • trunk/anuga_core/source/anuga/file_conversion/urs2nc.py

    r8150 r9551  
    44import numpy as num
    55
     6from anuga.anuga_exceptions import ANUGAError
    67from anuga.utilities.numerical_tools import ensure_numeric   
    78from anuga.caching.caching import myhash
     
    910from anuga.file.netcdf import Write_nc, write_elevation_nc
    1011
    11 
    12 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
     12import anuga.utilities.log as log
     13from anuga.file.mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
    1314                            NORTH_VELOCITY_LABEL
    1415
  • trunk/anuga_core/source/anuga/file_conversion/urs2sts.py

    r8780 r9551  
    11import numpy as num
    2 import log
     2
     3import anuga.utilities.log as log
    34
    45# ANUGA modules
     
    160161
    161162    mux={}
     163    times_old = 0.0
     164    latitudes_old = 0.0
     165    longitudes_old = 0.0
     166    elevation_old = 0.0
     167    starttime_old = 0.0
     168   
    162169    for i, quantity in enumerate(quantities):
    163170        # For each quantity read the associated list of source mux2 file with
     
    244251
    245252    old_zone = refzone
     253    old_easting = 0.0
     254    old_northing = 0.0
    246255
    247256    for i in range(number_of_points):
  • trunk/anuga_core/source/anuga/file_conversion/urs2sww.py

    r8780 r9551  
    55from anuga.file.urs import Read_urs
    66
     7import anuga.utilities.log as log
     8
    79from anuga.file_conversion.urs2nc import urs2nc
    810from anuga.file_conversion.ferret2sww import ferret2sww
     
    1416                                                    Geospatial_data
    1517
    16 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
     18from anuga.file.mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \
    1719                            NORTH_VELOCITY_LABEL
    1820                           
  • trunk/anuga_core/source/anuga/fit_interpolate/__init__.py

    r7876 r9551  
    66"""
    77
    8 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    9 import sys
    10 sys.path += __path__
     8pass
    119
    1210
    1311
     12
  • trunk/anuga_core/source/anuga/fit_interpolate/test/test_interpolate.py

    r9550 r9551  
    1818# ANUGA code imports
    1919import anuga
    20 from interpolate import *
     20from anuga.fit_interpolate.interpolate import *
    2121from anuga.coordinate_transforms.geo_reference import Geo_reference
    2222from anuga.utilities.numerical_tools import mean, NAN
     
    913913        for blocking_max in range(14):
    914914        #if True:
    915          #   blocking_max = 5
     915        #   blocking_max = 5
    916916            z = interp.interpolate(f, point_coords,
    917917                                   start_blocking_len=blocking_max)
     
    931931        for blocking_max in range(14):
    932932        #if True:
    933          #   blocking_max = 5
     933        #   blocking_max = 5
    934934            z = interp.interpolate(f, point_coords,
    935935                                   start_blocking_len=blocking_max)
     
    945945            assert num.allclose(z, answer)
    946946
    947         z = interp.interpolate(f, point_coords, start_blocking_len = 2)
     947        #z = interp.interpolate(f, point_coords, start_blocking_len = 2)
    948948
    949949        #print "z",z
    950950        #print "answer",answer
    951         assert num.allclose(z, answer)
    952        
    953     def test_interpolate_geo_spatial(self):
     951        #assert num.allclose(z, answer)
     952       
     953    def test_interpolate_geo_spatial_2(self):
    954954        a = [-1.0, 0.0]
    955955        b = [3.0, 4.0]
  • trunk/anuga_core/source/anuga/geometry/__init__.py

    r7876 r9551  
    66
    77
    8 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    9 import sys
    10 sys.path += __path__
     8pass
     9
  • trunk/anuga_core/source/anuga/geometry/test/test_polygon.py

    r9480 r9551  
    99from anuga.utilities.system_tools import get_pathname_from_package
    1010
    11 from polygon import _poly_xy, separate_points_by_polygon, \
     11from anuga.geometry.polygon import _poly_xy, separate_points_by_polygon, \
    1212                    populate_polygon, polygon_area, is_inside_polygon, \
    1313                    read_polygon, point_on_line, point_in_polygon, \
     
    1818                    in_and_outside_polygon
    1919                   
    20 from polygon_function import Polygon_function
     20from anuga.geometry.polygon_function import Polygon_function
    2121from anuga.coordinate_transforms.geo_reference import Geo_reference
    2222from anuga.geospatial_data.geospatial_data import Geospatial_data
     
    3737        FN = 'polygon_ext.c'
    3838        try:
    39             import polygon_ext
     39            import anuga.geometry.polygon_ext as polygon_ext
    4040        except:
    41             from compile import compile
     41            from anuga.utilities.compile import compile
    4242
    4343            try:
     
    4646                raise Exception, 'Could not compile %s' %FN
    4747            else:
    48                 import polygon_ext
     48                import anuga.geometry.polygon_ext as polygon_ext
    4949
    5050    # Polygon stuff
     
    18181818
    18191819    def test_decimate_polygon(self):
    1820         from polygon import decimate_polygon
     1820        from anuga.geometry.polygon import decimate_polygon
    18211821        polygon = [[0,0], [10,10], [15,5], [20, 10],
    18221822                   [25,0], [30,10], [40,-10], [35, -5]]
  • trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r9059 r9551  
    1111from copy import deepcopy
    1212import copy
     13
     14from exceptions import Exception
    1315
    1416from anuga.file.netcdf import NetCDFFile
     
    241243            msg = ('Argument geo_reference must be a valid Geo_reference '
    242244                   'object or None.')
    243             raise Expection(msg)
     245            raise (msg)
    244246
    245247        # If a geo_reference already exists, change the point data according to
     
    13861388        if no_boundary is True:
    13871389            msg = 'All boundaries must be defined'
    1388             raise Expection(msg)
     1390            raise Exception(msg)
    13891391
    13901392        poly_topo = [[east_boundary, south_boundary],
     
    15591561    """
    15601562
    1561     from anuga.shallow_water import Domain
     1563    from anuga.shallow_water.shallow_water_domain import Domain
    15621564    from anuga.geospatial_data.geospatial_data import Geospatial_data
    15631565    from anuga.pmesh.mesh_interface import create_mesh_from_regions
     
    15791581        if no_boundary is True:
    15801582            msg = 'All boundaries must be defined'
    1581             raise Expection(msg)
     1583            raise Exception(msg)
    15821584
    15831585        poly_topo = [[east_boundary, south_boundary],
  • trunk/anuga_core/source/anuga/lib/__init__.py

    r6213 r9551  
    44pass
    55
    6 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    7 import sys
    8 sys.path += __path__
    96
    107
    118
     9
  • trunk/anuga_core/source/anuga/operators/__init__.py

    r8133 r9551  
    66pass
    77
    8 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    9 import sys
    10 sys.path += __path__
    118
     9
  • trunk/anuga_core/source/anuga/operators/set_friction_operators.py

    r9001 r9551  
    126126
    127127
    128         Dpth_friction_operator.__init__(self,
     128        Depth_friction_operator.__init__(self,
    129129                                    domain,
    130130                                    friction=friction,
  • trunk/anuga_core/source/anuga/operators/test/test_rate_operators.py

    r9445 r9551  
    1818from anuga.fit_interpolate.interpolate import Modeltime_too_late
    1919
    20 from rate_operators import *
     20from anuga.operators.rate_operators import *
    2121
    2222import numpy as num
  • trunk/anuga_core/source/anuga/operators/test/test_set_elevation_operator.py

    r9445 r9551  
    1313from anuga.config import time_format
    1414
    15 from set_elevation_operator import *
     15from anuga.operators.set_elevation_operator import *
    1616
    1717import numpy as num
  • trunk/anuga_core/source/anuga/operators/test/test_set_quantity.py

    r9445 r9551  
    1313from anuga.config import time_format
    1414
    15 from set_quantity import *
    16 from set_stage import *
     15from anuga.operators.set_quantity import *
     16from anuga.operators.set_stage import *
    1717
    1818import numpy as num
  • trunk/anuga_core/source/anuga/operators/test/test_set_stage_operator.py

    r9445 r9551  
    1313from anuga.config import time_format
    1414
    15 from set_stage_operator import *
     15from anuga.operators.set_stage_operator import *
    1616
    1717import numpy as num
  • trunk/anuga_core/source/anuga/operators/test/test_set_w_uh_vh_operators.py

    r9445 r9551  
    1313from anuga.config import time_format
    1414
    15 from set_w_uh_vh_operator import *
     15from anuga.operators.set_w_uh_vh_operator import *
    1616
    1717import numpy as num
  • trunk/anuga_core/source/anuga/parallel/test/test_parallel_file_boundary.py

    r9501 r9551  
    4141from anuga import File_boundary
    4242
    43 from mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \
     43from anuga.file.mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \
    4444                NORTH_VELOCITY_MUX2_LABEL
    45 from mux import read_mux2_py
     45from anuga.file.mux import read_mux2_py
    4646from anuga.file_conversion.urs2sts import urs2sts
    4747from anuga.file.urs import Read_urs
  • trunk/anuga_core/source/anuga/pmesh/mesh.py

    r9063 r9551  
    22552255            log.critical("The region list has a bad size")
    22562256            # raise an error ..
    2257             raise Error
     2257            raise Exception
    22582258
    22592259    #remove "" from the region_list
  • trunk/anuga_core/source/anuga/pymetis/__init__.py

    r3095 r9551  
    44pass
    55
    6 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    7 import sys
    8 sys.path += __path__
     6
  • trunk/anuga_core/source/anuga/shallow_water/__init__.py

    r7778 r9551  
    66"""
    77
    8 # Add path of package to PYTHONPATH to allow C-extensions to be loaded
    9 import sys
    10 sys.path += __path__
     8pass
    119
    1210 
  • trunk/anuga_core/source/anuga/shallow_water/test/test_loadsave.py

    r9457 r9551  
    2929from anuga.shallow_water.sww_interrogate import get_flow_through_cross_section
    3030
    31 from shallow_water_domain import Domain
     31from anuga.shallow_water.shallow_water_domain import Domain
    3232
    3333# boundary functions
  • trunk/anuga_core/source/anuga/shallow_water/test/test_shallow_water_domain.py

    r9550 r9551  
    831831
    832832
    833         from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
     833        from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
    834834        # Now check that compute_flux yields zeros as well
    835835        compute_fluxes(domain)
     
    927927
    928928
    929         from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
     929        from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
    930930        # Now check that compute_flux yields zeros as well
    931931        compute_fluxes(domain)
     
    10151015
    10161016
    1017         from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
     1017        from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
    10181018        # Now check that compute_flux yields zeros as well
    10191019        compute_fluxes(domain)
     
    10971097
    10981098
    1099         from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
     1099        from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes
    11001100        # Now check that compute_flux yields zeros as well
    11011101        flux_timestep = compute_fluxes(domain)
     
    26572657
    26582658        #domain.compute_forcing_terms()
    2659         from shallow_water_ext import gravity
     2659        from anuga.shallow_water.shallow_water_ext import gravity
    26602660        gravity(domain)
    26612661
     
    27042704
    27052705        #domain.compute_forcing_terms()
    2706         from shallow_water_ext import gravity
     2706        from anuga.shallow_water.shallow_water_ext import gravity
    27072707        gravity(domain)
    27082708
     
    28622862            assert num.allclose(domain.quantities[name].semi_implicit_update, 0)
    28632863
    2864         from shallow_water_ext import gravity_wb
     2864        from anuga.shallow_water.shallow_water_ext import gravity_wb
    28652865        gravity_wb(domain)
    28662866
     
    29092909            assert num.allclose(domain.quantities[name].semi_implicit_update, 0)
    29102910
    2911         from shallow_water_ext import gravity_wb
     2911        from anuga.shallow_water.shallow_water_ext import gravity_wb
    29122912        gravity_wb(domain)
    29132913
     
    71797179        except RuntimeError, e:
    71807180            msg = 'Test failed: %s' % str(e)
    7181             raise Exception,(sg)
     7181            raise Exception(msg)
    71827182            # clean up in case raise fails
    71837183            os.remove(meshname)
     
    76317631        from anuga.shallow_water.shallow_water_domain import Domain
    76327632        from anuga.shallow_water.boundaries import Reflective_boundary
    7633         from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
    7634         from anuga.shallow_water.shallow_water_domain import Rainfall
     7633        from anuga import Dirichlet_boundary
     7634        from anuga.shallow_water.forcing import Rainfall
    76357635        from anuga.shallow_water.sww_interrogate import get_flow_through_cross_section
    76367636
     
    80468046                   
    80478047               
     8048                from anuga.shallow_water.boundaries import Inflow_boundary
    80488049               
    80498050                Bi = Inflow_boundary(domain, rate=ref_flow)
     
    81218122                import rectangular_cross
    81228123        from anuga.shallow_water.shallow_water_domain import Domain
    8123         from anuga.shallow_water.shallow_water_domain import Reflective_boundary
    8124         from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
     8124        from anuga.shallow_water.boundaries import Reflective_boundary
     8125        from anuga import Dirichlet_boundary
    81258126        from anuga.shallow_water.forcing import Inflow
    8126         from anuga.shallow_water.data_manager \
    8127                 import get_flow_through_cross_section
     8127
    81288128        from anuga.abstract_2d_finite_volumes.util \
    81298129                import sww2csv_gauges, csv2timeseries_graphs
  • trunk/anuga_core/source/anuga/structures/__init__.py

    r7961 r9551  
     1
     2pass
  • trunk/anuga_core/source/anuga/tsunami_source/__init__.py

    r9457 r9551  
    66"""
    77
    8 # Add path of package to PYTHONPATH to allow C-extensions to be loaded
    9 import sys
    10 sys.path += __path__
     8pass
     9
    1110
    1211 
  • trunk/anuga_core/source/anuga/utilities/__init__.py

    r7876 r9551  
    88pass
    99
    10 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    11 import sys
    12 sys.path += __path__
     10
  • trunk/anuga_core/source/anuga/utilities/test/test_log_analyser.py

    r9437 r9551  
    88import tempfile
    99from anuga.utilities.log import TimingDelimiter
    10 from log_analyser import analyse_log
     10from anuga.utilities.log_analyser import analyse_log
    1111
    1212class logTestCase(unittest.TestCase):
  • trunk/anuga_core/source/anuga/utilities/test/test_mem_time_equation.py

    r9435 r9551  
    1010import anuga
    1111
    12 from mem_time_equation import *
     12from anuga.utilities.mem_time_equation import *
    1313
    1414class Test_mem_time_equation(unittest.TestCase):
  • trunk/anuga_core/source/anuga/utilities/test/test_numerical_tools.py

    r9435 r9551  
    88from math import sqrt, pi
    99from anuga.config import epsilon
    10 from numerical_tools import *
     10from anuga.utilities.numerical_tools import *
    1111
    1212
     
    263263        FN = 'util_ext.c'
    264264        try:
    265             import util_ext
     265            import anuga.utilities.util_ext as util_ext
    266266        except:
    267             from compile import compile
     267            from anuga.utilities.compile import compile
    268268
    269269            try:
     
    272272                raise Exception('Could not compile %s' % FN)
    273273            else:
    274                 import util_ext
     274                import anuga.utilities.util_ext as util_ext
    275275
    276276
    277277    def test_gradient_C_extension(self):
    278         from util_ext import gradient as gradient_c
     278        from anuga.utilities.util_ext import gradient as gradient_c
    279279
    280280        x0 = 2.0/3; y0 = 2.0/3
     
    294294
    295295    def test_gradient_C_extension3(self):
    296         from util_ext import gradient as gradient_c
     296        from anuga.utilities.util_ext import gradient as gradient_c
    297297
    298298        seed((17, 53))
  • trunk/anuga_core/source/anuga/validation_utilities/__init__.py

    r9309 r9551  
    22    Validation tests
    33"""
    4 
    5 #Add path of package to PYTHONPATH to allow C-extensions to be loaded
    6 import sys
    7 sys.path += __path__
    84
    95
  • trunk/anuga_core/source/anuga/visualiser/__init__.py

    r3623 r9551  
     1
    12from realtime import RealtimeVisualiser
    23from offline import OfflineVisualiser
Note: See TracChangeset for help on using the changeset viewer.