summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2009-08-29 00:08:04 +0000
committerCharles Harris <charlesr.harris@gmail.com>2009-08-29 00:08:04 +0000
commitaba728e79bc77e39787e2a0cf9d9eae4dc2f8690 (patch)
treed6c73f2c64199f5edb432ae73a593ed278d13a67 /numpy
parent444fcb1e2feaef724fd4c69d8e27193ac3eeb565 (diff)
downloadnumpy-aba728e79bc77e39787e2a0cf9d9eae4dc2f8690.tar.gz
Make true divide return doubles.
Make true divide return nan/infs instead of raise zero divide error.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/code_generators/generate_umath.py2
-rw-r--r--numpy/core/src/umath/loops.c.src12
2 files changed, 4 insertions, 10 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
index 97172ad29..4aea685df 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -255,7 +255,7 @@ defdict = {
'true_divide' :
Ufunc(2, 1, One,
docstrings.get('numpy.core.umath.true_divide'),
- TD('bBhH', out='f'),
+ TD('bBhH', out='d'),
TD('iIlLqQ', out='d'),
TD(flts+cmplx),
TD(O, f='PyNumber_TrueDivide'),
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 10cfa8716..5c9e2bfd0 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -643,15 +643,9 @@ NPY_NO_EXPORT void
@S@@TYPE@_true_divide(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
{
BINARY_LOOP {
- const @s@@type@ in1 = *(@s@@type@ *)ip1;
- const @s@@type@ in2 = *(@s@@type@ *)ip2;
- if (in2 == 0) {
- generate_divbyzero_error();
- *((@ftype@ *)op1) = 0;
- }
- else {
- *((@ftype@ *)op1) = (@ftype@)in1 / (@ftype@)in2;
- }
+ const double in1 = (double)(*(@s@@type@ *)ip1);
+ const double in2 = (double)(*(@s@@type@ *)ip2);
+ *((double *)op1) = in1/in2;
}
}