Changeset 37dea17 in sasview for sansdataloader/test/utest_manipulations.py
- Timestamp:
- May 29, 2012 4:01:32 PM (12 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- a1fa589
- Parents:
- 5617775
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansdataloader/test/utest_manipulations.py
re2605a5 r37dea17 133 133 def setUp(self): 134 134 # Create two data sets to play with 135 x_0 = 2.0*numpy.ones( 100)136 dx_0 = 0.5*numpy.ones( 100)137 qx_0 = numpy.arange( 100)138 qy_0 = numpy.arange( 100)139 mask_0 = numpy.zeros( 100)140 dqx_0 = numpy.arange( 100)/100141 dqy_0 = numpy.arange( 100)/100135 x_0 = 2.0*numpy.ones(25) 136 dx_0 = 0.5*numpy.ones(25) 137 qx_0 = numpy.arange(25) 138 qy_0 = numpy.arange(25) 139 mask_0 = numpy.zeros(25) 140 dqx_0 = numpy.arange(25)/100 141 dqy_0 = numpy.arange(25)/100 142 142 q_0 = numpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 143 143 self.data = Data2D(x_0, dx_0, qx_0, qy_0, q_0, mask_0, dqx_0, dqy_0) 144 144 145 y = numpy.ones( 100)146 dy = numpy.ones( 100)147 qx = numpy.arange( 100)148 qy = numpy.arange( 100)149 mask = numpy.zeros( 100)145 y = numpy.ones(25) 146 dy = numpy.ones(25) 147 qx = numpy.arange(25) 148 qy = numpy.arange(25) 149 mask = numpy.zeros(25) 150 150 q = numpy.sqrt(qx * qx + qy * qy) 151 151 self.data2 = Data2D(y, dy, qx, qy, q, mask) … … 157 157 """ 158 158 # There should be 5 entries in the file 159 self.assertEqual(numpy.size(self.data.data), 100)160 161 for i in range( 100):159 self.assertEqual(numpy.size(self.data.data), 25) 160 161 for i in range(25): 162 162 # All y-error values should be 0.5 163 163 self.assertEqual(self.data.err_data[i], 0.5) … … 168 168 def test_add(self): 169 169 result = self.data2+self.data 170 for i in range( 100):170 for i in range(25): 171 171 self.assertEqual(result.data[i], 3.0) 172 172 self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0)) … … 174 174 def test_sub(self): 175 175 result = self.data2-self.data 176 for i in range( 100):176 for i in range(25): 177 177 self.assertEqual(result.data[i], -1.0) 178 178 self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0)) … … 180 180 def test_mul(self): 181 181 result = self.data2*self.data 182 for i in range( 100):182 for i in range(25): 183 183 self.assertEqual(result.data[i], 2.0) 184 184 self.assertEqual(result.err_data[i], math.sqrt((0.5*1.0)**2+(1.0*2.0)**2)) … … 186 186 def test_div(self): 187 187 result = self.data2/self.data 188 for i in range( 100):188 for i in range(25): 189 189 self.assertEqual(result.data[i], 0.5) 190 190 self.assertEqual(result.err_data[i], math.sqrt((1.0/2.0)**2+(0.5*1.0/4.0)**2)) … … 192 192 def test_radd(self): 193 193 result = self.data+3.0 194 for i in range( 100):194 for i in range(25): 195 195 self.assertEqual(result.data[i], 5.0) 196 196 self.assertEqual(result.err_data[i], 0.5) 197 197 198 198 result = 3.0+self.data 199 for i in range( 100):199 for i in range(25): 200 200 self.assertEqual(result.data[i], 5.0) 201 201 self.assertEqual(result.err_data[i], 0.5) … … 203 203 def test_rsub(self): 204 204 result = self.data-3.0 205 for i in range( 100):205 for i in range(25): 206 206 self.assertEqual(result.data[i], -1.0) 207 207 self.assertEqual(result.err_data[i], 0.5) 208 208 209 209 result = 3.0-self.data 210 for i in range( 100):210 for i in range(25): 211 211 self.assertEqual(result.data[i], 1.0) 212 212 self.assertEqual(result.err_data[i], 0.5) … … 214 214 def test_rmul(self): 215 215 result = self.data*3.0 216 for i in range( 100):216 for i in range(25): 217 217 self.assertEqual(result.data[i], 6.0) 218 218 self.assertEqual(result.err_data[i], 1.5) 219 219 220 220 result = 3.0*self.data 221 for i in range( 100):221 for i in range(25): 222 222 self.assertEqual(result.data[i], 6.0) 223 223 self.assertEqual(result.err_data[i], 1.5) … … 225 225 def test_rdiv(self): 226 226 result = self.data/4.0 227 for i in range( 100):227 for i in range(25): 228 228 self.assertEqual(result.data[i], 0.5) 229 229 self.assertEqual(result.err_data[i], 0.125) 230 230 231 231 result = 6.0/self.data 232 for i in range( 100):232 for i in range(25): 233 233 self.assertEqual(result.data[i], 3.0) 234 234 self.assertEqual(result.err_data[i], 6.0*0.5/4.0)
Note: See TracChangeset
for help on using the changeset viewer.