[Scipy-svn] r6568 - trunk/scipy/constants

scipy-svn@scip... scipy-svn@scip...
Sat Jun 26 23:20:03 CDT 2010


Author: stefan
Date: 2010-06-26 23:20:03 -0500 (Sat, 26 Jun 2010)
New Revision: 6568

Modified:
   trunk/scipy/constants/constants.py
Log:
ENH: Allow temperature conversion functions to operate on array-like input.

Modified: trunk/scipy/constants/constants.py
===================================================================
--- trunk/scipy/constants/constants.py	2010-06-27 04:19:59 UTC (rev 6567)
+++ trunk/scipy/constants/constants.py	2010-06-27 04:20:03 UTC (rev 6568)
@@ -18,6 +18,7 @@
 
 import math as _math
 from codata import value as _cd
+import numpy as np
 
 #mathematical constants
 pi = _math.pi
@@ -196,7 +197,7 @@
     array([ 233.15,  313.15])
 
     """
-    return C + zero_Celsius
+    return np.asanyarray(C) + zero_Celsius
 
 def K2C(K):
     """
@@ -224,7 +225,7 @@
     array([-40.,  40.])
 
     """
-    return K - zero_Celsius
+    return np.asanyarray(K) - zero_Celsius
 
 def F2C(F):
     """
@@ -251,7 +252,7 @@
     array([-40.        ,   4.44444444])
 
     """
-    return (F - 32) / 1.8
+    return (np.asanyarray(F) - 32) / 1.8
 
 def C2F(C):
     """
@@ -278,7 +279,7 @@
     array([ -40.,  104.])
 
     """
-    return 1.8 * C + 32
+    return 1.8 * np.asanyarray(C) + 32
 
 def F2K(F):
     """
@@ -307,7 +308,7 @@
     array([ 233.15,  313.15])
 
     """
-    return C2K(F2C(F))
+    return C2K(F2C(np.asanyarray(F)))
 
 def K2F(K):
     """
@@ -336,7 +337,7 @@
     array([ -40.,  104.])
 
     """
-    return C2F(K2C(K))
+    return C2F(K2C(np.asanyarray(K)))
 
 #optics
 
@@ -366,7 +367,7 @@
     array([  2.99792458e+08,   1.00000000e+00])
 
     """
-    return c / lambda_
+    return np.asanyarray(c) / lambda_
 
 def nu2lambda(nu):
     """
@@ -394,4 +395,5 @@
     array([  2.99792458e+08,   1.00000000e+00])
 
     """
-    return c / nu
+    return c / np.asanyarray(nu)
+



More information about the Scipy-svn mailing list