[Numpy-svn] r5872 - in branches/clean_math_config_chuck/numpy: core distutils/command lib lib/tests

numpy-svn@scip... numpy-svn@scip...
Sun Sep 28 15:16:12 CDT 2008


Author: charris
Date: 2008-09-28 15:16:08 -0500 (Sun, 28 Sep 2008)
New Revision: 5872

Modified:
   branches/clean_math_config_chuck/numpy/core/setup.py
   branches/clean_math_config_chuck/numpy/distutils/command/config.py
   branches/clean_math_config_chuck/numpy/lib/io.py
   branches/clean_math_config_chuck/numpy/lib/tests/test_io.py
Log:
Keep current with David's work.


Modified: branches/clean_math_config_chuck/numpy/core/setup.py
===================================================================
--- branches/clean_math_config_chuck/numpy/core/setup.py	2008-09-28 20:06:00 UTC (rev 5871)
+++ branches/clean_math_config_chuck/numpy/core/setup.py	2008-09-28 20:16:08 UTC (rev 5872)
@@ -63,20 +63,12 @@
     def name_to_defsymb(name):
         return "HAVE_%s" % name.upper()
 
-    use_msvc = config.check_decl("_MSC_VER")
+    #use_msvc = config.check_decl("_MSC_VER")
 
     # Mandatory functions: if not found, fail the build
-    if use_msvc:
-        # MSVC use intrisincs functions when build with e.g. /Ox, and this
-        # breaks tests. Fixing the tests is not trivial, so we assume the
-        # intrisincs functions are available.
-        # Functions which have intrisinces: sin, cos, tan, sin, cosh, tanh,
-        # fabs, sqrt, log10, log, exp, asin, acos, atan, fmod
-        mandatory_funcs = ['modf', 'frexp', 'ldexp']
-    else:
-        mandatory_funcs = ["sin", "cos", "tan", "sinh", "cosh", "tanh", "fabs",
-                        "floor", "ceil", "sqrt", "log10", "log", "exp", "asin",
-                        "acos", "atan", "fmod", 'modf', 'frexp', 'ldexp']
+    mandatory_funcs = ["sin", "cos", "tan", "sinh", "cosh", "tanh", "fabs",
+		"floor", "ceil", "sqrt", "log10", "log", "exp", "asin",
+		"acos", "atan", "fmod", 'modf', 'frexp', 'ldexp']
 
     if not check_funcs_once(mandatory_funcs):
         raise SystemError("One of the required function to build numpy is not"

Modified: branches/clean_math_config_chuck/numpy/distutils/command/config.py
===================================================================
--- branches/clean_math_config_chuck/numpy/distutils/command/config.py	2008-09-28 20:06:00 UTC (rev 5871)
+++ branches/clean_math_config_chuck/numpy/distutils/command/config.py	2008-09-28 20:16:08 UTC (rev 5872)
@@ -126,6 +126,13 @@
         body = []
         if decl:
             body.append("int %s ();" % func)
+        # Handle MSVC intrisincs: force MS compiler to make a function call.
+        # Useful to test for some functions when built with optimization on, to
+        # avoid build error because the intrisinc and our 'fake' test
+        # declaration do not match.
+        body.append("#ifdef _MSC_VER")
+        body.append("#pragma function(%s)" % func)
+        body.append("#endif")
         body.append("int main (void) {")
         if call:
             if call_args is None:
@@ -174,6 +181,12 @@
                 if v:
                     body.append("int %s ();" % f)
 
+        # Handle MS intrinsics. See check_func for more info.
+        body.append("#ifdef _MSC_VER")
+        for func in funcs:
+            body.append("#pragma function(%s)" % func)
+        body.append("#endif")
+
         body.append("int main (void) {")
         if call:
             for f in funcs:

Modified: branches/clean_math_config_chuck/numpy/lib/io.py
===================================================================
--- branches/clean_math_config_chuck/numpy/lib/io.py	2008-09-28 20:06:00 UTC (rev 5871)
+++ branches/clean_math_config_chuck/numpy/lib/io.py	2008-09-28 20:16:08 UTC (rev 5872)
@@ -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_chuck/numpy/lib/tests/test_io.py
===================================================================
--- branches/clean_math_config_chuck/numpy/lib/tests/test_io.py	2008-09-28 20:06:00 UTC (rev 5871)
+++ branches/clean_math_config_chuck/numpy/lib/tests/test_io.py	2008-09-28 20:16:08 UTC (rev 5872)
@@ -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