mailr19061 - in /trunk: ./ data_store/ generic_fns/ generic_fns/structure/ lib/ lib/text/


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

Header


Content

Posted by edward on March 23, 2013 - 10:46:
Author: bugman
Date: Sat Mar 23 10:46:51 2013
New Revision: 19061

URL: http://svn.gna.org/viewcvs/relax?rev=19061&view=rev
Log:
Moved the check_types module into the lib package.


Added:
    trunk/lib/check_types.py
      - copied unchanged from r19029, trunk/check_types.py
Removed:
    trunk/check_types.py
Modified:
    trunk/data_store/relax_xml.py
    trunk/generic_fns/mol_res_spin.py
    trunk/generic_fns/rdc.py
    trunk/generic_fns/structure/internal.py
    trunk/lib/__init__.py
    trunk/lib/arg_check.py
    trunk/lib/float.py
    trunk/lib/io.py
    trunk/lib/text/table.py

Removed: trunk/check_types.py
URL: http://svn.gna.org/viewcvs/relax/trunk/check_types.py?rev=19060&view=auto
==============================================================================
--- trunk/check_types.py (original)
+++ trunk/check_types.py (removed)
@@ -1,98 +1,0 @@
-###############################################################################
-#                                                                            
 #
-# Copyright (C) 2012 Edward d'Auvergne                                       
 #
-#                                                                            
 #
-# This file is part of the program relax (http://www.nmr-relax.com).         
 #
-#                                                                            
 #
-# This program is free software: you can redistribute it and/or modify       
 #
-# it under the terms of the GNU General Public License as published by       
 #
-# the Free Software Foundation, either version 3 of the License, or          
 #
-# (at your option) any later version.                                        
 #
-#                                                                            
 #
-# This program is distributed in the hope that it will be useful,            
 #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
-# GNU General Public License for more details.                               
 #
-#                                                                            
 #
-# You should have received a copy of the GNU General Public License          
 #
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.      
 #
-#                                                                            
 #
-###############################################################################
-
-# Module docstring.
-"""Special module for checking types."""
-
-# Python module imports.
-io_module = True
-try:
-    from io import IOBase    # Python 2.5+ import.
-    file = None
-except ImportError:
-    io_module = False
-from numpy import float32, float64, ndarray
-try:
-    from numpy import float16
-except ImportError:
-    float16 = float32    # Support for old numpy versions.
-try:
-    from numpy import float128
-except ImportError:
-    float128 = float64    # Support for 32-bit numpy versions.
-
-
-def is_filetype(obj):
-    """Check if the given Python object is a file.
-
-    @param obj:     The Python object.
-    @type obj:      anything
-    @return:        True if the object is a file, False otherwise.
-    @rtype:         bool
-    """
-
-    # New style check.
-    if io_module:
-        return isinstance(obj, IOBase)
-
-    # Old style check.
-    else:
-        return isinstance(obj, file)
-
-
-def is_float(num):
-    """Check if the given number is a Python or numpy float.
-
-    @param num: The number to check.
-    @type num:  anything.
-    @return:    True if the number is a float, False otherwise.
-    @rtype:     bool
-    """
-
-    # Standard float.
-    if isinstance(num, float):
-        return True
-
-    # Numpy floats.
-    if isinstance(num, float16):
-        return True
-    if isinstance(num, float32):
-        return True
-    if isinstance(num, float64):
-        return True
-    if isinstance(num, float128):
-        return True
-
-    # Not a float.
-    return False
-
-
-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: trunk/data_store/relax_xml.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/data_store/relax_xml.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/data_store/relax_xml.py (original)
+++ trunk/data_store/relax_xml.py Sat Mar 23 10:46:51 2013
@@ -32,7 +32,7 @@
 
 # relax module imports.
 import lib.arg_check
-import check_types
+import lib.check_types
 from lib.float import floatAsByteArray, packBytesAsPyFloat
 from lib.errors import RelaxError
 
@@ -129,19 +129,19 @@
     elem.setAttribute('type', py_type)
 
     # Store floats as IEEE-754 byte arrays (for full precision storage).
-    if check_types.is_float(value):
+    if lib.check_types.is_float(value):
         val_elem = doc.createElement('ieee_754_byte_array')
         elem.appendChild(val_elem)
         
val_elem.appendChild(doc.createTextNode(repr(floatAsByteArray(value))))
 
     # Store lists with floats as IEEE-754 byte arrays.
-    elif (isinstance(value, list) or isinstance(value, ndarray)) and 
len(value) and check_types.is_float(value[0]):
+    elif (isinstance(value, list) or isinstance(value, ndarray)) and 
len(value) and lib.check_types.is_float(value[0]):
         # The converted list.
         ieee_obj = []
         conv = False
         for i in range(len(value)):
             # A float.
-            if check_types.is_float(value[i]):
+            if lib.check_types.is_float(value[i]):
                 ieee_obj.append(floatAsByteArray(value[i]))
                 conv = True
 
@@ -164,7 +164,7 @@
         ieee_obj = {}
         conv = False
         for key in list(value.keys()):
-            if check_types.is_float(value[key]):
+            if lib.check_types.is_float(value[key]):
                 ieee_obj[key] = floatAsByteArray(value[key])
                 conv = True
 

Modified: trunk/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/mol_res_spin.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/generic_fns/mol_res_spin.py (original)
+++ trunk/generic_fns/mol_res_spin.py Sat Mar 23 10:46:51 2013
@@ -40,9 +40,9 @@
 from warnings import warn
 
 # relax module imports.
