def test_dx_multiple_spectrum(self): dataX = [3, 2, 1, 3, 2, 1] # In descending order, so y and e will need to be reversed. dataY = [1, 2, 3, 1, 2, 3] dx = [1, 2, 3, 1, 2, 3] unsortedws = CreateWorkspace(DataX=dataX, DataY=dataY, Dx=dx, UnitX='TOF', Distribution=True, NSpec=2) dx.reverse() # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) # Check the resulting data values for 1st spectrum. sortedDx = sortedws.readDx(0) self.assertEqual(dx[0:3], sortedDx.tolist()) # Check the resulting data values for 2nd spectrum. sortedDx = sortedws.readDx(1) self.assertEqual(dx[3:], sortedDx.tolist()) DeleteWorkspace(unsortedws) DeleteWorkspace(sortedws)
def test_dx_histogram_ascending(self): dataX = [1., 2., 3., 4.] dataY = [1., 2., 3.] dx = [1., 2., 3.] unsortedws = CreateWorkspace(DataX=dataX, DataY=dataY, Dx=dx, UnitX='TOF', Distribution=False) # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) sortedDx = sortedws.readDx(0) # Check the resulting data values. Sorting operation should have resulted in no changes self.assertEqual(dx, sortedDx.tolist()) DeleteWorkspace(unsortedws) DeleteWorkspace(sortedws)
def test_dx_multiple_spectrum(self): dataX = [3, 2, 1, 3, 2, 1 ] # In descending order, so y and e will need to be reversed. dataY = [1, 2, 3, 1, 2, 3] dx = [1, 2, 3, 1, 2, 3] unsortedws = CreateWorkspace(DataX=dataX, DataY=dataY, Dx=dx, UnitX='TOF', Distribution=True, NSpec=2) dx.reverse() # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) # Check the resulting data values for 1st spectrum. sortedDx = sortedws.readDx(0) self.assertEqual(dx[0:3], sortedDx.tolist()) # Check the resulting data values for 2nd spectrum. sortedDx = sortedws.readDx(1) self.assertEqual(dx[3:], sortedDx.tolist()) DeleteWorkspace(unsortedws) DeleteWorkspace(sortedws)