summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2006-06-30 12:21:17 +0000
committerStefan van der Walt <stefan@sun.ac.za>2006-06-30 12:21:17 +0000
commit2b06537f480da6c75666b8c3ed8e45aa2aef6e59 (patch)
tree8316c9637570611808c4881adbcefcfe479b850a /numpy
parentbbabc5c6e3ac6356056ec3f997c81bd430f3214b (diff)
downloadnumpy-2b06537f480da6c75666b8c3ed8e45aa2aef6e59.tar.gz
Cast to double instead of float in digitize.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/src/_compiled_base.c4
-rw-r--r--numpy/lib/tests/test_function_base.py5
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):