-from check_types import is_unicode
 from data_store.mol_res_spin import MoleculeContainer, ResidueContainer, 
SpinContainer
 from generic_fns import exp_info, pipes, relax_re
+from lib.check_types import is_unicode
 from lib.errors import RelaxError, RelaxNoSpinError, RelaxMultiMolIDError, 
RelaxMultiResIDError, RelaxMultiSpinIDError, RelaxResSelectDisallowError, 
RelaxSpinSelectDisallowError
 from lib.warnings import RelaxWarning
 from status import Status; status = Status()

Modified: trunk/generic_fns/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/rdc.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/generic_fns/rdc.py (original)
+++ trunk/generic_fns/rdc.py Sat Mar 23 10:46:51 2013
@@ -31,7 +31,7 @@
 from warnings import warn
 
 # relax module imports.
-from check_types import is_float
+from lib.check_types import is_float
 from lib.float import nan
 from generic_fns import grace, pipes
 from generic_fns.align_tensor import get_tensor_index

Modified: trunk/generic_fns/structure/internal.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/internal.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/generic_fns/structure/internal.py (original)
+++ trunk/generic_fns/structure/internal.py Sat Mar 23 10:46:51 2013
@@ -32,13 +32,13 @@
 from warnings import warn
 
 # relax module imports.
-from check_types import is_float
 from data_store.relax_xml import fill_object_contents, xml_to_object
 from generic_fns import pipes, relax_re
 from generic_fns.mol_res_spin import spin_loop
 from generic_fns.mol_res_spin import Selection
 from generic_fns.structure import pdb_read, pdb_write
 from generic_fns.structure.api_base import Base_struct_API, ModelList, 
Displacements
+from lib.check_types import is_float
 from lib.errors import RelaxError, RelaxNoneIntError, RelaxNoPdbError
 from lib.io import file_root, open_read_file
 from lib.warnings import RelaxWarning

Modified: trunk/lib/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/__init__.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/lib/__init__.py (original)
+++ trunk/lib/__init__.py Sat Mar 23 10:46:51 2013
@@ -27,6 +27,7 @@
     'ansi',
     'arg_check',
     'auto_relaxation',
+    'check_types',
     'errors',
     'float',
     'frame_order',

Modified: trunk/lib/arg_check.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/arg_check.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/lib/arg_check.py (original)
+++ trunk/lib/arg_check.py Sat Mar 23 10:46:51 2013
@@ -26,7 +26,7 @@
 from numpy import ndarray
 
 # relax module imports.
-import check_types
+import lib.check_types
 from lib.errors import RelaxBoolError, RelaxFloatError, RelaxFunctionError, 
RelaxIntError, RelaxIntListIntError, RelaxListFloatError, RelaxListIntError, 
RelaxMatrixFloatError, RelaxNoneFloatError, RelaxNoneFunctionError, 
RelaxListNumError, RelaxListStrError, RelaxNoneError, RelaxNoneIntError, 
RelaxNoneIntListIntError, RelaxNoneListFloatError, RelaxNoneListIntError, 
RelaxNoneMatrixFloatError, RelaxNoneListNumError, RelaxNoneListStrError, 
RelaxNoneNumError, RelaxNoneNumStrListNumStrError, RelaxNoneNumTupleNumError, 
RelaxNoneStrError, RelaxNoneStrFileError, RelaxNoneStrListNumError, 
RelaxNoneStrListStrError, RelaxNoneTupleError, RelaxNumError, 
RelaxNumStrListNumStrError, RelaxNumTupleNumError, RelaxStrError, 
RelaxStrFileError, RelaxStrListNumError, RelaxStrListStrError, 
RelaxTupleError, RelaxTupleNumError, RelaxNoneValListValError, 
RelaxValListValError
 from lib.io import DummyFileObject
 from types import FunctionType, MethodType

Modified: trunk/lib/float.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/float.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/lib/float.py (original)
+++ trunk/lib/float.py Sat Mar 23 10:46:51 2013
@@ -94,7 +94,7 @@
 import sys
 
 # relax module imports.
-from check_types import is_float
+from lib.check_types import is_float
 
 
 SIGNBIT = 0x80

Modified: trunk/lib/io.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/io.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/lib/io.py (original)
+++ trunk/lib/io.py Sat Mar 23 10:46:51 2013
@@ -40,9 +40,9 @@
 from warnings import warn
 
 # relax module imports.
-from check_types import is_filetype, is_float
 from compat import bz2_open, gz_open
 import generic_fns
+from lib.check_types import is_filetype, is_float
 from lib.errors import RelaxError, RelaxFileError, RelaxFileOverwriteError, 
RelaxInvalidSeqError, RelaxMissingBinaryError, RelaxNoInPathError, 
RelaxNonExecError
 from lib.warnings import RelaxWarning, RelaxFileEmptyWarning
 

Modified: trunk/lib/text/table.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/text/table.py?rev=19061&r1=19060&r2=19061&view=diff
==============================================================================
--- trunk/lib/text/table.py (original)
+++ trunk/lib/text/table.py Sat Mar 23 10:46:51 2013
@@ -27,7 +27,7 @@
 from textwrap import wrap
 
 # relax module imports.
-from check_types import is_float
+from lib.check_types import is_float
 from lib.errors import RelaxError
 
 




Related Messages


Powered by MHonArc, Updated Sat Mar 23 11:00:02 2013