Author: bugman Date: Fri May 3 20:27:35 2013 New Revision: 19656 URL: http://svn.gna.org/viewcvs/relax?rev=19656&view=rev Log: Merged revisions 19650-19655 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r19650 | bugman | 2013-05-03 19:36:30 +0200 (Fri, 03 May 2013) | 3 lines Modified the Value.test_value_copy system test to check the copying of errors as well. ........ r19651 | bugman | 2013-05-03 19:49:43 +0200 (Fri, 03 May 2013) | 5 lines Added the error flag argument to all of the specific analysis API set_param_values() methods. This will allow parameter errors as well as values to be set. ........ r19652 | bugman | 2013-05-03 19:54:55 +0200 (Fri, 03 May 2013) | 3 lines The Value.test_value_copy system test now checks all of the values and errors. ........ r19653 | bugman | 2013-05-03 20:08:55 +0200 (Fri, 03 May 2013) | 5 lines Added the error flag argument to the value.set user function. This will allow for parameter errors to be set by the user. ........ r19654 | bugman | 2013-05-03 20:10:28 +0200 (Fri, 03 May 2013) | 5 lines Bug fix for the value.copy user function. The user function can now handle parameter errors, and the values are set in the correct data pipe. ........ r19655 | bugman | 2013-05-03 20:11:07 +0200 (Fri, 03 May 2013) | 3 lines The specific analysis API _return_value_general() method now returns errors even when values are missing. ........ Modified: branches/relax_disp/ (props changed) branches/relax_disp/pipe_control/value.py branches/relax_disp/specific_analyses/api_base.py branches/relax_disp/specific_analyses/api_common.py branches/relax_disp/specific_analyses/model_free/main.py branches/relax_disp/specific_analyses/n_state_model.py branches/relax_disp/test_suite/system_tests/value.py branches/relax_disp/user_functions/value.py Propchange: branches/relax_disp/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri May 3 20:27:35 2013 @@ -1,1 +1,1 @@ -/trunk:1-19648 +/trunk:1-19655 Modified: branches/relax_disp/pipe_control/value.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/value.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/pipe_control/value.py (original) +++ branches/relax_disp/pipe_control/value.py Fri May 3 20:27:35 2013 @@ -53,6 +53,7 @@ pipe_from = pipes.cdp_name() if pipe_to == None: pipe_to = pipes.cdp_name() + pipe_orig = pipes.cdp_name() # The second pipe does not exist. pipes.test(pipe_to) @@ -77,16 +78,25 @@ if value != None or error != None: raise RelaxValueError(param, pipe_to) + # Switch to the data pipe to copy values to. + pipes.switch(pipe_to) + # Copy the values. for spin, spin_id in spin_loop(pipe=pipe_from, return_id=True): # Get the value and error from pipe_from. value, error = return_value(spin, param) # Set the values of pipe_to. - set(spin_id=spin_id, val=value, error=error, param=param) + if value != None: + set(spin_id=spin_id, val=value, param=param, pipe=pipe_to) + if error != None: + set(spin_id=spin_id, val=error, param=param, pipe=pipe_to, error=True) # Reset all minimisation statistics. minimise.reset_min_stats(pipe_to) + + # Switch back to the original current data pipe. + pipes.switch(pipe_orig) def display(param=None, scaling=1.0): @@ -343,19 +353,19 @@ minimise.reset_min_stats() -def set(val=None, param=None, error=None, pipe=None, spin_id=None, force=True, reset=True): +def set(val=None, param=None, pipe=None, spin_id=None, error=False, force=True, reset=True): """Set global or spin specific data values. @keyword val: The parameter values. @type val: None or list @keyword param: The parameter names. @type param: None, str, or list of str - @keyword error: The parameter errors. - @type error: None, number, or list of numbers @keyword pipe: The data pipe the values should be placed in. @type pipe: None or str @keyword spin_id: The spin identification string. @type spin_id: str + @keyword error: A flag which if True will allow the parameter errors to be set instead of the values. + @type error: bool @keyword force: A flag forcing the overwriting of current values. @type force: bool @keyword reset: A flag which if True will cause all minimisation statistics to be reset. @@ -414,7 +424,7 @@ raise RelaxParamSetError(param[i]) # Set the parameter values. - set_param_values(param=param, value=val, spin_id=spin_id, force=force) + set_param_values(param=param, value=val, spin_id=spin_id, error=error, force=force) # Reset all minimisation statistics. if reset: Modified: branches/relax_disp/specific_analyses/api_base.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/api_base.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/api_base.py (original) +++ branches/relax_disp/specific_analyses/api_base.py Fri May 3 20:27:35 2013 @@ -655,7 +655,7 @@ raise RelaxImplementError('set_error') - def set_param_values(self, param=None, value=None, spin_id=None, force=True): + def set_param_values(self, param=None, value=None, spin_id=None, error=False, force=True): """Set the model parameter values. @keyword param: The parameter name list. @@ -664,6 +664,8 @@ @type value: list @keyword spin_id: The spin identification string, only used for spin specific parameters. @type spin_id: None or str + @keyword error: A flag which if True will allow the parameter errors to be set instead of the values. + @type error: bool @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. @type force: bool """ Modified: branches/relax_disp/specific_analyses/api_common.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/api_common.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/api_common.py (original) +++ branches/relax_disp/specific_analyses/api_common.py Fri May 3 20:27:35 2013 @@ -364,9 +364,9 @@ if hasattr(spin, object_name): value = getattr(spin, object_name) - # The error. - if hasattr(spin, object_error): - error = getattr(spin, object_error) + # The spin error. + if hasattr(spin, object_error): + error = getattr(spin, object_error) # The global value. elif hasattr(cdp, object_name): @@ -435,7 +435,7 @@ inc = inc + 1 - def _set_param_values_global(self, param=None, value=None, spin_id=None, force=True): + def _set_param_values_global(self, param=None, value=None, spin_id=None, error=False, force=True): """Set the global parameter values in the top layer of the data pipe. @keyword param: The parameter name list. @@ -444,6 +444,8 @@ @type value: list @keyword spin_id: The spin identification string (unused). @type spin_id: None + @keyword error: A flag which if True will allow the parameter errors to be set instead of the values. + @type error: bool @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. @type force: bool """ @@ -461,6 +463,10 @@ if not obj_name: raise RelaxError("The parameter '%s' is not valid for this data pipe type." % param[i]) + # Error object. + if error: + obj_name += '_err' + # Is the parameter already set. if not force and hasattr(cdp, obj_name) and getattr(cdp, obj_name) != None: raise RelaxError("The parameter '%s' already exists, set the force flag to True to overwrite." % param[i]) @@ -469,7 +475,7 @@ setattr(cdp, obj_name, value[i]) - def _set_param_values_spin(self, param=None, value=None, spin_id=None, force=True): + def _set_param_values_spin(self, param=None, value=None, spin_id=None, error=False, force=True): """Set the spin specific parameter values. @keyword param: The parameter name list. @@ -478,6 +484,8 @@ @type value: list @keyword spin_id: The spin identification string, only used for spin specific parameters. @type spin_id: None or str + @keyword error: A flag which if True will allow the parameter errors to be set instead of the values. + @type error: bool @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. @type force: bool """ @@ -498,8 +506,13 @@ if not spin.select: continue + # The object name. + obj_name = param[i] + if error: + obj_name += '_err' + # Set the parameter. - setattr(spin, param[i], value[i]) + setattr(spin, obj_name, value[i]) def _set_selected_sim_global(self, model_info, select_sim): Modified: branches/relax_disp/specific_analyses/model_free/main.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/model_free/main.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/model_free/main.py (original) +++ branches/relax_disp/specific_analyses/model_free/main.py Fri May 3 20:27:35 2013 @@ -2207,7 +2207,7 @@ inc = inc + 1 - def set_param_values(self, param=None, value=None, spin_id=None, force=True): + def set_param_values(self, param=None, value=None, spin_id=None, error=False, force=True): """Set the model-free parameter values. @keyword param: The parameter name list. @@ -2216,6 +2216,8 @@ @type value: list @keyword spin_id: The spin identification string, only used for spin specific parameters. @type spin_id: None or str + @keyword error: A flag which if True will allow the parameter errors to be set instead of the values. + @type error: bool @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. @type force: bool """ @@ -2232,7 +2234,10 @@ # Diffusion tensor parameter. diff_obj = diffusion_tensor.return_data_name(param[i]) if diff_obj: - diff_params.append(param[i]) + if error: + diff_params.append(param[i] + '_err') + else: + diff_params.append(param[i]) diff_vals.append(value[i]) # Model-free parameter. @@ -2252,6 +2257,10 @@ # Check if it is a model-free parameter. if obj_name not in self.data_names(set='params', scope='spin') and obj_name not in self.data_names(set='generic', scope='spin'): raise RelaxError("The parameter '%s' is unknown. It should be one of %s or %s" % (mf_params[i], self.data_names(set='params', scope='spin'), self.data_names(set='generic', scope='spin'))) + + # The error object name. + if error: + obj_name += '_err' # Set the parameter. for spin in spin_loop(spin_id): Modified: branches/relax_disp/specific_analyses/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/n_state_model.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/n_state_model.py (original) +++ branches/relax_disp/specific_analyses/n_state_model.py Fri May 3 20:27:35 2013 @@ -2596,7 +2596,7 @@ return getattr(tensor, names[param_index]+'_err') - def set_param_values(self, param=None, value=None, spin_id=None, force=True): + def set_param_values(self, param=None, value=None, spin_id=None, error=False, force=True): """Set the N-state model parameter values. @keyword param: The parameter name list. @@ -2605,6 +2605,8 @@ @type value: list @keyword spin_id: The spin identification string (unused). @type spin_id: None + @keyword error: A flag which if True will allow the parameter errors to be set instead of the values. + @type error: bool @keyword force: A flag which if True will cause current values to be overwritten. If False, a RelaxError will raised if the parameter value is already set. @type force: bool """ @@ -2621,6 +2623,10 @@ # Is the parameter is valid? if not obj_name: raise RelaxError("The parameter '%s' is not valid for this data pipe type." % param[i]) + + # Error object. + if error: + obj_name += '_err' # Set the indexed parameter. if obj_name in ['probs', 'alpha', 'beta', 'gamma']: Modified: branches/relax_disp/test_suite/system_tests/value.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/test_suite/system_tests/value.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/test_suite/system_tests/value.py (original) +++ branches/relax_disp/test_suite/system_tests/value.py Fri May 3 20:27:35 2013 @@ -45,8 +45,11 @@ self.interpreter.spin.create(mol_name='test mol', res_name='Gly', res_num=2, spin_name='N') self.interpreter.spin.create(mol_name='test mol', res_name='Gly', res_num=3, spin_name='N') - # Add some values. + # Add some values and errors. self.interpreter.value.set(val=0.8, param='s2', spin_id=':1,2') + self.interpreter.value.set(val=0.1, param='s2', spin_id=':1', error=True) + self.interpreter.value.set(val=0.2, param='s2', spin_id=':2', error=True) + self.interpreter.value.set(val=0.3, param='s2', spin_id=':3', error=True) # Create a new data pipe. self.interpreter.pipe.create('new', 'mf') @@ -54,3 +57,18 @@ # Copy the sequence data and value. self.interpreter.sequence.copy(pipe_from='orig', pipe_to='new') self.interpreter.value.copy(pipe_from='orig', pipe_to='new', param='s2') + + # Loop over both the new and old pipes to check the data. + for pipe in ['orig', 'new']: + # Printout. + print("Checking the values of the '%s' data pipe." % pipe) + + # Check the values. + self.assertEqual(ds[pipe].mol[0].res[0].spin[0].s2, 0.8) + self.assertEqual(ds[pipe].mol[0].res[1].spin[0].s2, 0.8) + self.assert_(not hasattr(ds[pipe].mol[0].res[2].spin[0], 's2')) + + # Check the errors. + self.assertEqual(ds[pipe].mol[0].res[0].spin[0].s2_err, 0.1) + self.assertEqual(ds[pipe].mol[0].res[1].spin[0].s2_err, 0.2) + self.assertEqual(ds[pipe].mol[0].res[2].spin[0].s2_err, 0.3) Modified: branches/relax_disp/user_functions/value.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/value.py?rev=19656&r1=19655&r2=19656&view=diff ============================================================================== --- branches/relax_disp/user_functions/value.py (original) +++ branches/relax_disp/user_functions/value.py Fri May 3 20:27:35 2013 @@ -330,6 +330,13 @@ desc_short = "spin ID to restrict value setting to", desc = "The spin ID string to restrict value setting to.", can_be_none = True +) +uf.add_keyarg( + name = "error", + default = False, + py_type = "bool", + desc_short = "error flag", + desc = "A flag which if True will cause the error rather than parameter to be set." ) # Description. uf.desc.append(Desc_container())