Author: bugman Date: Sun Jan 6 00:22:00 2008 New Revision: 4377 URL: http://svn.gna.org/viewcvs/relax?rev=4377&view=rev Log: Wrote 12 unit tests for using the value setting functions to set the hetero and homonuclei. This is in preparation for replacing the nuclei() user function with the more powerful value.set(). The values also need to now be spin specific. Modified: 1.3/test_suite/unit_tests/value_testing_base.py Modified: 1.3/test_suite/unit_tests/value_testing_base.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/value_testing_base.py?rev=4377&r1=4376&r2=4377&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/value_testing_base.py (original) +++ 1.3/test_suite/unit_tests/value_testing_base.py Sun Jan 6 00:22:00 2008 @@ -2524,6 +2524,46 @@ self.assertEqual(cdp.mol[0].res[1].spin[0].csa, -160e-6) + def test_set_jw_all_spins_heteronuc(self): + """Set the RSDM heteronucleus type for all spins. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'jw'. + relax_data_store.current_pipe = 'jw' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='heteronuc', val='C') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].heteronuc, 'C') + self.assertEqual(cdp.mol[0].res[1].spin[0].heteronuc, 'C') + + + def test_set_jw_all_spins_homonuc(self): + """Set the RSDM homonucleus type for all spins. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'jw'. + relax_data_store.current_pipe = 'jw' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='homonuc', val='H') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].homonuc, 'H') + self.assertEqual(cdp.mol[0].res[1].spin[0].homonuc, 'H') + + def test_set_jw_all_spins_diff_j0_jwx_jwh(self): """Set different RSDM parameters J(0), J(wX), J(wH) for all spins. @@ -2660,6 +2700,46 @@ self.assertAlmostEqual(cdp.mol[0].res[1].spin[0].csa, -172e-6) + def test_set_jw_defaults_heteronuc(self): + """Set the RSDM heteronucleus type to the default value. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'jw'. + relax_data_store.current_pipe = 'jw' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='heteronuc') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].heteronuc, 'N') + self.assertEqual(cdp.mol[0].res[1].spin[0].heteronuc, 'N') + + + def test_set_jw_defaults_homonuc(self): + """Set the RSDM homonucleus type to the default value. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'jw'. + relax_data_store.current_pipe = 'jw' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='homonuc') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].homonuc, 'H') + self.assertEqual(cdp.mol[0].res[1].spin[0].homonuc, 'H') + + def test_set_jw_defaults_j0_jwx_jwh(self): """Set different RSDM parameters J(0), J(wX), J(wH) to the default values (there are none!). @@ -2774,6 +2854,46 @@ # Test the parameter. self.assert_(not hasattr(cdp.mol[0].res[0].spin[0], 'csa')) self.assertEqual(cdp.mol[0].res[1].spin[0].csa, -160e-6) + + + def test_set_jw_single_spin_heteronuc(self): + """Set the RSDM heteronucleus type for a single spin. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'jw'. + relax_data_store.current_pipe = 'jw' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='heteronuc', val='C', spin_id='@112') + + # Test the parameter. + self.assert_(not hasattr(cdp.mol[0].res[0].spin[0], 'heteronuc')) + self.assertEqual(cdp.mol[0].res[1].spin[0].heteronuc, 'C') + + + def test_set_jw_single_spin_homonuc(self): + """Set the RSDM homonucleus type for a single spin. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'jw'. + relax_data_store.current_pipe = 'jw' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='homonuc', val='H', spin_id='@112') + + # Test the parameter. + self.assert_(not hasattr(cdp.mol[0].res[0].spin[0], 'homonuc')) + self.assertEqual(cdp.mol[0].res[1].spin[0].homonuc, 'H') def test_set_jw_single_spin_diff_j0_jwx_jwh(self): @@ -3030,6 +3150,46 @@ self.assertEqual(cdp.mol[0].res[1].spin[0].csa, -172e-6) + def test_set_mf_all_spins_heteronuc(self): + """Set the model-free heteronucleus type for all spins. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'mf'. + relax_data_store.current_pipe = 'mf' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='heteronuc', val='C') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].heteronuc, 'C') + self.assertEqual(cdp.mol[0].res[1].spin[0].heteronuc, 'C') + + + def test_set_mf_all_spins_homonuc(self): + """Set the model-free homonucleus type for all spins. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'mf'. + relax_data_store.current_pipe = 'mf' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='homonuc', val='H') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].homonuc, 'H') + self.assertEqual(cdp.mol[0].res[1].spin[0].homonuc, 'H') + + def test_set_mf_all_spins_diff_s2f_s2s(self): """Set the model-free S2f and S2s parameters for all spins to different values. @@ -3274,6 +3434,46 @@ self.assertEqual(cdp.mol[0].res[1].spin[0].csa, -172 * 1e-6) + def test_set_mf_defaults_heteronuc(self): + """Set the model-free heteronucleus type to the default value. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'mf'. + relax_data_store.current_pipe = 'mf' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='heteronuc') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].heteronuc, 'N') + self.assertEqual(cdp.mol[0].res[1].spin[0].heteronuc, 'N') + + + def test_set_mf_defaults_homonuc(self): + """Set the model-free homonucleus type to the default value. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'mf'. + relax_data_store.current_pipe = 'mf' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='homonuc') + + # Test the parameter. + self.assertEqual(cdp.mol[0].res[0].spin[0].homonuc, 'H') + self.assertEqual(cdp.mol[0].res[1].spin[0].homonuc, 'H') + + def test_set_mf_defaults_s2f_s2s(self): """Set the model-free S2f and S2s parameters to the default values. @@ -3496,6 +3696,46 @@ self.assertEqual(cdp.mol[0].res[1].spin[0].csa, -172e-6) + def test_set_mf_single_spin_heteronuc(self): + """Set the model-free heteronucleus type for a single spin. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'mf'. + relax_data_store.current_pipe = 'mf' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='heteronuc', val='C', spin_id='@112') + + # Test the parameter. + self.assert_(not hasattr(cdp.mol[0].res[0].spin[0], 'heteronuc')) + self.assertEqual(cdp.mol[0].res[1].spin[0].heteronuc, 'C') + + + def test_set_mf_single_spin_homonuc(self): + """Set the model-free homonucleus type for a single spin. + + The functions tested are both generic_fns.value.set() and prompt.value.set(). + """ + + # Set the current data pipe to 'mf'. + relax_data_store.current_pipe = 'mf' + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Set the parameter. + self.value_fns.set(param='homonuc', val='H', spin_id='@112') + + # Test the parameter. + self.assert_(not hasattr(cdp.mol[0].res[0].spin[0], 'homonuc')) + self.assertEqual(cdp.mol[0].res[1].spin[0].homonuc, 'H') + + def test_set_mf_single_spin_diff_s2f_s2s(self): """Set the model-free S2f and S2s parameters for a single spin to different values.