diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2009-08-29 00:08:04 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2009-08-29 00:08:04 +0000 |
commit | aba728e79bc77e39787e2a0cf9d9eae4dc2f8690 (patch) | |
tree | d6c73f2c64199f5edb432ae73a593ed278d13a67 | |
parent | 444fcb1e2feaef724fd4c69d8e27193ac3eeb565 (diff) | |
download | numpy-aba728e79bc77e39787e2a0cf9d9eae4dc2f8690.tar.gz |
Make true divide return doubles.
Make true divide return nan/infs instead of raise zero divide error.
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 2 | ||||
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 12 |
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; } } |