diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2006-06-30 12:21:17 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2006-06-30 12:21:17 +0000 |
commit | 2b06537f480da6c75666b8c3ed8e45aa2aef6e59 (patch) | |
tree | 8316c9637570611808c4881adbcefcfe479b850a /numpy | |
parent | bbabc5c6e3ac6356056ec3f997c81bd430f3214b (diff) | |
download | numpy-2b06537f480da6c75666b8c3ed8e45aa2aef6e59.tar.gz |
Cast to double instead of float in digitize.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/src/_compiled_base.c | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 5 |
2 files changed, 7 insertions, 2 deletions
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): |