From 2b06537f480da6c75666b8c3ed8e45aa2aef6e59 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Fri, 30 Jun 2006 12:21:17 +0000 Subject: Cast to double instead of float in digitize. --- numpy/lib/src/_compiled_base.c | 4 ++-- numpy/lib/tests/test_function_base.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'numpy') diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 4878abb49..1ba1aa742 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -190,11 +190,11 @@ arr_digitize(PyObject *self, PyObject *args, PyObject *kwds) 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"); } diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 244b64bc1..1c99eaa18 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -285,6 +285,11 @@ class test_digitize(NumpyTestCase): 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): -- cgit v1.2.1