[Numpy-svn] r2709 - in trunk/numpy/lib: src tests

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Jun 30 07:21:40 CDT 2006


Author: stefan
Date: 2006-06-30 07:21:17 -0500 (Fri, 30 Jun 2006)
New Revision: 2709

Modified:
   trunk/numpy/lib/src/_compiled_base.c
   trunk/numpy/lib/tests/test_function_base.py
Log:
Cast to double instead of float in digitize.


Modified: trunk/numpy/lib/src/_compiled_base.c
===================================================================
--- trunk/numpy/lib/src/_compiled_base.c	2006-06-30 11:59:07 UTC (rev 2708)
+++ trunk/numpy/lib/src/_compiled_base.c	2006-06-30 12:21:17 UTC (rev 2709)
@@ -190,11 +190,11 @@
         m = monotonic_ (dbins, lbins) ;
 	if ( m == -1 ) {
             for ( i = 0 ; i < lx ; i ++ )
-		iret [i] = decr_slot_ (dx [i], dbins, lbins) ;
+		iret [i] = decr_slot_ ((double)dx [i], dbins, lbins) ;
 	}
         else if ( m == 1 ) {
             for ( i = 0 ; i < lx ; i ++ )
-                iret [i] = incr_slot_ ((float)dx [i], dbins, lbins) ;
+                iret [i] = incr_slot_ ((double)dx [i], dbins, lbins) ;
         }
         else Py_Assert(0, "bins must be montonically increasing or decreasing");
     }

Modified: trunk/numpy/lib/tests/test_function_base.py
===================================================================
--- trunk/numpy/lib/tests/test_function_base.py	2006-06-30 11:59:07 UTC (rev 2708)
+++ trunk/numpy/lib/tests/test_function_base.py	2006-06-30 12:21:17 UTC (rev 2709)
@@ -285,6 +285,11 @@
 	x = arange(5,-6,-1)
 	bins = arange(5,-5,-1)
 	assert_array_equal(digitize(x,bins),arange(11))
+	
+    def check_random(self):
+	x = rand(10)
+	bin = linspace(x.min(), x.max(), 10)
+	assert all(digitize(x,bin) != 0)
 
 class test_unwrap(NumpyTestCase):
     def check_simple(self):



More information about the Numpy-svn mailing list