Changeset 7855

Ignore:
Timestamp:
Jun 17, 2010, 5:34:13 PM (13 years ago)
Message:

Changing for loop to numpy.where

Location:
anuga_work/development/2010-projects/anuga_1d
Files:
6 edited
1 moved

Unmodified
Removed
• anuga_work/development/2010-projects/anuga_1d/base/limiters_python.py

 r7852 from numpy import sign, abs, minimum, where return where( (sign(a)*sign(b) > 0.0) & (sign(a)*sign(c)>0.0), sign(a)*minimum(abs(a),abs(b),abs(c)), 0.0 ) return where( (sign(a)*sign(b) > 0.0) & (sign(a)*sign(c)>0.0), sign(a)*minimum(minimum(abs(a),abs(b)),abs(c)), 0.0 )

• anuga_work/development/2010-projects/anuga_1d/base/test_generic_domain.py

 r7852 import unittest from math import sqrt, pi import numpy from anuga_1d.base.generic_domain import * import numpy #------------------------------------------------------------- if __name__ == "__main__":
• anuga_work/development/2010-projects/anuga_1d/base/test_quantity_1d.py

 r7851 from generic_domain import Generic_domain as Domain from anuga_1d.base.generic_domain import Generic_domain as Domain #from shallow_water_domain import flux_function as domain_flux_function from quantity import * from anuga_1d.base.quantity import * self.domain6 = Domain(self.points6) def tearDown(self): pass assert self.domain4.boundary  == {(0, 0): 'left', (3, 1): 'right'} def test_creation(self): def test_find_qmax_qmin(self): quantity = Quantity(self.domain4) quantity.set_values([1.0, 4.0, 8.0, 2.0], location = 'centroids') quantity.find_qmax_qmin() assert allclose(quantity.qmax, [4.0, 8.0, 8.0, 8.0]) assert allclose(quantity.qmin, [1.0, 1.0, 2.0, 2.0]) def test_distribute_first_order(self): quantity = Quantity(self.domain4)
• anuga_work/development/2010-projects/anuga_1d/channel/channel_domain.py

 r7852 if domain.discontinousb: domain.quantities['width'].extrapolate_second_order() # FIXME (SGR): Replace with numpy.where to speed up code width.extrapolate_second_order() h0 = 1.0e-12 w_C[:] = h_C + z_C #    for i in range(N): # #        if a_C[i] <= h0: #           a_C[i] = 0.0 #           h_C[i] = 0.0 #            d_C[i] = 0.0 #            u_C[i] = 0.0 #            w_C[i] = z_C[i] #        else: # #            if b_C[i]<=h0: #                a_C[i] = 0.0 #                h_C[i] = 0.0 #                d_C[i] = 0.0 #                u_C[i] = 0.0 #                w_C[i] = z_C[i] # #            else: #                h_C[i] = a_C[i]/(b_C[i]+h0/b_C[i]) #                w_C[i] = h_C[i]+z_C[i] #                u_C[i] = d_C[i]/(a_C[i]+h0/a_C[i]) b_V  = width.vertex_values #FIXME (SGR): replace with numpy.where h_V[:] = w_V-z_V d_V[:] = u_V*a_V #    for i in range(len(h_C)): #        for j in range(2): #            h_V[i,j] = w_V[i,j]-z_V[i,j] #            if h_V[i,j]
• anuga_work/development/2010-projects/anuga_1d/channel/profile_channel.py

 r7852 #p.strip_dirs().sort_stats(-1).print_stats(20) p.sort_stats('cumulative').print_stats(10) p.sort_stats('cumulative').print_stats(30) print p
• anuga_work/development/2010-projects/anuga_1d/test_all.py

 r7840 # Directories that should not be searched for test files. exclude_dirs = ['channel',    # Special requirements '.svn',       # subversion 'props', 'wcprops', 'prop-base', 'text-base', 'tmp'] exclude_dirs = ['channel',  '.svn'] # @brief Check that the environment is sane. # @note Stops here if there is an error. def check_anuga_import(): def check_anuga_1d_import(): try: # importing something that loads quickly import anuga.anuga_exceptions import anuga_1d.config except ImportError: print "Python cannot import ANUGA module." print "Python cannot import ANUGA_1D module." print "Check you have followed all steps of its installation." import sys if __name__ == '__main__': check_anuga_import() check_anuga_1d_import() print 'test-all' if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
Note: See TracChangeset for help on using the changeset viewer.