Author: bugman Date: Mon Jan 7 15:58:52 2008 New Revision: 4431 URL: http://svn.gna.org/viewcvs/relax?rev=4431&view=rev Log: Many fixes for the specific_fns.relax_data.find_index() function. This function now fits into the new relax design. Modified: 1.3/specific_fns/relax_data.py Modified: 1.3/specific_fns/relax_data.py URL: http://svn.gna.org/viewcvs/relax/1.3/specific_fns/relax_data.py?rev=4431&r1=4430&r2=4431&view=diff ============================================================================== --- 1.3/specific_fns/relax_data.py (original) +++ 1.3/specific_fns/relax_data.py Mon Jan 7 15:58:52 2008 @@ -480,29 +480,31 @@ self.relax.generic.value.write_data(self.run, (self.ri_label, self.frq_label), sys.stdout, return_value=self.return_value) - def find_index(self, data): - """Function for finding the index corresponding to self.ri_label and self.frq_label.""" + def find_index(self, data, ri_label, frq_label): + """Function for finding the index corresponding to ri_label and frq_label. + + @param data: The class instance containing the ri_label and frq_label variables. + @type data: PipeContainer or SpinContainer + @param ri_label: The relaxation data type, ie 'R1', 'R2', or 'NOE'. + @type ri_label: str + @param frq_label: The field strength label. + @type frq_label: str + @return: The index corresponding to the relaxation data. If there is no + relaxation data corresponding to the labels, None is returned. + @type return: None or int + """ # No data.num_ri data structure. - if self.global_flag == 1: - if not data.num_ri.has_key(self.relax): - return None - else: - if not hasattr(data, 'num_ri'): - return None + if not hasattr(data, 'num_ri'): + return None # Initialise. index = None # Find the index. - if self.global_flag == 1: - for j in xrange(data.num_ri[self.run]): - if self.ri_label == data.ri_labels[self.run][j] and self.frq_label == data.frq_labels[self.run][data.remap_table[self.run][j]]: - index = j - else: - for j in xrange(data.num_ri): - if self.ri_label == data.ri_labels[j] and self.frq_label == data.frq_labels[data.remap_table[j]]: - index = j + for j in xrange(data.num_ri): + if ri_label == data.ri_labels[j] and frq_label == data.frq_labels[data.remap_table[j]]: + index = j # Return the index. return index