mailr23774 - /trunk/lib/compat.py


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

Header


Content

Posted by edward on June 10, 2014 - 09:40:
Author: bugman
Date: Tue Jun 10 09:40:22 2014
New Revision: 23774

URL: http://svn.gna.org/viewcvs/relax?rev=23774&view=rev
Log:
The lib.compat.norm() replacement function for numpy.linalg.norm() now 
handles no axis argument.

This is to allow the function to be used in all cases where 
numpy.linalg.norm() is used, while
providing compatibility with the axis argument and all numpy versions.


Modified:
    trunk/lib/compat.py

Modified: trunk/lib/compat.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/compat.py?rev=23774&r1=23773&r2=23774&view=diff
==============================================================================
--- trunk/lib/compat.py (original)
+++ trunk/lib/compat.py Tue Jun 10 09:40:22 2014
@@ -237,13 +237,16 @@
     @type axis:     {int, 2-tuple of ints, None}, optional
     """
 
+    # No axis argument given.
+    if axis == None:
+        return numpy.linalg.norm(x, ord=ord)
+
     # The axis argument exists.
     if numpy_norm_axis:
         return numpy.linalg.norm(x, ord=ord, axis=axis)
 
     # Support for older version (this is much slower).
-    else:
-        return numpy.apply_along_axis(numpy.linalg.norm, axis, x)
+    return numpy.apply_along_axis(numpy.linalg.norm, axis, x)
 
 
 def sorted(data):




Related Messages


Powered by MHonArc, Updated Tue Jun 10 10:00:02 2014