Changeset 5494 for anuga_work/development/Hinwood_2008/test_slope.py
- Timestamp:
- Jul 11, 2008, 4:15:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/Hinwood_2008/test_slope.py
r5447 r5494 10 10 import tempfile 11 11 12 from scipy import array, allclose 12 from Numeric import array, allclose 13 from anuga.utilities.numerical_tools import ensure_numeric 14 13 15 14 16 from slope import * … … 33 35 handle.write(sample) 34 36 handle.close() 35 dtimes, depths, sensors = load_ depths(file_name)37 dtimes, depths, sensors = load_sensors(file_name) 36 38 actual = array([0,0.01,0.02,0.03]) 37 39 self.assert_ (allclose(dtimes, actual, 0.001)) … … 73 75 handle.write(sample) 74 76 handle.close() 75 graph_slopes(file_name)76 77 78 # since it currently graphs 79 #graph_slopes(file_name) 77 80 78 81 os.remove(file_name) 79 82 83 def test_get_min_in_band(self): 84 time = array([0,1,2,3,4,5]) 85 slopes = array([[10,12], 86 [9,10], 87 [8,9], 88 [9,7], 89 [10,6], 90 [7,2]]) 91 92 max_q, max_q_times = get_min_in_band(0,5,time,slopes) 93 actual = array([8,6]) 94 self.assert_ (allclose(max_q, actual, 0.001)) 95 actual = array([2,4]) 96 self.assert_ (allclose(max_q_times, actual, 0.001)) 97 98 99 max_q, max_q_times = get_min_in_band(1,4,time,slopes) 100 actual = array([8,7]) 101 self.assert_ (allclose(max_q, actual, 0.001)) 102 actual = array([2,3]) 103 self.assert_ (allclose(max_q_times, actual, 0.001)) 104 105 def test_break_times2bands(self): 106 break_times = [1,3,4,8] 107 band_offset = 0.0 108 bands = break_times2bands(break_times, band_offset) 109 #print "bands", bands 110 actual = array([0,2,3.5,6,10 ]) 111 self.assert_ (allclose(ensure_numeric(bands), actual, 0.001)) 112 113 def test_get_time_band(self): 114 time = array([0,1,2,3,4,5]) 115 slopes = array([[10,12], 116 [9,10], 117 [8,9], 118 [9,7], 119 [10,6], 120 [7,2]]) 121 122 band_time, band_quantity = get_time_band(0,5,time,slopes) 123 actual = array([1,2,3,4]) 124 self.assert_ (allclose(band_time, actual, 0.001)) 125 actual = array([[9,10], 126 [8,9], 127 [9,7], 128 [10,6]]) 129 self.assert_ (allclose(band_quantity, actual, 0.001)) 130 131 132 def test_get_band(self): 133 time = array([0,1,2,3,4,5]) 134 slopes = array([[10,12], 135 [9,10], 136 [8,9], 137 [9,7], 138 [10,6], 139 [7,2]]) 140 141 band_time, band_quantity = get_band(0,5,time,slopes,0) 142 actual = array([1,2,3,4]) 143 self.assert_ (allclose(band_time, actual, 0.001)) 144 actual = array([[9,10], 145 [8,9], 146 [9,7], 147 [10,6]]) 148 self.assert_ (allclose(band_quantity, actual, 0.001)) 149 150 location = array([0,1,2,3,4,5]) 151 slopes = array([[0,1,2,3,4,5], 152 [0,10,20,30,40,50]]) 153 154 band_time, band_quantity = get_band(0,5,location,slopes,-1) 155 actual = array([1,2,3,4]) 156 self.assert_ (allclose(band_time, actual, 0.001)) 157 actual = array([[1,2,3,4], 158 [10,20,30,40]]) 159 self.assert_ (allclose(band_quantity, actual, 0.001)) 160 80 161 if __name__ == "__main__": 81 162 82 163 suite = unittest.makeSuite(slopeTestCase,'test') 164 suite = unittest.makeSuite(slopeTestCase,'test_get_band') 165 83 166 runner = unittest.TextTestRunner() #verbosity=2) 84 167 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.