Changeset 9551
- Timestamp:
- Jan 30, 2015, 12:00:06 AM (9 years ago)
- 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 26 26 27 27 if use_cache is True: 28 from caching import cache28 from anuga.caching import cache 29 29 result = cache(_pmesh_to_domain_instance, (source, DomainClass), 30 30 dependencies=[source], verbose=verbose) … … 211 211 #print segment_tags 212 212 213 from pmesh2domain_ext import build_boundary_dictionary213 from anuga.abstract_2d_finite_volumes.pmesh2domain_ext import build_boundary_dictionary 214 214 215 215 tag_dict = build_boundary_dictionary(triangles, segments, segment_tags, tag_dict) … … 277 277 #print ntriangles 278 278 279 from pmesh2domain_ext import sides_dictionary_construct280 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) 281 281 282 282 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test/test_gauge.py
r9461 r9551 3 3 4 4 import unittest 5 from math import sqrt, pi 6 import tempfile, os 7 from os import access, F_OK,sep, removedirs,remove,mkdir,getcwd 5 import tempfile 6 import os 7 from csv import reader 8 import time 9 import numpy as num 8 10 9 11 import anuga 10 #from anuga.abstract_2d_finite_volumes.util import * 12 11 13 from 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 14 from anuga.utilities.numerical_tools import mean 18 15 from anuga.pmesh.mesh import Mesh 19 20 16 from 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 28 18 29 19 -
trunk/anuga_core/source/anuga/advection/__init__.py
r8022 r9551 3 3 purposes. 4 4 """ 5 6 # Add path of package to PYTHONPATH to allow C-extensions to be loaded7 import sys8 sys.path += __path__9 5 10 6 from advection import Advection_Domain -
trunk/anuga_core/source/anuga/anuga_exceptions.py
r8970 r9551 16 16 pass 17 17 18 class ANUGAError( Exception):18 class ANUGAError(exceptions.Exception): 19 19 """ Generic ANUGA error. """ 20 20 #def __init__(self, args=None): -
trunk/anuga_core/source/anuga/caching/caching.py
r9489 r9551 44 44 from os import getenv 45 45 import types 46 import time 46 47 47 48 import os … … 1108 1109 1109 1110 import time, os, sys 1111 verbose = False 1110 1112 1111 1113 # PADARN NOTE 17/12/12: Adding a special case to handle the existence of a … … 1114 1116 from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate 1115 1117 1116 import quad_tree_ext1117 import sparse_matrix_ext1118 import anuga.utilities.quad_tree_ext as quad_tree_ext 1119 import anuga.utilities.sparse_matrix_ext as sparse_matrix_ext 1118 1120 from anuga.geometry.aabb import AABB 1119 1121 -
trunk/anuga_core/source/anuga/caching/test/test_caching.py
r9468 r9551 12 12 # Define a test function to be cached 13 13 # 14 def f(a, b,c,N,x=0,y='abcdefg'):15 """f(a,b,c,N)16 17 """18 19 import string20 21 B = []22 for n in range(N):23 s = str(n+2.0/(n + 4.0))+'.a'*1024 B.append((a, b,c,s,n,x,y))25 return(B)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) 26 26 27 27 def f_numeric(A, B): 28 """Operation on numeric arrays29 """30 31 return 3.1*A + B + 128 """Operation on numeric arrays 29 """ 30 31 return 3.1 * A + B + 1 32 32 33 33 34 34 def f_object(A, B): 35 """Operation of objecs of class Dummy36 """37 38 return A.value+B.value, A.another+B.another35 """Operation of objects of class Dummy 36 """ 37 38 return A.value + B.value, A.another + B.another 39 39 40 40 41 41 def f_generic(A): 42 return A42 return A 43 43 44 44 def 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), 48 48 verbose=verbose) 49 49 50 50 51 51 def 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) 62 56 63 57 msg = 'Cached value was not found' 58 assert X is not None, msg 59 64 60 class Test_Caching(unittest.TestCase): 65 61 def setUp(self): 66 set_option('verbose', 0) # Why62 set_option('verbose', 0) # Why 67 63 68 64 pass … … 83 79 def test_basic_caching(self): 84 80 85 verbose =False81 verbose = False 86 82 # Make some test input arguments 87 83 # 88 N = 5000 # Make N fairly small here89 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} 93 89 x = 3 94 90 y = 'holy hand granate' … … 103 99 # Evaluate and store 104 100 # 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, \ 106 102 compression=comp, verbose=verbose) 107 103 108 104 # Retrieve 109 105 # 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) 111 107 112 108 # Reference result 113 109 # 114 T3 = f(a, b,c,N,x=x,y=y) # Compute without caching110 T3 = f(a, b, c, N, x=x, y=y) # Compute without caching 115 111 116 112 … … 149 145 150 146 # Retrieve 151 T2 = cache(f_numeric, (A1, B1), 147 T2 = cache(f_numeric, (A1, B1), 152 148 compression=comp, test=1, verbose=verbose) 153 149 … … 157 153 158 154 # Reference result 159 T3 = f_numeric(A0, B0) # Compute without caching155 T3 = f_numeric(A0, B0) # Compute without caching 160 156 161 157 … … 170 166 171 167 # Make test input arguments 172 A0 = num.arange(5) *1.0168 A0 = num.arange(5) * 1.0 173 169 B = ('x', 15) 174 170 … … 197 193 # Check that A1 doesn't trigger retrieval of the previous result 198 194 # even though it hashes to the same address 199 T2 = cache(f_numeric, (A1, A1), 195 T2 = cache(f_numeric, (A1, A1), 200 196 compression=comp, verbose=verbose) 201 197 … … 217 213 218 214 219 verbose = False #True220 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, 232 228 'triangles': None} 233 229 234 DD = deepcopy(D) # Mangles the dictionary ordering230 DD = deepcopy(D) # Mangles the dictionary ordering 235 231 236 232 assert myhash(DD) == myhash(D) … … 245 241 246 242 # Retrieve using copy (DD) 247 T2 = cache(f_generic, DD, 243 T2 = cache(f_generic, DD, 248 244 compression=comp, test=1, verbose=verbose) 249 245 … … 253 249 254 250 # Reference result 255 T3 = f_generic(D) # Compute without caching251 T3 = f_generic(D) # Compute without caching 256 252 257 253 … … 301 297 302 298 # 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, 306 302 verbose=verbose) 307 303 … … 311 307 312 308 # Reference result 313 T3 = f_object(A0, B0) # Compute without caching309 T3 = f_object(A0, B0) # Compute without caching 314 310 315 311 … … 331 327 B = {'x': 10, 'A': A} 332 328 C = [B, 15] 333 A.value = C # Make it circular334 A.x = [1, 2,C,5,A]# More circular and self referential329 A.value = C # Make it circular 330 A.x = [1, 2, C, 5, A] # More circular and self referential 335 331 336 332 AA = deepcopy(A) … … 341 337 342 338 # Evaluate and store 343 T1 = cache(f_generic, A, 339 T1 = cache(f_generic, A, 344 340 evaluate=1, 345 341 compression=comp, verbose=verbose) 346 342 347 343 # Retrieve 348 T2 = cache(f_generic, AA, 349 compression=comp, 344 T2 = cache(f_generic, AA, 345 compression=comp, 350 346 test=1, verbose=verbose) 351 347 … … 355 351 356 352 # Reference result 357 T3 = f_generic(A) # Compute without caching353 T3 = f_generic(A) # Compute without caching 358 354 359 355 … … 380 376 381 377 def __call__(self, x): 382 return self.a *x + self.b378 return self.a * x + self.b 383 379 384 380 … … 395 391 396 392 # Prior to cluster upgrades Feb 2009 397 # f1hash = 1914027059797211698398 # f2hash = 1914027059807087171393 # f1hash = 1914027059797211698 394 # f2hash = 1914027059807087171 399 395 else: 400 396 # 32 bit hash values … … 461 457 B = {'x': 10, 'A': A} 462 458 C = [B, num.array([1.2, 3, 5, 0.1])] 463 A.value = C # Make it circular459 A.value = C # Make it circular 464 460 465 461 # Create identical but separate object 466 462 AA = Dummy(None, None) 467 463 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 circular470 AA.another = 3 +4464 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 471 467 472 468 … … 484 480 485 481 # Retrieve using copy (AA) 486 T2 = cache(f_generic, AA, 482 T2 = cache(f_generic, AA, 487 483 compression=comp, test=1, verbose=verbose) 488 484 … … 492 488 493 489 # Reference result 494 T3 = f_generic(A) # Compute without caching490 T3 = f_generic(A) # Compute without caching 495 491 496 492 … … 508 504 """ 509 505 510 verbose = False #True506 verbose = False # True 511 507 512 508 # Create input argument 513 509 A = {'x': 10, 'B': None} 514 510 B = [A, 15] 515 A['B'] = B # Make it circular511 A['B'] = B # Make it circular 516 512 517 513 # Test caching … … 525 521 526 522 # Retrieve 527 T2 = cache(f_generic, A, 523 T2 = cache(f_generic, A, 528 524 compression=comp, test=1, verbose=verbose) 529 525 … … 533 529 534 530 # Reference result 535 T3 = f_generic(A) # Compute without caching531 T3 = f_generic(A) # Compute without caching 536 532 537 533 … … 545 541 """Test existence of cachefiles 546 542 """ 547 N = 5000 # Make N fairly small here548 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} 552 548 x = 3 553 549 y = 'holy hand granate' 554 550 555 551 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) 558 554 559 555 … … 563 559 compression = 1 564 560 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) 568 564 569 565 datafile.close() … … 579 575 N = 5 580 576 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} 584 580 x = 3 585 581 y = 'holy hand granate' 586 582 587 583 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, 590 586 verbose=verbose) 591 587 592 T2 = cache(f, (a, b,c,N), {'x':x, 'y':y},588 T2 = cache(f, (a, b, c, N), {'x':x, 'y':y}, 593 589 test=1, 594 590 verbose=verbose) … … 606 602 """ 607 603 608 N = 5000 # Make N fairly small here609 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} 613 609 x = 3 614 610 y = 'holy hand granate' 615 611 616 612 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) 621 617 622 618 … … 624 620 625 621 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) 627 623 assert T4 is None, "Option 'test' when cache absent failed" 628 624 … … 635 631 DepFN = CD + 'testfile.tmp' 636 632 DepFN_wildcard = CD + 'test*.tmp' 637 Depfile = open(DepFN, 'w')633 Depfile = open(DepFN, 'w') 638 634 Depfile.write('We are the knights who say NI!') 639 635 Depfile.close() … … 643 639 # 644 640 645 N = 5000 # Make N fairly small here646 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} 650 646 x = 3 651 647 y = 'holy hand granate' 652 648 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) 655 651 656 652 assert T1 == T2, 'Dependencies do not work' … … 658 654 659 655 # 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) 661 657 662 658 assert T1 == T3, 'Dependencies with wildcards do not work' … … 666 662 667 663 # Modify dependency file 668 Depfile = open(DepFN, 'a')664 Depfile = open(DepFN, 'a') 669 665 Depfile.write('You must cut down the mightiest tree in the forest with a Herring') 670 666 Depfile.close() 671 667 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) 673 669 674 670 assert T3 is None, 'Changed dependencies not recognised' … … 676 672 # Test recomputation when dependencies have changed 677 673 # 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) 679 675 assert T1 == T3, 'Recomputed value with changed dependencies failed' 680 676 681 # def test_performance(self):677 # def test_performance(self): 682 678 # """Performance test (with statistics) 683 679 # Don't really rely on this as it will depend on specific computer. … … 713 709 """ 714 710 import os, string 715 statsfile 711 statsfile = '.cache_stat' # Basefilename for cached statistics. 716 712 717 713 CD = checkdir(cachedir) … … 719 715 SF = [] 720 716 for FN in DIRLIST: 721 if string.find(FN, statsfile) >= 0:717 if string.find(FN, statsfile) >= 0: 722 718 try: 723 fid = open(CD +FN,'r')719 fid = open(CD + FN, 'r') 724 720 fid.close() 725 721 except: … … 785 781 786 782 verbose = True 787 # verbose = False783 # verbose = False 788 784 789 785 for i in range(2): … … 792 788 793 789 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) 795 791 hash_value = myhash(a) 796 792 797 # print "hash_value",hash_value793 # print "hash_value",hash_value 798 794 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) 802 798 assert hash_value == myhash(a) 803 799 … … 832 828 833 829 if verbose: print 'cache for first time' 834 a_ref = cache(Dummy, args=(9, 10),830 a_ref = cache(Dummy, args=(9, 10), 835 831 compression=compression_store, 836 832 verbose=verbose) 837 833 838 834 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, 840 836 compression=compression_retrieve, 841 837 verbose=verbose) 842 838 843 839 if verbose: print 'Check cached result' 844 a = cache(Dummy, args=(9, 10),840 a = cache(Dummy, args=(9, 10), 845 841 compression=compression_store, 846 842 verbose=verbose) … … 849 845 850 846 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 caching858 # area859 def Xtest_objects_are_created_memory(self):860 """861 862 This test shows how instances can be created from cache863 as long as input arguments are unchanged - even if the class864 lives in different memory locations.865 866 This is using cache created in the main program below867 """868 869 verbose = True #False870 871 # Redefine class Dummy_memorytest872 class Dummy_memorytest:873 def __init__(self, value, another):874 self.value = value875 876 # Make sure that class has been redefined to another address877 print878 print 'Initial_addr ', initial_addr879 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), msg885 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) 892 888 893 889 -
trunk/anuga_core/source/anuga/coordinate_transforms/__init__.py
r2253 r9551 1 1 2 from redfearn import * 2 3 from point import * -
trunk/anuga_core/source/anuga/damage_modelling/__init__.py
r3307 r9551 2 2 """ 3 3 4 #Add path of package to PYTHONPATH to allow C-extensions to be loaded 5 import sys 6 sys.path += __path__ 4 pass 7 5 8 6 9 7 8 -
trunk/anuga_core/source/anuga/file/__init__.py
r7776 r9551 49 49 """ 50 50 51 # Add path of package to PYTHONPATH to allow C-extensions to be loaded 52 import sys 53 sys.path += __path__ 51 pass 52 -
trunk/anuga_core/source/anuga/file/sww.py
r9384 r9551 18 18 from anuga.file.netcdf import NetCDFFile 19 19 20 from anuga.config import minimum_storable_height as default_minimum_storable_height 21 20 22 from sts import Write_sts 21 23 … … 23 25 ensure_geo_reference 24 26 25 from file_utils import create_filename27 from anuga.utilities.file_utils import create_filename 26 28 import numpy as num 27 29 -
trunk/anuga_core/source/anuga/file/test/test_csv.py
r9488 r9551 6 6 from anuga.utilities.system_tools import get_pathname_from_package 7 7 8 from csv_file import load_csv_as_array, load_csv_as_dict, store_parameters, \8 from anuga.file.csv_file import load_csv_as_array, load_csv_as_dict, store_parameters, \ 9 9 load_csv_as_matrix, load_csv_as_polygons, \ 10 10 load_csv_as_building_polygons -
trunk/anuga_core/source/anuga/file/test/test_mux.py
r9488 r9551 10 10 from anuga.coordinate_transforms.geo_reference import Geo_reference 11 11 12 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \12 from anuga.file.mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \ 13 13 NORTH_VELOCITY_LABEL 14 14 15 from mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \15 from anuga.file.mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \ 16 16 NORTH_VELOCITY_MUX2_LABEL 17 17 18 from mux import read_mux2_py18 from anuga.file.mux import read_mux2_py 19 19 from anuga.file_conversion.urs2sts import urs2sts 20 20 from anuga.file.urs import Read_urs … … 456 456 """ 457 457 458 from urs_ext import read_mux2458 from anuga.file.urs_ext import read_mux2 459 459 460 460 verbose = False … … 561 561 """ 562 562 563 from urs_ext import read_mux2563 from anuga.file.urs_ext import read_mux2 564 564 565 565 from anuga.config import single_precision as epsilon … … 824 824 825 825 826 from urs_ext import read_mux2826 from anuga.file.urs_ext import read_mux2 827 827 828 828 from anuga.config import single_precision as epsilon -
trunk/anuga_core/source/anuga/file/test/test_read_sww.py
r9490 r9551 199 199 rectangular_cross 200 200 from anuga.shallow_water.shallow_water_domain import Domain 201 from boundaries import Reflective_boundary201 from anuga.shallow_water.boundaries import Reflective_boundary 202 202 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\ 203 203 import Dirichlet_boundary, Time_boundary -
trunk/anuga_core/source/anuga/file_conversion/__init__.py
r7814 r9551 14 14 """ 15 15 16 # Add path of package to PYTHONPATH to allow C-extensions to be loaded 17 import sys 18 sys.path += __path__ 16 pass 19 17 18 -
trunk/anuga_core/source/anuga/file_conversion/sts2sww_mesh.py
r9550 r9551 7 7 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular 8 8 from anuga.shallow_water.shallow_water_domain import Domain 9 from boundaries import Reflective_boundary9 from anuga.shallow_water.boundaries import Reflective_boundary 10 10 from anuga.coordinate_transforms.geo_reference import Geo_reference 11 from forcing import * 11 from anuga.shallow_water.forcing import * 12 from anuga.utilities.numerical_tools import ensure_numeric 13 12 14 from anuga.file.sww import Write_sww 13 15 from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a, \ … … 16 18 def sts2sww_mesh(basename_in, basename_out=None, 17 19 spatial_thinning=1, verbose=False): 20 21 from anuga.mesh_engine.mesh_engine import NoTrianglesError 18 22 from anuga.pmesh.mesh import Mesh 19 23 if verbose: -
trunk/anuga_core/source/anuga/file_conversion/test/test_dem2dem.py
r9491 r9551 12 12 from anuga.config import g 13 13 14 from boundaries import Reflective_boundary, \14 from anuga.shallow_water.boundaries import Reflective_boundary, \ 15 15 Field_boundary, Transmissive_momentum_set_stage_boundary, \ 16 16 Transmissive_stage_zero_momentum_boundary -
trunk/anuga_core/source/anuga/file_conversion/test/test_dem2pts.py
r9476 r9551 11 11 from anuga.file.netcdf import NetCDFFile 12 12 13 from dem2pts import dem2pts14 from a sc2dem import asc2dem13 from anuga.file_conversion.dem2pts import dem2pts 14 from anuga.file_conversion.asc2dem import asc2dem 15 15 16 16 class Test_Dem2Pts(unittest.TestCase): -
trunk/anuga_core/source/anuga/file_conversion/urs2nc.py
r8150 r9551 4 4 import numpy as num 5 5 6 from anuga.anuga_exceptions import ANUGAError 6 7 from anuga.utilities.numerical_tools import ensure_numeric 7 8 from anuga.caching.caching import myhash … … 9 10 from anuga.file.netcdf import Write_nc, write_elevation_nc 10 11 11 12 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \12 import anuga.utilities.log as log 13 from anuga.file.mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \ 13 14 NORTH_VELOCITY_LABEL 14 15 -
trunk/anuga_core/source/anuga/file_conversion/urs2sts.py
r8780 r9551 1 1 import numpy as num 2 import log 2 3 import anuga.utilities.log as log 3 4 4 5 # ANUGA modules … … 160 161 161 162 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 162 169 for i, quantity in enumerate(quantities): 163 170 # For each quantity read the associated list of source mux2 file with … … 244 251 245 252 old_zone = refzone 253 old_easting = 0.0 254 old_northing = 0.0 246 255 247 256 for i in range(number_of_points): -
trunk/anuga_core/source/anuga/file_conversion/urs2sww.py
r8780 r9551 5 5 from anuga.file.urs import Read_urs 6 6 7 import anuga.utilities.log as log 8 7 9 from anuga.file_conversion.urs2nc import urs2nc 8 10 from anuga.file_conversion.ferret2sww import ferret2sww … … 14 16 Geospatial_data 15 17 16 from mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \18 from anuga.file.mux import WAVEHEIGHT_MUX_LABEL, EAST_VELOCITY_LABEL, \ 17 19 NORTH_VELOCITY_LABEL 18 20 -
trunk/anuga_core/source/anuga/fit_interpolate/__init__.py
r7876 r9551 6 6 """ 7 7 8 #Add path of package to PYTHONPATH to allow C-extensions to be loaded 9 import sys 10 sys.path += __path__ 8 pass 11 9 12 10 13 11 12 -
trunk/anuga_core/source/anuga/fit_interpolate/test/test_interpolate.py
r9550 r9551 18 18 # ANUGA code imports 19 19 import anuga 20 from interpolate import *20 from anuga.fit_interpolate.interpolate import * 21 21 from anuga.coordinate_transforms.geo_reference import Geo_reference 22 22 from anuga.utilities.numerical_tools import mean, NAN … … 913 913 for blocking_max in range(14): 914 914 #if True: 915 915 # blocking_max = 5 916 916 z = interp.interpolate(f, point_coords, 917 917 start_blocking_len=blocking_max) … … 931 931 for blocking_max in range(14): 932 932 #if True: 933 933 # blocking_max = 5 934 934 z = interp.interpolate(f, point_coords, 935 935 start_blocking_len=blocking_max) … … 945 945 assert num.allclose(z, answer) 946 946 947 z = interp.interpolate(f, point_coords, start_blocking_len = 2)947 #z = interp.interpolate(f, point_coords, start_blocking_len = 2) 948 948 949 949 #print "z",z 950 950 #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): 954 954 a = [-1.0, 0.0] 955 955 b = [3.0, 4.0] -
trunk/anuga_core/source/anuga/geometry/__init__.py
r7876 r9551 6 6 7 7 8 #Add path of package to PYTHONPATH to allow C-extensions to be loaded 9 import sys 10 sys.path += __path__ 8 pass 9 -
trunk/anuga_core/source/anuga/geometry/test/test_polygon.py
r9480 r9551 9 9 from anuga.utilities.system_tools import get_pathname_from_package 10 10 11 from polygon import _poly_xy, separate_points_by_polygon, \11 from anuga.geometry.polygon import _poly_xy, separate_points_by_polygon, \ 12 12 populate_polygon, polygon_area, is_inside_polygon, \ 13 13 read_polygon, point_on_line, point_in_polygon, \ … … 18 18 in_and_outside_polygon 19 19 20 from polygon_function import Polygon_function20 from anuga.geometry.polygon_function import Polygon_function 21 21 from anuga.coordinate_transforms.geo_reference import Geo_reference 22 22 from anuga.geospatial_data.geospatial_data import Geospatial_data … … 37 37 FN = 'polygon_ext.c' 38 38 try: 39 import polygon_ext39 import anuga.geometry.polygon_ext as polygon_ext 40 40 except: 41 from compile import compile41 from anuga.utilities.compile import compile 42 42 43 43 try: … … 46 46 raise Exception, 'Could not compile %s' %FN 47 47 else: 48 import polygon_ext48 import anuga.geometry.polygon_ext as polygon_ext 49 49 50 50 # Polygon stuff … … 1818 1818 1819 1819 def test_decimate_polygon(self): 1820 from polygon import decimate_polygon1820 from anuga.geometry.polygon import decimate_polygon 1821 1821 polygon = [[0,0], [10,10], [15,5], [20, 10], 1822 1822 [25,0], [30,10], [40,-10], [35, -5]] -
trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py
r9059 r9551 11 11 from copy import deepcopy 12 12 import copy 13 14 from exceptions import Exception 13 15 14 16 from anuga.file.netcdf import NetCDFFile … … 241 243 msg = ('Argument geo_reference must be a valid Geo_reference ' 242 244 'object or None.') 243 raise Expection(msg)245 raise (msg) 244 246 245 247 # If a geo_reference already exists, change the point data according to … … 1386 1388 if no_boundary is True: 1387 1389 msg = 'All boundaries must be defined' 1388 raise Ex pection(msg)1390 raise Exception(msg) 1389 1391 1390 1392 poly_topo = [[east_boundary, south_boundary], … … 1559 1561 """ 1560 1562 1561 from anuga.shallow_water import Domain1563 from anuga.shallow_water.shallow_water_domain import Domain 1562 1564 from anuga.geospatial_data.geospatial_data import Geospatial_data 1563 1565 from anuga.pmesh.mesh_interface import create_mesh_from_regions … … 1579 1581 if no_boundary is True: 1580 1582 msg = 'All boundaries must be defined' 1581 raise Ex pection(msg)1583 raise Exception(msg) 1582 1584 1583 1585 poly_topo = [[east_boundary, south_boundary], -
trunk/anuga_core/source/anuga/lib/__init__.py
r6213 r9551 4 4 pass 5 5 6 #Add path of package to PYTHONPATH to allow C-extensions to be loaded7 import sys8 sys.path += __path__9 6 10 7 11 8 9 -
trunk/anuga_core/source/anuga/operators/__init__.py
r8133 r9551 6 6 pass 7 7 8 #Add path of package to PYTHONPATH to allow C-extensions to be loaded9 import sys10 sys.path += __path__11 8 9 -
trunk/anuga_core/source/anuga/operators/set_friction_operators.py
r9001 r9551 126 126 127 127 128 D pth_friction_operator.__init__(self,128 Depth_friction_operator.__init__(self, 129 129 domain, 130 130 friction=friction, -
trunk/anuga_core/source/anuga/operators/test/test_rate_operators.py
r9445 r9551 18 18 from anuga.fit_interpolate.interpolate import Modeltime_too_late 19 19 20 from rate_operators import *20 from anuga.operators.rate_operators import * 21 21 22 22 import numpy as num -
trunk/anuga_core/source/anuga/operators/test/test_set_elevation_operator.py
r9445 r9551 13 13 from anuga.config import time_format 14 14 15 from set_elevation_operator import *15 from anuga.operators.set_elevation_operator import * 16 16 17 17 import numpy as num -
trunk/anuga_core/source/anuga/operators/test/test_set_quantity.py
r9445 r9551 13 13 from anuga.config import time_format 14 14 15 from set_quantity import *16 from set_stage import *15 from anuga.operators.set_quantity import * 16 from anuga.operators.set_stage import * 17 17 18 18 import numpy as num -
trunk/anuga_core/source/anuga/operators/test/test_set_stage_operator.py
r9445 r9551 13 13 from anuga.config import time_format 14 14 15 from set_stage_operator import *15 from anuga.operators.set_stage_operator import * 16 16 17 17 import numpy as num -
trunk/anuga_core/source/anuga/operators/test/test_set_w_uh_vh_operators.py
r9445 r9551 13 13 from anuga.config import time_format 14 14 15 from set_w_uh_vh_operator import *15 from anuga.operators.set_w_uh_vh_operator import * 16 16 17 17 import numpy as num -
trunk/anuga_core/source/anuga/parallel/test/test_parallel_file_boundary.py
r9501 r9551 41 41 from anuga import File_boundary 42 42 43 from mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \43 from anuga.file.mux import WAVEHEIGHT_MUX2_LABEL, EAST_VELOCITY_MUX2_LABEL, \ 44 44 NORTH_VELOCITY_MUX2_LABEL 45 from mux import read_mux2_py45 from anuga.file.mux import read_mux2_py 46 46 from anuga.file_conversion.urs2sts import urs2sts 47 47 from anuga.file.urs import Read_urs -
trunk/anuga_core/source/anuga/pmesh/mesh.py
r9063 r9551 2255 2255 log.critical("The region list has a bad size") 2256 2256 # raise an error .. 2257 raise E rror2257 raise Exception 2258 2258 2259 2259 #remove "" from the region_list -
trunk/anuga_core/source/anuga/pymetis/__init__.py
r3095 r9551 4 4 pass 5 5 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 6 6 """ 7 7 8 # Add path of package to PYTHONPATH to allow C-extensions to be loaded 9 import sys 10 sys.path += __path__ 8 pass 11 9 12 10 -
trunk/anuga_core/source/anuga/shallow_water/test/test_loadsave.py
r9457 r9551 29 29 from anuga.shallow_water.sww_interrogate import get_flow_through_cross_section 30 30 31 from shallow_water_domain import Domain31 from anuga.shallow_water.shallow_water_domain import Domain 32 32 33 33 # boundary functions -
trunk/anuga_core/source/anuga/shallow_water/test/test_shallow_water_domain.py
r9550 r9551 831 831 832 832 833 from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes833 from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes 834 834 # Now check that compute_flux yields zeros as well 835 835 compute_fluxes(domain) … … 927 927 928 928 929 from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes929 from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes 930 930 # Now check that compute_flux yields zeros as well 931 931 compute_fluxes(domain) … … 1015 1015 1016 1016 1017 from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes1017 from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes 1018 1018 # Now check that compute_flux yields zeros as well 1019 1019 compute_fluxes(domain) … … 1097 1097 1098 1098 1099 from shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes1099 from anuga.shallow_water.shallow_water_ext import compute_fluxes_ext_central_structure as compute_fluxes 1100 1100 # Now check that compute_flux yields zeros as well 1101 1101 flux_timestep = compute_fluxes(domain) … … 2657 2657 2658 2658 #domain.compute_forcing_terms() 2659 from shallow_water_ext import gravity2659 from anuga.shallow_water.shallow_water_ext import gravity 2660 2660 gravity(domain) 2661 2661 … … 2704 2704 2705 2705 #domain.compute_forcing_terms() 2706 from shallow_water_ext import gravity2706 from anuga.shallow_water.shallow_water_ext import gravity 2707 2707 gravity(domain) 2708 2708 … … 2862 2862 assert num.allclose(domain.quantities[name].semi_implicit_update, 0) 2863 2863 2864 from shallow_water_ext import gravity_wb2864 from anuga.shallow_water.shallow_water_ext import gravity_wb 2865 2865 gravity_wb(domain) 2866 2866 … … 2909 2909 assert num.allclose(domain.quantities[name].semi_implicit_update, 0) 2910 2910 2911 from shallow_water_ext import gravity_wb2911 from anuga.shallow_water.shallow_water_ext import gravity_wb 2912 2912 gravity_wb(domain) 2913 2913 … … 7179 7179 except RuntimeError, e: 7180 7180 msg = 'Test failed: %s' % str(e) 7181 raise Exception ,(sg)7181 raise Exception(msg) 7182 7182 # clean up in case raise fails 7183 7183 os.remove(meshname) … … 7631 7631 from anuga.shallow_water.shallow_water_domain import Domain 7632 7632 from anuga.shallow_water.boundaries import Reflective_boundary 7633 from anuga .shallow_water.shallow_water_domainimport Dirichlet_boundary7634 from anuga.shallow_water. shallow_water_domainimport Rainfall7633 from anuga import Dirichlet_boundary 7634 from anuga.shallow_water.forcing import Rainfall 7635 7635 from anuga.shallow_water.sww_interrogate import get_flow_through_cross_section 7636 7636 … … 8046 8046 8047 8047 8048 from anuga.shallow_water.boundaries import Inflow_boundary 8048 8049 8049 8050 Bi = Inflow_boundary(domain, rate=ref_flow) … … 8121 8122 import rectangular_cross 8122 8123 from anuga.shallow_water.shallow_water_domain import Domain 8123 from anuga.shallow_water. shallow_water_domainimport Reflective_boundary8124 from anuga .shallow_water.shallow_water_domainimport Dirichlet_boundary8124 from anuga.shallow_water.boundaries import Reflective_boundary 8125 from anuga import Dirichlet_boundary 8125 8126 from anuga.shallow_water.forcing import Inflow 8126 from anuga.shallow_water.data_manager \ 8127 import get_flow_through_cross_section 8127 8128 8128 from anuga.abstract_2d_finite_volumes.util \ 8129 8129 import sww2csv_gauges, csv2timeseries_graphs -
trunk/anuga_core/source/anuga/structures/__init__.py
r7961 r9551 1 2 pass -
trunk/anuga_core/source/anuga/tsunami_source/__init__.py
r9457 r9551 6 6 """ 7 7 8 # Add path of package to PYTHONPATH to allow C-extensions to be loaded 9 import sys 10 sys.path += __path__ 8 pass 9 11 10 12 11 -
trunk/anuga_core/source/anuga/utilities/__init__.py
r7876 r9551 8 8 pass 9 9 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 8 8 import tempfile 9 9 from anuga.utilities.log import TimingDelimiter 10 from log_analyser import analyse_log10 from anuga.utilities.log_analyser import analyse_log 11 11 12 12 class logTestCase(unittest.TestCase): -
trunk/anuga_core/source/anuga/utilities/test/test_mem_time_equation.py
r9435 r9551 10 10 import anuga 11 11 12 from mem_time_equation import *12 from anuga.utilities.mem_time_equation import * 13 13 14 14 class Test_mem_time_equation(unittest.TestCase): -
trunk/anuga_core/source/anuga/utilities/test/test_numerical_tools.py
r9435 r9551 8 8 from math import sqrt, pi 9 9 from anuga.config import epsilon 10 from numerical_tools import *10 from anuga.utilities.numerical_tools import * 11 11 12 12 … … 263 263 FN = 'util_ext.c' 264 264 try: 265 import util_ext265 import anuga.utilities.util_ext as util_ext 266 266 except: 267 from compile import compile267 from anuga.utilities.compile import compile 268 268 269 269 try: … … 272 272 raise Exception('Could not compile %s' % FN) 273 273 else: 274 import util_ext274 import anuga.utilities.util_ext as util_ext 275 275 276 276 277 277 def test_gradient_C_extension(self): 278 from util_ext import gradient as gradient_c278 from anuga.utilities.util_ext import gradient as gradient_c 279 279 280 280 x0 = 2.0/3; y0 = 2.0/3 … … 294 294 295 295 def test_gradient_C_extension3(self): 296 from util_ext import gradient as gradient_c296 from anuga.utilities.util_ext import gradient as gradient_c 297 297 298 298 seed((17, 53)) -
trunk/anuga_core/source/anuga/validation_utilities/__init__.py
r9309 r9551 2 2 Validation tests 3 3 """ 4 5 #Add path of package to PYTHONPATH to allow C-extensions to be loaded6 import sys7 sys.path += __path__8 4 9 5 -
trunk/anuga_core/source/anuga/visualiser/__init__.py
r3623 r9551 1 1 2 from realtime import RealtimeVisualiser 2 3 from offline import OfflineVisualiser
Note: See TracChangeset
for help on using the changeset viewer.