[Numpy-svn] r5861 - in branches/clean_math_config: . numpy/lib numpy/lib/tests

numpy-svn@scip... numpy-svn@scip...
Mon Sep 22 22:48:07 CDT 2008


Author: cdavid
Date: 2008-09-22 22:48:01 -0500 (Mon, 22 Sep 2008)
New Revision: 5861

Modified:
   branches/clean_math_config/
   branches/clean_math_config/numpy/lib/io.py
   branches/clean_math_config/numpy/lib/tests/test_io.py
Log:
Merged revisions 5844-5860 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk

........
  r5860 | stefan | 2008-09-23 05:28:00 +0900 (Tue, 23 Sep 2008) | 2 lines
  
  Ignore unused converters in `loadtxt`.
........



Property changes on: branches/clean_math_config
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/aligned_alloca:1-5127 /branches/build_with_scons:1-4676 /branches/cdavid:1-5257 /branches/cleanconfig_rtm:1-4677 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /branches/vs_longstring:1-5656 /cleaned_math_config:1-5731 /trunk:1-5843
   + /branches/aligned_alloca:1-5127 /branches/build_with_scons:1-4676 /branches/cdavid:1-5257 /branches/cleanconfig_rtm:1-4677 /branches/distutils-revamp:1-2752 /branches/distutils_scons_command:1-4619 /branches/multicore:1-3687 /branches/numpy.scons:1-4484 /branches/vs_longstring:1-5656 /cleaned_math_config:1-5731 /trunk:1-5860

Modified: branches/clean_math_config/numpy/lib/io.py
===================================================================
--- branches/clean_math_config/numpy/lib/io.py	2008-09-22 20:28:00 UTC (rev 5860)
+++ branches/clean_math_config/numpy/lib/io.py	2008-09-23 03:48:01 UTC (rev 5861)
@@ -378,7 +378,11 @@
     # By preference, use the converters specified by the user
     for i, conv in (user_converters or {}).iteritems():
         if usecols:
-            i = usecols.index(i)
+            try:
+                i = usecols.index(i)
+            except ValueError:
+                # Unused converter specified
+                continue
         converters[i] = conv
 
     # Parse each line, including the first

Modified: branches/clean_math_config/numpy/lib/tests/test_io.py
===================================================================
--- branches/clean_math_config/numpy/lib/tests/test_io.py	2008-09-22 20:28:00 UTC (rev 5860)
+++ branches/clean_math_config/numpy/lib/tests/test_io.py	2008-09-23 03:48:01 UTC (rev 5861)
@@ -258,6 +258,17 @@
         c = StringIO.StringIO()
         assert_raises(IOError, np.loadtxt, c)
 
+    def test_unused_converter(self):
+        c = StringIO.StringIO()
+        c.writelines(['1 21\n', '3 42\n'])
+        c.seek(0)
+        data = np.loadtxt(c, usecols=(1,), converters={0: lambda s: int(s, 16)})
+        assert_array_equal(data, [21, 42])
+
+        c.seek(0)
+        data = np.loadtxt(c, usecols=(1,), converters={1: lambda s: int(s, 16)})
+        assert_array_equal(data, [33, 66])
+
 class Testfromregex(TestCase):
     def test_record(self):
         c = StringIO.StringIO()



More information about the Numpy-svn mailing list