mailr17838 - in /branches/frame_order_testing: ./ generic_fns/ opendx/ test_suite/ test_suite/unit_tests/_generic_fns/


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

Header


Content

Posted by edward on October 16, 2012 - 10:52:
Author: bugman
Date: Tue Oct 16 10:52:10 2012
New Revision: 17838

URL: http://svn.gna.org/viewcvs/relax?rev=17838&view=rev
Log:
Merged revisions 17651-17660 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r17651 | bugman | 2012-10-02 10:52:35 +0200 (Tue, 02 Oct 2012) | 5 lines
  
  Created the check_types.is_unicode() function for Python 2+3 compatibility.
  
  This is used in the generic_fns.mol_res_spin module.
........
  r17652 | bugman | 2012-10-02 10:53:34 +0200 (Tue, 02 Oct 2012) | 3 lines
  
  More usage of the is_unicode() function in the generic_fns.mol_res_spin 
module.
........
  r17653 | bugman | 2012-10-02 10:54:58 +0200 (Tue, 02 Oct 2012) | 3 lines
  
  Import fix for the OpenDX mapping package, recently broken with the 
relative import for Python 3 change.
........
  r17654 | bugman | 2012-10-02 11:04:51 +0200 (Tue, 02 Oct 2012) | 3 lines
  
  The compat module now has the py_version variable specifying if this is 
Python 2 or 3.
........
  r17655 | bugman | 2012-10-02 11:39:17 +0200 (Tue, 02 Oct 2012) | 7 lines
  
  For running relax with Python 2, the __builtin__.range() function has been 
replaced with xrange.
  
  This causes large speed ups (speed that was lost with the earlier xrange() 
to range() conversions),
  and memory decreases.  For example on one system, the system test time 
decreased from 513.029s to
  487.586s.
........
  r17656 | bugman | 2012-10-02 11:47:15 +0200 (Tue, 02 Oct 2012) | 6 lines
  
  Automatically converted the generic_fns.mol_res_spin module to support both 
Python 2 and 3.
  
  The command used was:
  2to3 -w generic_fns/mol_res_spin.py
........
  r17657 | bugman | 2012-10-02 11:53:17 +0200 (Tue, 02 Oct 2012) | 5 lines
  
  Python 3 fix for the generic_fns.mol_res_spin.parse_token() function.
  
  Mixed lists for int and string can no longer be sorted.  This sort call is 
not needed anyway.
........
  r17658 | bugman | 2012-10-02 13:35:59 +0200 (Tue, 02 Oct 2012) | 3 lines
  
  Fix for the test_parse_token_multi_element_name() unit test, as 
parse_token() no longer sorts.
........
  r17659 | bugman | 2012-10-02 14:05:17 +0200 (Tue, 02 Oct 2012) | 6 lines
  
  Fix for the running of the test suite under Python 3.
  
  The zip() function used in the loadTestsFromTestCase() function is now an 
iterator, so it needs to
  be passed through the list() function to generate a list.
........
  r17660 | bugman | 2012-10-02 14:05:50 +0200 (Tue, 02 Oct 2012) | 3 lines
  
  Copyright update.
........

Modified:
    branches/frame_order_testing/   (props changed)
    branches/frame_order_testing/check_types.py
    branches/frame_order_testing/compat.py
    branches/frame_order_testing/generic_fns/mol_res_spin.py
    branches/frame_order_testing/opendx/main.py
    branches/frame_order_testing/test_suite/relax_test_loader.py
    
branches/frame_order_testing/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py

Propchange: branches/frame_order_testing/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Oct 16 10:52:10 2012
@@ -1,1 +1,1 @@
-/trunk:1-17274,17295-17359,17361-17365,17367-17376,17378-17389,17391-17538,17540,17542,17552-17650
+/trunk:1-17274,17295-17359,17361-17365,17367-17376,17378-17389,17391-17538,17540,17542,17552-17660

Modified: branches/frame_order_testing/check_types.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/check_types.py?rev=17838&r1=17837&r2=17838&view=diff
==============================================================================
--- branches/frame_order_testing/check_types.py (original)
+++ branches/frame_order_testing/check_types.py Tue Oct 16 10:52:10 2012
@@ -47,3 +47,16 @@
     # Old style check.
     else:
         return isinstance(obj, file)
+
+
+def is_unicode(obj):
+    """Check if the given Python object is a unicode string.
+
+    @param obj:     The Python object.
+    @type obj:      anything
+    @return:        True if the object is a unicode string, False otherwise.
+    @rtype:         bool
+    """
+
+    # Check using the unicode type (set in the compat module for Python 3).
+    return isinstance(obj, unicode)

Modified: branches/frame_order_testing/compat.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/compat.py?rev=17838&r1=17837&r2=17838&view=diff
==============================================================================
--- branches/frame_order_testing/compat.py (original)
+++ branches/frame_order_testing/compat.py Tue Oct 16 10:52:10 2012
@@ -25,8 +25,21 @@
 # Python module imports.
 import sys
 
