def test_count_relax_times_cpmg(self): """Unit test of the count_relax_times() function. This uses the data of the saved state attached to U{bug #21665<https://gna.org/bugs/?21665>}. """ # Load the state. statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2' state.load_state(statefile, force=True) # Original data (exp_type, frq). data = [ ['SQ CPMG', 499862140.0], ['SQ CPMG', 599890858.69999993] ] # Original indices (ei, mi). indices = [ [0, 0], [0, 1] ] # Check the number of time counts. print("Checking the number of time counts.") for id in cdp.exp_type: exp_type = cdp.exp_type[id] frq = cdp.spectrometer_frq[id] point = cdp.cpmg_frqs[id] count = count_relax_times(exp_type = exp_type, frq = frq, point = point, ei = cdp.exp_type_list.index(cdp.exp_type[id])) print(id, exp_type, frq, point, count) # Test the data if id.split('A')[0] == 'Z_': self.assertEqual(exp_type, data[0][0]) self.assertEqual(frq, data[0][1]) elif id.split('B')[0] == 'Z_': self.assertEqual(exp_type, data[1][0]) self.assertEqual(frq, data[1][1]) # Test the time count self.assertEqual(count, 1)
def test_count_relax_times_cpmg(self): """Unit test of the count_relax_times() function. This uses the data of the saved state attached to U{bug #21665<https://web.archive.org/web/https://gna.org/bugs/?21665>}. """ # Load the state. statefile = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'bug_21665.bz2' state.load_state(statefile, force=True) # Original data (exp_type, frq). data = [['SQ CPMG', 499862140.0], ['SQ CPMG', 599890858.69999993]] # Original indices (ei, mi). indices = [[0, 0], [0, 1]] # Check the number of time counts. print("Checking the number of time counts.") for id in cdp.exp_type: exp_type = cdp.exp_type[id] frq = cdp.spectrometer_frq[id] point = cdp.cpmg_frqs[id] count = count_relax_times(exp_type=exp_type, frq=frq, point=point, ei=cdp.exp_type_list.index( cdp.exp_type[id])) print(id, exp_type, frq, point, count) # Test the data if id.split('A')[0] == 'Z_': self.assertEqual(exp_type, data[0][0]) self.assertEqual(frq, data[0][1]) elif id.split('B')[0] == 'Z_': self.assertEqual(exp_type, data[1][0]) self.assertEqual(frq, data[1][1]) # Test the time count self.assertEqual(count, 1)
def test_count_relax_times_r1rho(self): """Unit test of the count_relax_times() function. This uses the data of the saved state attached to U{bug #21344<https://gna.org/bugs/?21344>}. """ # Load the state. statefile = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21344_trunc.bz2' state.load_state(statefile, force=True) # Original data (spectrum id: exp_type, frq, omega_rf_ppm, spin_lock_field_strength, time_spin_lock). data = dict() data['46_0_35_0'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.0] data['48_0_35_4'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.04] data['47_0_35_10'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.1] data['49_0_35_20'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.2] data['36_0_39_0'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.0] data['39_0_39_4'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.04] data['37_0_39_10'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.1] data['40_0_39_20'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.2] data['38_0_39_40'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.4] data['41_0_41_0'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.0] data['44_0_41_4'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.04] data['42_0_41_10'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.1] data['45_0_41_20'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.2] data['43_0_41_40'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.4] data['31_0_43_0'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.0] data['34_0_43_4'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.04] data['32_0_43_10'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.1] data['35_0_43_20'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.2] data['33_0_43_40'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.4] data['1_0_46_0'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.0] data['4_0_46_4'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.04] data['2_0_46_10'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.1] data['5_0_46_20'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.2] data['3_0_46_40'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.4] data['60_0_48_0'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.0] data['63_0_48_4'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.04] data['61_0_48_10'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.1] data['62_0_48_14'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.14] data['64_0_48_20'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.2] data['11_500_46_0'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.0] data['14_500_46_4'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.04] data['12_500_46_10'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.1] data['15_500_46_20'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.2] data['13_500_46_40'] = ['R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.4] data['50_1000_41_0'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.0] data['53_1000_41_4'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.04] data['51_1000_41_10'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.1] data['54_1000_41_20'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.2] data['52_1000_41_40'] = ['R1rho', 799777399.1, 130.41606292412092, 800.5, 0.4] data['21_1000_46_0'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.0] data['24_1000_46_4'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.04] data['22_1000_46_10'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.1] data['25_1000_46_20'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.2] data['23_1000_46_40'] = ['R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.4] data['65_1000_48_0'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.0] data['68_1000_48_4'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.04] data['66_1000_48_10'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.1] data['67_1000_48_14'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.14] data['69_1000_48_20'] = ['R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.2] data['55_2000_41_0'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.0] data['58_2000_41_4'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.04] data['56_2000_41_10'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.1] data['59_2000_41_20'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.2] data['57_2000_41_40'] = ['R1rho', 799777399.1, 142.75412584824184, 800.5, 0.4] data['6_2000_46_0'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.0] data['9_2000_46_4'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.04] data['7_2000_46_10'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.1] data['10_2000_46_20'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.2] data['8_2000_46_40'] = ['R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.4] data['16_5000_46_0'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.0] data['19_5000_46_4'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.04] data['17_5000_46_10'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.1] data['20_5000_46_20'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.2] data['18_5000_46_40'] = ['R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.4] data['26_10000_46_0'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.0] data['29_10000_46_4'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.04] data['27_10000_46_10'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.1] data['30_10000_46_20'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.2] data['28_10000_46_40'] = ['R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.4] time_comp = { '118.078_431.00':4, '118.078_651.20':5, '118.078_800.50':5, '118.078_984.00':5, '118.078_1341.11':5, '118.078_1648.50':5, '124.247_1341.11':5, '130.416_800.50':5, '130.416_1341.11':5, '130.416_1648.50':5, '142.754_800.50':5, '142.754_1341.11':5, '179.768_1341.11':5, '241.459_1341.11':5} # Check the number of time counts. print("Checking the number of time counts.") for id in cdp.exp_type: exp_type = cdp.exp_type[id] frq = cdp.spectrometer_frq[id] offset = cdp.spin_lock_offset[id] point = cdp.spin_lock_nu1[id] count = count_relax_times(exp_type = exp_type, frq = frq, offset=offset, point = point, ei = cdp.exp_type_list.index(cdp.exp_type[id])) print(id, exp_type, frq, offset, point, count) # Test the time count print(time_comp) self.assertEqual(count, time_comp['%.3f_%.2f'%(offset, point)])
def test_count_relax_times_r1rho(self): """Unit test of the count_relax_times() function. This uses the data of the saved state attached to U{bug #21344<https://web.archive.org/web/https://gna.org/bugs/?21344>}. """ # Load the state. statefile = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'bug_21344_trunc.bz2' state.load_state(statefile, force=True) # Original data (spectrum id: exp_type, frq, omega_rf_ppm, spin_lock_field_strength, time_spin_lock). data = dict() data['46_0_35_0'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.0] data['48_0_35_4'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.04] data['47_0_35_10'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.1] data['49_0_35_20'] = ['R1rho', 799777399.1, 118.078, 431.0, 0.2] data['36_0_39_0'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.0] data['39_0_39_4'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.04] data['37_0_39_10'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.1] data['40_0_39_20'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.2] data['38_0_39_40'] = ['R1rho', 799777399.1, 118.078, 651.2, 0.4] data['41_0_41_0'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.0] data['44_0_41_4'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.04] data['42_0_41_10'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.1] data['45_0_41_20'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.2] data['43_0_41_40'] = ['R1rho', 799777399.1, 118.078, 800.5, 0.4] data['31_0_43_0'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.0] data['34_0_43_4'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.04] data['32_0_43_10'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.1] data['35_0_43_20'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.2] data['33_0_43_40'] = ['R1rho', 799777399.1, 118.078, 984.0, 0.4] data['1_0_46_0'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.0] data['4_0_46_4'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.04] data['2_0_46_10'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.1] data['5_0_46_20'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.2] data['3_0_46_40'] = ['R1rho', 799777399.1, 118.078, 1341.11, 0.4] data['60_0_48_0'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.0] data['63_0_48_4'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.04] data['61_0_48_10'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.1] data['62_0_48_14'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.14] data['64_0_48_20'] = ['R1rho', 799777399.1, 118.078, 1648.5, 0.2] data['11_500_46_0'] = [ 'R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.0 ] data['14_500_46_4'] = [ 'R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.04 ] data['12_500_46_10'] = [ 'R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.1 ] data['15_500_46_20'] = [ 'R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.2 ] data['13_500_46_40'] = [ 'R1rho', 799777399.1, 124.24703146206046, 1341.11, 0.4 ] data['50_1000_41_0'] = [ 'R1rho', 799777399.1, 130.41606292412092, 800.5, 0.0 ] data['53_1000_41_4'] = [ 'R1rho', 799777399.1, 130.41606292412092, 800.5, 0.04 ] data['51_1000_41_10'] = [ 'R1rho', 799777399.1, 130.41606292412092, 800.5, 0.1 ] data['54_1000_41_20'] = [ 'R1rho', 799777399.1, 130.41606292412092, 800.5, 0.2 ] data['52_1000_41_40'] = [ 'R1rho', 799777399.1, 130.41606292412092, 800.5, 0.4 ] data['21_1000_46_0'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.0 ] data['24_1000_46_4'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.04 ] data['22_1000_46_10'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.1 ] data['25_1000_46_20'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.2 ] data['23_1000_46_40'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1341.11, 0.4 ] data['65_1000_48_0'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.0 ] data['68_1000_48_4'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.04 ] data['66_1000_48_10'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.1 ] data['67_1000_48_14'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.14 ] data['69_1000_48_20'] = [ 'R1rho', 799777399.1, 130.41606292412092, 1648.5, 0.2 ] data['55_2000_41_0'] = [ 'R1rho', 799777399.1, 142.75412584824184, 800.5, 0.0 ] data['58_2000_41_4'] = [ 'R1rho', 799777399.1, 142.75412584824184, 800.5, 0.04 ] data['56_2000_41_10'] = [ 'R1rho', 799777399.1, 142.75412584824184, 800.5, 0.1 ] data['59_2000_41_20'] = [ 'R1rho', 799777399.1, 142.75412584824184, 800.5, 0.2 ] data['57_2000_41_40'] = [ 'R1rho', 799777399.1, 142.75412584824184, 800.5, 0.4 ] data['6_2000_46_0'] = [ 'R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.0 ] data['9_2000_46_4'] = [ 'R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.04 ] data['7_2000_46_10'] = [ 'R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.1 ] data['10_2000_46_20'] = [ 'R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.2 ] data['8_2000_46_40'] = [ 'R1rho', 799777399.1, 142.75412584824184, 1341.11, 0.4 ] data['16_5000_46_0'] = [ 'R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.0 ] data['19_5000_46_4'] = [ 'R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.04 ] data['17_5000_46_10'] = [ 'R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.1 ] data['20_5000_46_20'] = [ 'R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.2 ] data['18_5000_46_40'] = [ 'R1rho', 799777399.1, 179.76831462060457, 1341.11, 0.4 ] data['26_10000_46_0'] = [ 'R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.0 ] data['29_10000_46_4'] = [ 'R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.04 ] data['27_10000_46_10'] = [ 'R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.1 ] data['30_10000_46_20'] = [ 'R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.2 ] data['28_10000_46_40'] = [ 'R1rho', 799777399.1, 241.45862924120914, 1341.11, 0.4 ] time_comp = { '118.078_431.00': 4, '118.078_651.20': 5, '118.078_800.50': 5, '118.078_984.00': 5, '118.078_1341.11': 5, '118.078_1648.50': 5, '124.247_1341.11': 5, '130.416_800.50': 5, '130.416_1341.11': 5, '130.416_1648.50': 5, '142.754_800.50': 5, '142.754_1341.11': 5, '179.768_1341.11': 5, '241.459_1341.11': 5 } # Check the number of time counts. print("Checking the number of time counts.") for id in cdp.exp_type: exp_type = cdp.exp_type[id] frq = cdp.spectrometer_frq[id] offset = cdp.spin_lock_offset[id] point = cdp.spin_lock_nu1[id] count = count_relax_times(exp_type=exp_type, frq=frq, offset=offset, point=point, ei=cdp.exp_type_list.index( cdp.exp_type[id])) print(id, exp_type, frq, offset, point, count) # Test the time count print(time_comp) self.assertEqual(count, time_comp['%.3f_%.2f' % (offset, point)])