Author: bugman Date: Wed Mar 4 14:48:39 2015 New Revision: 27775 URL: http://svn.gna.org/viewcvs/relax?rev=27775&view=rev Log: Merged revisions 27771-27774 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r27771 | bugman | 2015-03-04 14:28:46 +0100 (Wed, 04 Mar 2015) | 6 lines Created the Align_tensor.test_copy_pipes system test. This is to show a problem in the align_tensor.copy user function when copying all tensors between data pipes. ........ r27772 | bugman | 2015-03-04 14:30:30 +0100 (Wed, 04 Mar 2015) | 5 lines The align_tensor.copy user function 'tensor_from' argument can now be None. This is to enable the copying of all alignment tensors from one data pipe to another. ........ r27773 | bugman | 2015-03-04 14:34:07 +0100 (Wed, 04 Mar 2015) | 5 lines Modified the pipe_control.align_tensor.align_data_exists() function to handle no tensor IDs. If no tensor ID is supplied, this will then return True if any alignment data exists. ........ r27774 | bugman | 2015-03-04 14:47:21 +0100 (Wed, 04 Mar 2015) | 6 lines Improvement for the align_tensor.copy user function. The user function has been modified to allow all alignment tensors to be copied between two data pipes. This allows the Align_tensor.test_copy_pipes system test to pass. ........ Modified: branches/frame_order_cleanup/ (props changed) branches/frame_order_cleanup/pipe_control/align_tensor.py branches/frame_order_cleanup/test_suite/system_tests/align_tensor.py branches/frame_order_cleanup/user_functions/align_tensor.py Propchange: branches/frame_order_cleanup/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Wed Mar 4 14:48:39 2015 @@ -1 +1 @@ -/trunk:1-27769 +/trunk:1-27774 Modified: branches/frame_order_cleanup/pipe_control/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/pipe_control/align_tensor.py?rev=27775&r1=27774&r2=27775&view=diff ============================================================================== --- branches/frame_order_cleanup/pipe_control/align_tensor.py (original) +++ branches/frame_order_cleanup/pipe_control/align_tensor.py Wed Mar 4 14:48:39 2015 @@ -44,15 +44,15 @@ from pipe_control.pipes import check_pipe -def align_data_exists(tensor, pipe=None): +def align_data_exists(tensor=None, pipe=None): """Function for determining if alignment data exists in the current data pipe. - @param tensor: The alignment tensor identification string. - @type tensor: str - @param pipe: The data pipe to search for data in. - @type pipe: str - @return: The answer to the question. - @rtype: bool + @keyword tensor: The alignment tensor ID string. If not supplied, then any alignment data will result in the function returning True. + @type tensor: str or None + @keyword pipe: The data pipe to search for data in. This defaults to the current data pipe if not supplied. + @type pipe: str or None + @return: The answer to the question. + @rtype: bool """ # The data pipe to check. @@ -64,6 +64,8 @@ # Test if an alignment tensor corresponding to the arg 'tensor' exists. if hasattr(pipe, 'align_tensors'): + if tensor == None: + return True for data in pipe.align_tensors: if data.name == tensor: return True @@ -134,29 +136,49 @@ dp_to.align_tensors = AlignTensorList() # Add the tensor if it doesn't already exist. - if tensor_to not in dp_to.align_tensors.names(): + if tensor_to != None and tensor_to not in dp_to.align_tensors.names(): dp_to.align_tensors.add_item(tensor_to) - # Find the tensor index. - index_from = get_tensor_index(tensor=tensor_from, pipe=pipe_from) - index_to = get_tensor_index(tensor=tensor_to, pipe=pipe_to) - - # Copy the data. - if index_to == None: - dp_to.align_tensors.append(deepcopy(dp_from.align_tensors[index_from])) - index_to = len(dp_to.align_tensors) - 1 + # Copy all data. + if tensor_from == None: + # Check. + if tensor_to != tensor_from: + raise RelaxError("The tensor_to argument '%s' should not be supplied when tensor_from is None." % tensor_to) + + # The align IDs. + align_ids = [] + + # Loop over and copy all tensors. + for i in range(len(dp_from.align_tensors)): + dp_to.align_tensors.append(deepcopy(dp_from.align_tensors[i])) + align_ids.append(dp_from.align_tensors[i].align_id) + + # Copy a single tensor. else: - dp_to.align_tensors[index_to] = deepcopy(dp_from.align_tensors[index_from]) - - # Update the tensor's name. - dp_to.align_tensors[index_to].set('name', tensor_to) - - # Add the align ID to the target data pipe if needed. - align_id = dp_from.align_tensors[index_from].align_id + # Find the tensor index. + index_from = get_tensor_index(tensor=tensor_from, pipe=pipe_from) + index_to = get_tensor_index(tensor=tensor_to, pipe=pipe_to) + + # Copy the tensor. + tensor = deepcopy(dp_from.align_tensors[index_from]) + if index_to == None: + dp_to.align_tensors.append(tensor) + index_to = len(dp_to.align_tensors) - 1 + else: + dp_to.align_tensors[index_to] = tensor + + # Update the tensor's name. + dp_to.align_tensors[index_to].set('name', tensor_to) + + # The align IDs. + align_ids = [dp_from.align_tensors[index_from].align_id] + + # Add the align IDs to the target data pipe if needed. if not hasattr(dp_to, 'align_ids'): dp_to.align_ids = [] - if align_id not in dp_to.align_ids: - dp_to.align_ids.append(align_id) + for align_id in align_ids: + if align_id not in dp_to.align_ids: + dp_to.align_ids.append(align_id) def delete(tensor=None): Modified: branches/frame_order_cleanup/test_suite/system_tests/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/system_tests/align_tensor.py?rev=27775&r1=27774&r2=27775&view=diff ============================================================================== --- branches/frame_order_cleanup/test_suite/system_tests/align_tensor.py (original) +++ branches/frame_order_cleanup/test_suite/system_tests/align_tensor.py Wed Mar 4 14:48:39 2015 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2013 Edward d'Auvergne # +# Copyright (C) 2006-2015 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -288,6 +288,28 @@ self.assertEqual(cdp.align_tensors[1].name, 'new') + def test_copy_pipes(self): + """Test the copying of alignment tensors between data pipes.""" + + # First reset. + self.interpreter.reset() + + # Create two data pipes. + self.interpreter.pipe.create('target', 'N-state') + self.interpreter.pipe.create('source', 'N-state') + + # Initialise one tensor. + self.interpreter.align_tensor.init(tensor='orig', align_id='test', params=self.tensors_full[0], param_types=0) + + # Copy the tensor. + self.interpreter.align_tensor.copy(pipe_from='source', pipe_to='target') + + # Checks. + self.interpreter.pipe.switch('target') + self.assertEqual(len(cdp.align_tensors), 1) + self.assertEqual(cdp.align_tensors[0].name, 'orig') + + def test_fix(self): """Test the align_tensor.fix user function.""" Modified: branches/frame_order_cleanup/user_functions/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/user_functions/align_tensor.py?rev=27775&r1=27774&r2=27775&view=diff ============================================================================== --- branches/frame_order_cleanup/user_functions/align_tensor.py (original) +++ branches/frame_order_cleanup/user_functions/align_tensor.py Wed Mar 4 14:48:39 2015 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2007-2014 Edward d'Auvergne # +# Copyright (C) 2007-2015 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -45,7 +45,8 @@ default = None, py_type = "str", desc_short = "source tensor ID", - desc = "The identification string of the alignment tensor to copy the data from." + desc = "The identification string of the alignment tensor to copy the data from.", + can_be_none = True ) uf.add_keyarg( name = "pipe_from",