+# The Python version.
+py_version = sys.version_info[0]
+
+# Python 2 hacks.
+if py_version == 2:
+    # Python 2 only imports.
+    import __builtin__
+
+    # Switch all range() calls to xrange() for increased speed and memory 
reduction.
+    # This should work as all range() usage for Python 3 in relax must match 
the old xrange() usage.
+    __builtin__.range = __builtin__.xrange
+
+
 # Python 3 work-arounds.
-if sys.version_info[0] == 3:
+if py_version == 3:
     # Python 3 only imports.
     import builtins
 

Modified: branches/frame_order_testing/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/mol_res_spin.py?rev=17838&r1=17837&r2=17838&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/mol_res_spin.py (original)
+++ branches/frame_order_testing/generic_fns/mol_res_spin.py Tue Oct 16 
10:52:10 2012
@@ -42,6 +42,7 @@
 from warnings import warn
 
 # relax module imports.
+from check_types import is_unicode
 from data.mol_res_spin import MoleculeContainer, ResidueContainer, 
SpinContainer
 from generic_fns import exp_info, pipes, relax_re
 from relax_errors import RelaxError, RelaxNoSpinError, RelaxMultiMolIDError, 
RelaxMultiResIDError, RelaxMultiSpinIDError, RelaxResSelectDisallowError, 
RelaxSpinSelectDisallowError
@@ -80,7 +81,7 @@
         """
 
         # Handle Unicode.
-        if isinstance(select_string, unicode):
+        if is_unicode(select_string):
             select_string = str(select_string)
 
         self._union = None
@@ -1973,7 +1974,7 @@
                         spin._spin_ids.pop(spin._spin_ids.index(spin_id))
 
                     # Remove the IDs from the look up table.
-                    if dp.mol._spin_id_lookup.has_key(spin_id):
+                    if spin_id in dp.mol._spin_id_lookup:
                         dp.mol._spin_id_lookup.pop(spin_id)
 
 
@@ -2451,9 +2452,6 @@
                 # Append the element.
                 id_list.append(element)
 
-    # Sort the list.
-    id_list.sort()
-
     # Return the identifying list.
     return id_list
 
@@ -2646,7 +2644,7 @@
     dp = pipes.get_pipe(pipe)
 
     # No spin ID, so assume there is no spin.
-    if not dp.mol._spin_id_lookup.has_key(spin_id):
+    if spin_id not in dp.mol._spin_id_lookup:
         return None
 
     # The indices from the look up table.
@@ -2682,7 +2680,7 @@
     """
 
     # Handle Unicode.
-    if isinstance(selection, unicode):
+    if is_unicode(selection):
         selection = str(selection)
 
     # The data pipe.
@@ -2812,7 +2810,7 @@
     dp = pipes.get_pipe(pipe)
 
     # No spin ID, so switch to selection matching.
-    if not dp.mol._spin_id_lookup.has_key(spin_id):
+    if spin_id not in dp.mol._spin_id_lookup:
         # Parse the selection string.
         select_obj = Selection(spin_id)
 

Modified: branches/frame_order_testing/opendx/main.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/opendx/main.py?rev=17838&r1=17837&r2=17838&view=diff
==============================================================================
--- branches/frame_order_testing/opendx/main.py (original)
+++ branches/frame_order_testing/opendx/main.py Tue Oct 16 10:52:10 2012
@@ -28,7 +28,7 @@
 import string
 
 # relax module imports.
-import opendx.isosurface_3D
+from opendx import isosurface_3D
 from relax_errors import RelaxError
 from relax_io import test_binary
 

Modified: branches/frame_order_testing/test_suite/relax_test_loader.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/relax_test_loader.py?rev=17838&r1=17837&r2=17838&view=diff
==============================================================================
--- branches/frame_order_testing/test_suite/relax_test_loader.py (original)
+++ branches/frame_order_testing/test_suite/relax_test_loader.py Tue Oct 16 
10:52:10 2012
@@ -1,6 +1,6 @@
 
################################################################################
 #                                                                            
  #
-# Copyright (C) 2011 Edward d'Auvergne                                       
  #
+# Copyright (C) 2011-2012 Edward d'Auvergne                                  
  #
 #                                                                            
  #
 # This file is part of the program relax.                                    
  #
 #                                                                            
  #
@@ -56,7 +56,7 @@
             test_case = testCaseClass(testCaseNames[i])
 
             # Skip.
-            if status.skipped_tests and testCaseNames[i] in 
zip(*status.skipped_tests)[0]:
+            if status.skipped_tests and testCaseNames[i] in 
list(zip(*status.skipped_tests))[0]:
                 continue
 
             # Append the test case.

Modified: 
branches/frame_order_testing/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py?rev=17838&r1=17837&r2=17838&view=diff
==============================================================================
--- 
branches/frame_order_testing/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py
 (original)
+++ 
branches/frame_order_testing/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py
 Tue Oct 16 10:52:10 2012
@@ -899,8 +899,8 @@
 
         # Check the list elements.
         self.assertEqual(len(list), 2)
-        self.assertEqual(list[0], 'CA')
-        self.assertEqual(list[1], 'N')
+        self.assertEqual(list[0], 'N')
+        self.assertEqual(list[1], 'CA')
 
 
     def test_parse_token_multi_element_num_name(self):




Related Messages


Powered by MHonArc, Updated Tue Oct 16 11:00:02 2012