Author: bugman Date: Sun Oct 19 15:37:45 2008 New Revision: 7817 URL: http://svn.gna.org/viewcvs/relax?rev=7817&view=rev Log: Alphabetical sorting of all class methods. Modified: branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py Modified: branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py?rev=7817&r1=7816&r2=7817&view=diff ============================================================================== --- branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py (original) +++ branches/multi_processor_merge/specific_fns/model_free/multi_processor_commands.py Sun Oct 19 15:37:45 2008 @@ -169,54 +169,26 @@ self.info_map = {'res_id':None, 'grid_size':1} - #FIXME: bad names - def set_mf(self, **kwargs): - - self.mf_map.update(kwargs) -# FIXME: add to checking class -# self.mf_hash_map = self.get_hash_map(self.mf_map) - -# FIXME: add to checking class -# def get_hash_map(self, map): -# import Numeric -# result = {} -# for key, elem in map.items(): -# #print key, elem, type(elem), dir(type(elem)) -# #if isinstance(elem, Numeric.array): -# # print '*** here 888' -# # elem = tuple(elem.aslist()) -# #elem.__class__.__name__ -# result[key] = (`elem`) -# return result - -# FIXME: add to checking class -# def assert_hash_map_same(self, ref_map, new_map): -# for key in ref_map.keys(): -# if ref_map[key] != new_map[key]: -# print 'bad compare ' + key - - - def set_minimise(self, **kwargs): - if 'res_id' in kwargs: - self.info_map['res_id'] = kwargs['res_id'] - del kwargs['res_id'] - if 'index' in kwargs: - self.info_map['index'] = kwargs['index'] - del kwargs['index'] - if 'grid_size' in kwargs: - self.info_map['grid_size'] = kwargs['grid_size'] - del kwargs['grid_size'] - if 'sim_index' in kwargs: - self.info_map['sim_index'] = kwargs['sim_index'] - del kwargs['sim_index'] - - self.minimise_map.update(kwargs) -# FIXME: add to checking class -# self.mf_minimise_map = self.get_hash_map(self.minimise_map) - - def build_mf(self): return Mf(**self.mf_map) + + + def do_feedback(self): + """Minimisation print out.""" + + # Only print out if verbosity is turned on. + if self.minimise_map['verbosity'] >= 1: + # Monte Carlo simulation print out. + if self.info_map['sim_index'] != None and self.info_map['index'] == 0: + print 'Simulation '+ `self.info_map['sim_index']`+ '\n' + + # Individual spin print out. + if self.mf_map['param_set'] == 'mf' or self.mf_map['param_set'] == 'local_tm': + if self.minimise_map['verbosity'] >= 2: + print "\n\n" + string = "Fitting to spin: " + self.info_map['spin_id'] + print "\n\n" + string + print len(string) * '~' # def do_minimise(self, memo): @@ -235,22 +207,46 @@ # m_f.disassemble_result(param_vector=param_vector, func=func, iter=iter, fc=fc, gc=gc, hc=hc, warning=warning, run=memo.run, index=memo.index, sim_index=memo.sim_index, param_set=memo.param_set, scaling=memo.scaling, scaling_matrix=memo.scaling_matrix) - def do_feedback(self): - """Minimisation print out.""" - - # Only print out if verbosity is turned on. - if self.minimise_map['verbosity'] >= 1: - # Monte Carlo simulation print out. - if self.info_map['sim_index'] != None and self.info_map['index'] == 0: - print 'Simulation '+ `self.info_map['sim_index']`+ '\n' - - # Individual spin print out. - if self.mf_map['param_set'] == 'mf' or self.mf_map['param_set'] == 'local_tm': - if self.minimise_map['verbosity'] >= 2: - print "\n\n" - string = "Fitting to spin: " + self.info_map['spin_id'] - print "\n\n" + string - print len(string) * '~' +# FIXME: add to checking class +# def get_hash_map(self, map): +# import Numeric +# result = {} +# for key, elem in map.items(): +# #print key, elem, type(elem), dir(type(elem)) +# #if isinstance(elem, Numeric.array): +# # print '*** here 888' +# # elem = tuple(elem.aslist()) +# #elem.__class__.__name__ +# result[key] = (`elem`) +# return result + +# FIXME: add to checking class +# def assert_hash_map_same(self, ref_map, new_map): +# for key in ref_map.keys(): +# if ref_map[key] != new_map[key]: +# print 'bad compare ' + key + + + def post_command_feedback(self, results, processor): + pass + + + def post_run(self, processor): + #FIXME: move to processor startup + pass + + + def pre_command_feed_back(self, processor): + self.do_feedback() + + + def pre_run(self, processor): + pass + #FIXME: move to processor startup + + +# def process_result(self, processor): +# self.process_results(self.results, processor, completed) # rename confusing with processor process_results @@ -265,33 +261,6 @@ processor.return_object(MF_result_command(processor, self.memo_id, param_vector, func, iter, fc, gc, hc, warning, completed=False)) processor.return_object(Result_string(processor, result_string, completed=completed)) - - - def pre_command_feed_back(self, processor): - self.do_feedback() - - - def pre_run(self, processor): - pass - #FIXME: move to processor startup - - - def post_run(self, processor): - #FIXME: move to processor startup - pass - - - def post_command_feedback(self, results, processor): - pass - - - def run_command(self, processor): - self.mf = self.build_mf() - return generic_minimise(func=self.mf.func, dfunc=self.mf.dfunc, d2func=self.mf.d2func, **self.minimise_map) - - -# def process_result(self, processor): -# self.process_results(self.results, processor, completed) def run(self, processor, completed): @@ -323,13 +292,45 @@ # sys.stderr = save_stderr + def run_command(self, processor): + self.mf = self.build_mf() + return generic_minimise(func=self.mf.func, dfunc=self.mf.dfunc, d2func=self.mf.d2func, **self.minimise_map) + + + #FIXME: bad names + def set_mf(self, **kwargs): + self.mf_map.update(kwargs) +# FIXME: add to checking class +# self.mf_hash_map = self.get_hash_map(self.mf_map) + + + def set_minimise(self, **kwargs): + if 'res_id' in kwargs: + self.info_map['res_id'] = kwargs['res_id'] + del kwargs['res_id'] + if 'index' in kwargs: + self.info_map['index'] = kwargs['index'] + del kwargs['index'] + if 'grid_size' in kwargs: + self.info_map['grid_size'] = kwargs['grid_size'] + del kwargs['grid_size'] + if 'sim_index' in kwargs: + self.info_map['sim_index'] = kwargs['sim_index'] + del kwargs['sim_index'] + + self.minimise_map.update(kwargs) +# FIXME: add to checking class +# self.mf_minimise_map = self.get_hash_map(self.minimise_map) + + class MF_grid_command(MF_minimise_command): def __init__(self): super(MF_grid_command, self).__init__() -# def run(self, processor, completed): -# pass + def post_command_feedback(self, results, processor): + set_generic_pre_and_post_amble(True) + set_grid_pre_and_post_amble(True) def pre_command_feed_back(self, processor): @@ -361,15 +362,6 @@ # print print_prefix + "b: " + `b` - #def run_command() - # return super(MF_grid_command, self).run(processor, completed) - - - def post_command_feedback(self, results, processor): - set_generic_pre_and_post_amble(True) - set_grid_pre_and_post_amble(True) - - def process_results(self, results, processor, completed): param_vector, func, iter, fc, gc, hc, warning = results @@ -379,6 +371,14 @@ stderr.truncate(0) processor.return_object(MF_grid_result_command(processor, result_string, self.memo_id, param_vector, func, iter, fc, gc, hc, warning, completed=completed)) + + +# def run(self, processor, completed): +# pass + + + #def run_command() + # return super(MF_grid_command, self).run(processor, completed) class MF_result_command(Result_command): @@ -427,10 +427,6 @@ self.h_count = 0 self.warning = [] self.first_time = None - - - def add_sub_memo(self, memo): - self.sub_memos.append(memo) def add_result(self, sub_memo, results): @@ -474,3 +470,7 @@ if self.first_time == None: self.first_time = True #print '****', self.xk, self.fk, self.k, self.f_count, self.g_count, self.h_count, self.warning + + + def add_sub_memo(self, memo): + self.sub_memos.append(memo)