[Scipy-svn] r6266 - in trunk/scipy/constants: . tests

scipy-svn@scip... scipy-svn@scip...
Sun Mar 21 16:16:09 CDT 2010


Author: warren.weckesser
Date: 2010-03-21 16:16:09 -0500 (Sun, 21 Mar 2010)
New Revision: 6266

Added:
   trunk/scipy/constants/tests/
   trunk/scipy/constants/tests/test_codata.py
Modified:
   trunk/scipy/constants/codata.py
Log:
ENH: Change scipy.constants.find() to return the list of keys instead of printing them (ticket #996).

Modified: trunk/scipy/constants/codata.py
===================================================================
--- trunk/scipy/constants/codata.py	2010-03-21 20:37:15 UTC (rev 6265)
+++ trunk/scipy/constants/codata.py	2010-03-21 21:16:09 UTC (rev 6266)
@@ -469,8 +469,7 @@
         if l_sub in l_key:
             result.append(key)
     result.sort()
-    for key in result :
-        print key
+    return result
 
 #table is lacking some digits for exact values: calculate from definition
 

Added: trunk/scipy/constants/tests/test_codata.py
===================================================================
--- trunk/scipy/constants/tests/test_codata.py	                        (rev 0)
+++ trunk/scipy/constants/tests/test_codata.py	2010-03-21 21:16:09 UTC (rev 6266)
@@ -0,0 +1,23 @@
+
+from scipy.constants import find
+from numpy.testing import assert_equal
+
+def test_find():
+
+    keys = find('weak mixing')
+    assert_equal(keys, ['weak mixing angle'])
+
+    keys = find('qwertyuiop')
+    assert_equal(keys, [])
+
+    keys = find('natural unit')
+    assert_equal(keys, sorted(['natural unit of velocity',
+                                'natural unit of action',
+                                'natural unit of action in eV s',
+                                'natural unit of mass',
+                                'natural unit of energy',
+                                'natural unit of energy in MeV',
+                                'natural unit of momentum',
+                                'natural unit of momentum in MeV/c',
+                                'natural unit of length',
+                                'natural unit of time']))



More information about the Scipy-svn mailing list