mailr16674 - in /branches/uf_redesign: ./ generic_fns/ test_suite/system_tests/ test_suite/system_tests/scripts/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 05, 2012 - 18:08:
Author: bugman
Date: Tue Jun  5 18:08:58 2012
New Revision: 16674

URL: http://svn.gna.org/viewcvs/relax?rev=16674&view=rev
Log:
Merged revisions 16672-16673 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3

........
  r16672 | bugman | 2012-06-05 17:52:56 +0200 (Tue, 05 Jun 2012) | 3 lines
  
  Created a system test for catching bug #19785 (https://gna.org/bugs/?19785).
........
  r16673 | bugman | 2012-06-05 18:04:02 +0200 (Tue, 05 Jun 2012) | 11 lines
  
  The relax_data.delete user function is now finally properly implemented!
  
  This was reported by Martin Ballaschk <ballaschk att fmp-berlin dott de> as 
bug #19785
  (https://gna.org/bugs/?19785), and the mail message at
  http://www.mail-archive.com/relax-users@xxxxxxx/msg01183.html (Message-Id:
  <EED32F2B-B78F-4D23-9E0B-3DDE8B661F48@xxxxxxxxxxxxx>).
  
  The problem was that this was not being checked by the test suite, and no 
one had tried to delete
  relaxation data before (well, at least it was never reported).
........

Added:
    
branches/uf_redesign/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py
      - copied unchanged from r16673, 
1.3/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py
Modified:
    branches/uf_redesign/   (props changed)
    branches/uf_redesign/generic_fns/relax_data.py
    branches/uf_redesign/test_suite/system_tests/relax_data.py

Propchange: branches/uf_redesign/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun  5 18:08:58 2012
@@ -1,1 +1,1 @@
-/1.3:1-16669
+/1.3:1-16673

Modified: branches/uf_redesign/generic_fns/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/generic_fns/relax_data.py?rev=16674&r1=16673&r2=16674&view=diff
==============================================================================
--- branches/uf_redesign/generic_fns/relax_data.py (original)
+++ branches/uf_redesign/generic_fns/relax_data.py Tue Jun  5 18:08:58 2012
@@ -478,15 +478,40 @@
     if not exists_mol_res_spin_data():
         raise RelaxNoSequenceError
 
+    # Check the ID.
+    if ri_id == None:
+        raise RelaxError("The relaxation data ID string must be supplied.")
+
     # Test if data exists.
     if not hasattr(cdp, 'ri_ids') or ri_id not in cdp.ri_ids:
         raise RelaxNoRiError(ri_id)
 
-    # Loop over the spins.
+    # Pop the ID, and remove it from the frequency and type lists.
+    cdp.ri_ids.pop(cdp.ri_ids.index(ri_id))
+    del cdp.frq[ri_id]
+    del cdp.ri_type[ri_id]
+
+    # Prune empty structures.
+    if len(cdp.ri_ids) == 0:
+        del cdp.ri_ids
+    if len(cdp.frq) == 0:
+        del cdp.frq
+    if len(cdp.ri_type) == 0:
+        del cdp.ri_type
+
+    # Loop over the spins, deleting the relaxation data and errors when 
present.
     for spin in spin_loop():
-        # Relaxation data and errors.
-        del spin.ri_data[ri_id]
-        del spin.ri_data_err[ri_id]
+        # Data deletion.
+        if hasattr(spin, 'ri_data') and spin.ri_data.has_key(ri_id):
+            del spin.ri_data[ri_id]
+        if hasattr(spin, 'ri_data_err') and spin.ri_data_err.has_key(ri_id):
+            del spin.ri_data_err[ri_id]
+
+        # Prune empty structures.
+        if hasattr(spin, 'ri_data') and len(spin.ri_data) == 0:
+            del spin.ri_data
+        if hasattr(spin, 'ri_data_err') and len(spin.ri_data_err) == 0:
+            del spin.ri_data_err
 
 
 def display(ri_id=None):

Modified: branches/uf_redesign/test_suite/system_tests/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/test_suite/system_tests/relax_data.py?rev=16674&r1=16673&r2=16674&view=diff
==============================================================================
--- branches/uf_redesign/test_suite/system_tests/relax_data.py (original)
+++ branches/uf_redesign/test_suite/system_tests/relax_data.py Tue Jun  5 
18:08:58 2012
@@ -25,7 +25,6 @@
 
 # relax module imports.
 from base_classes import SystemTestCase
-from data import Relax_data_store; ds = Relax_data_store()
 from generic_fns.mol_res_spin import spin_loop
 from status import Status; status = Status()
 
@@ -100,3 +99,32 @@
 
             # Increment.
             index += 1
+
+
+    def test_delete(self):
+        """Test the relax_data.delete user function, replicating bug 
#19785."""
+
+        # Execute the script.
+        self.interpreter.run(script_file=status.install_path + 
sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'bug_19785_relax_data_delete.py')
+
+        # Switch to the first pipe.
+        self.interpreter.pipe.switch('delete 1')
+
+        # Checks.
+        self.assertEqual(cdp.ri_ids, ['R1_900', 'NOE_900', 'R1_500', 
'R2_500', 'NOE_500'])
+        self.assert_(not cdp.frq.has_key('R2_900'))
+        self.assert_(not cdp.ri_type.has_key('R2_900'))
+        for spin in spin_loop():
+            self.assert_(not spin.ri_data.has_key('R2_900'))
+            self.assert_(not spin.ri_data_err.has_key('R2_900'))
+
+        # Switch to the second pipe.
+        self.interpreter.pipe.switch('delete 2')
+
+        # Checks.
+        self.assert_(not hasattr(cdp, 'ri_ids'))
+        self.assert_(not hasattr(cdp, 'frq'))
+        self.assert_(not hasattr(cdp, 'ri_type'))
+        for spin in spin_loop():
+            self.assert_(not hasattr(spin, 'ri_data'))
+            self.assert_(not hasattr(spin, 'ri_data_err'))




Related Messages


Powered by MHonArc, Updated Tue Jun 05 18:20:02 2012