Author: bugman
Date: Wed Aug 27 10:01:54 2014
New Revision: 25324
URL: http://svn.gna.org/viewcvs/relax?rev=25324&view=rev
Log:
Improvements to the pipe_control.minimise.reset_min_stats() function.
The minimise statistics resetting is now more elegantly implemented. And the
sim_index keyword
argument is accepted by the function and individual Monte Carlo simulation
elements can now be
reset.
Modified:
trunk/pipe_control/minimise.py
Modified: trunk/pipe_control/minimise.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/minimise.py?rev=25324&r1=25323&r2=25324&view=diff
==============================================================================
--- trunk/pipe_control/minimise.py (original)
+++ trunk/pipe_control/minimise.py Wed Aug 27 10:01:54 2014
@@ -509,13 +509,13 @@
processor.run_queue()
-def reset_min_stats(data_pipe=None, spin=None):
- """Function for resetting the minimisation statistics.
-
- @keyword data_pipe: The name of the data pipe to reset the minimisation
statisics of. This defaults to the current data pipe.
- @type data_pipe: str
- @keyword spin: The spin data container if spin specific data is to be
reset.
- @type spin: SpinContainer
+def reset_min_stats(data_pipe=None, sim_index=None):
+ """Function for resetting all minimisation statistics.
+
+ @keyword data_pipe: The name of the data pipe to reset the
minimisation statistics of. This defaults to the current data pipe.
+ @type data_pipe: str
+ @keyword sim_index: The optional Monte Carlo simulation index.
+ @type sim_index: int
"""
# The data pipe.
@@ -525,63 +525,54 @@
# Get the data pipe.
dp = pipes.get_pipe(data_pipe)
-
- # Global minimisation statistics.
- #################################
-
- # Chi-squared.
- if hasattr(dp, 'chi2'):
- dp.chi2 = None
-
- # Iteration count.
- if hasattr(dp, 'iter'):
- dp.iter = None
-
- # Function count.
- if hasattr(dp, 'f_count'):
- dp.f_count = None
-
- # Gradient count.
- if hasattr(dp, 'g_count'):
- dp.g_count = None
-
- # Hessian count.
- if hasattr(dp, 'h_count'):
- dp.h_count = None
-
- # Warning.
- if hasattr(dp, 'warning'):
- dp.warning = None
-
-
- # Sequence specific minimisation statistics.
- ############################################
-
- # Loop over all spins.
- for spin in spin_loop():
- # Chi-squared.
- if hasattr(spin, 'chi2'):
- spin.chi2 = None
-
- # Iteration count.
- if hasattr(spin, 'iter'):
- spin.iter = None
-
- # Function count.
- if hasattr(spin, 'f_count'):
- spin.f_count = None
-
- # Gradient count.
- if hasattr(spin, 'g_count'):
- spin.g_count = None
-
- # Hessian count.
- if hasattr(spin, 'h_count'):
- spin.h_count = None
-
- # Warning.
- if hasattr(spin, 'warning'):
- spin.warning = None
+ # The objects to reset to None.
+ names = [
+ 'chi2',
+ 'iter',
+ 'f_count',
+ 'g_count',
+ 'h_count',
+ 'warning'
+ ]
+
+ # Loop over the objects.
+ for name in names:
+ # The simulation name.
+ sim_name = name + '_sim'
+
+ # Global minimisation statistics.
+ if sim_index == None:
+ # Reset the object to None if it exists.
+ if hasattr(dp, name):
+ setattr(dp, name, None)
+
+ # Global MC minimisation statistics.
+ else:
+ if hasattr(dp, sim_name):
+ # The MC simulation object.
+ sim_obj = getattr(dp, sim_name)
+
+ # Reset the object to None if possible.
+ if sim_index < len(sim_obj):
+ sim_obj[sim_index] = None
+
+ # Loop over all spins.
+ for spin in spin_loop(skip_desel=False):
+ # The minimisation statistics.
+ if sim_index == None:
+ # Reset the object to None if it exists.
+ if hasattr(spin, name):
+ setattr(spin, name, None)
+
+ # The MC minimisation statistics.
+ else:
+ if hasattr(spin, sim_name):
+ # The MC simulation object.
+ sim_obj = getattr(spin, sim_name)
+
+ # Reset the object to None if possible.
+ if sim_index < len(sim_obj):
+ sim_obj[sim_index] = None
def set(val=None, error=None, param=None, scaling=None, spin_id=None):
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits