Ignore:
Timestamp:
Feb 25, 2009, 9:37:22 AM (15 years ago)
Author:
rwilson
Message:

numpy changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/shallow_water/test_shallow_water_domain.py

    r6304 r6410  
    199199
    200200    return 17.7
     201
     202
     203def scalar_func_list(t,x,y):
     204    """Function that returns a scalar.
     205    Used to test error message when numeric array is expected
     206    """
     207
     208    return [17.7]
    201209
    202210
     
    24622470
    24632471        try:
    2464             domain.forcing_terms.append(Wind_stress(s = scalar_func,
     2472            domain.forcing_terms.append(Wind_stress(s = scalar_func_list,
    24652473                                                    phi = angle))
    24662474        except AssertionError:
     
    24742482            domain.forcing_terms.append(Wind_stress(s = speed,
    24752483                                                    phi = scalar_func))
    2476         except AssertionError:
     2484        except Exception:
    24772485            pass
    24782486        else:
     
    55825590        #print take(cv2, (0,3,8))
    55835591
    5584         assert num.allclose( num.take(cv1, (0,8,16)), num.take(cv2, (0,3,8))) #Diag
    5585         assert num.allclose( num.take(cv1, (0,6,12)), num.take(cv2, (0,1,4))) #Bottom
    5586         assert num.allclose( num.take(cv1, (12,14,16)), num.take(cv2, (4,6,8))) #RHS
     5592        assert num.allclose(num.take(cv1, (0,8,16), axis=0),
     5593                            num.take(cv2, (0,3,8), axis=0))    #Diag
     5594        assert num.allclose(num.take(cv1, (0,6,12), axis=0),
     5595                            num.take(cv2, (0,1,4), axis=0))    #Bottom
     5596        assert num.allclose(num.take(cv1, (12,14,16), axis=0),
     5597                            num.take(cv2, (4,6,8), axis=0))    #RHS
    55875598
    55885599        #Cleanup
     
    56905701
    56915702        #print points[0], points[5], points[10], points[15]
    5692         msg = ('value was %s,\nshould be [[0,0], [1.0/3, 1.0/3], '
    5693                '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15])))
    5694         assert num.allclose(num.take(points, [0,5,10,15]),
     5703        msg = ('value was\n%s\nshould be\n'
     5704               '[[0,0], [1.0/3, 1.0/3],\n'
     5705               '[2.0/3, 2.0/3], [1,1]]'
     5706               % str(num.take(points, [0,5,10,15], axis=0)))
     5707        assert num.allclose(num.take(points, [0,5,10,15], axis=0),
    56955708                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
    56965709
     
    58735886
    58745887        #print points[0], points[5], points[10], points[15]
    5875         msg = ('values was %s,\nshould be [[0,0], [1.0/3, 1.0/3], '
    5876                '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15])))
    5877         assert num.allclose(num.take(points, [0,5,10,15]),
     5888        msg = ('values was\n%s\nshould be\n'
     5889               '[[0,0], [1.0/3, 1.0/3],\n'
     5890               '[2.0/3, 2.0/3], [1,1]]'
     5891               % str(num.take(points, [0,5,10,15], axis=0)))
     5892        assert num.allclose(num.take(points, [0,5,10,15], axis=0),
    58785893                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
    58795894
     
    60486063
    60496064        #print points[0], points[5], points[10], points[15]
    6050         msg = ('value was %s,\nshould be [[0,0], [1.0/3, 1.0/3], '
    6051                '[2.0/3, 2.0/3], [1,1]]' % str(num.take(points, [0,5,10,15])))
    6052         assert num.allclose(num.take(points, [0,5,10,15]),
     6065        msg = ('value was\n%s\nshould be\n'
     6066               '[[0,0], [1.0/3, 1.0/3],\n'
     6067               '[2.0/3, 2.0/3], [1,1]]'
     6068               % str(num.take(points, [0,5,10,15], axis=0)))
     6069        assert num.allclose(num.take(points, [0,5,10,15], axis=0),
    60536070                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
    60546071
     
    66266643       
    66276644if __name__ == "__main__":
    6628 
    6629     suite = unittest.makeSuite(Test_Shallow_Water, 'test')
    6630     #suite = unittest.makeSuite(Test_Shallow_Water, 'test_rainfall_forcing_with_evolve')
    6631     #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_energy_through_cross_section_with_g')   
    6632     #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain')   
    6633     #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
    6634     #suite = unittest.makeSuite(Test_Shallow_Water,'test_inflow_outflow_conservation')
    6635     #suite = unittest.makeSuite(Test_Shallow_Water,'test_outflow_conservation_problem_temp')   
    6636    
    6637 
    6638    
     6645    #suite = unittest.makeSuite(Test_Shallow_Water, 'test')
     6646    suite = unittest.makeSuite(Test_Shallow_Water, 'test_get_maximum_inundation_from_sww')
    66396647    runner = unittest.TextTestRunner(verbosity=1)   
    66406648    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.