diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/code_generators/generate_umath.py | 2 | ||||
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 36 | ||||
-rw-r--r-- | numpy/core/src/umath/loops.h.src | 3 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 16 |
4 files changed, 8 insertions, 49 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py index 9e94f9ccc..1b6917ebc 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py @@ -329,7 +329,7 @@ defdict = { 'PyUFunc_DivisionTypeResolver', TD(ints, cfunc_alias='divide', dispatch=[('loops_arithmetic', 'bBhHiIlLqQ')]), - TD(flts + cmplx), + TD(flts), [TypeDescription('m', FullTypeDescr, 'mq', 'm'), TypeDescription('m', FullTypeDescr, 'md', 'm'), TypeDescription('m', FullTypeDescr, 'mm', 'q'), diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index 683bd0178..b1afa69a7 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -2416,42 +2416,6 @@ NPY_NO_EXPORT void } -NPY_NO_EXPORT void -@TYPE@_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)) -{ - BINARY_LOOP { - const @ftype@ in1r = ((@ftype@ *)ip1)[0]; - const @ftype@ in1i = ((@ftype@ *)ip1)[1]; - const @ftype@ in2r = ((@ftype@ *)ip2)[0]; - const @ftype@ in2i = ((@ftype@ *)ip2)[1]; -#if defined(__APPLE__) && defined(__aarch64__) - // On macos-arm64 without this block of code, - // when branch prediction goes wrong, the floating point exception - // register does not get cleared and an exception for the - // wrong branch is thrown. - if (in2i == 0) { - ((@ftype@ *)op1)[0] = npy_floor@c@(in1r/in2r); - ((@ftype@ *)op1)[1] = 0; - } - else if (in2r == 0) { - ((@ftype@ *)op1)[0] = npy_floor@c@(in1i/in2i); - ((@ftype@ *)op1)[1] = 0; - } - else -#endif - if (npy_fabs@c@(in2r) >= npy_fabs@c@(in2i)) { - const @ftype@ rat = in2i/in2r; - ((@ftype@ *)op1)[0] = npy_floor@c@((in1r + in1i*rat)/(in2r + in2i*rat)); - ((@ftype@ *)op1)[1] = 0; - } - else { - const @ftype@ rat = in2r/in2i; - ((@ftype@ *)op1)[0] = npy_floor@c@((in1r*rat + in1i)/(in2i + in2r*rat)); - ((@ftype@ *)op1)[1] = 0; - } - } -} - /**begin repeat1 * #kind= greater, greater_equal, less, less_equal, equal, not_equal# * #OP = CGT, CGE, CLT, CLE, CEQ, CNE# diff --git a/numpy/core/src/umath/loops.h.src b/numpy/core/src/umath/loops.h.src index bb07e047c..02d749a5e 100644 --- a/numpy/core/src/umath/loops.h.src +++ b/numpy/core/src/umath/loops.h.src @@ -420,9 +420,6 @@ C@TYPE@_@kind@(char **args, npy_intp const *dimensions, npy_intp const *steps, v NPY_NO_EXPORT void C@TYPE@_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); -NPY_NO_EXPORT void -C@TYPE@_floor_divide(char **args, npy_intp const *dimensions, npy_intp const *steps, void *NPY_UNUSED(func)); - /**begin repeat1 * #kind= greater, greater_equal, less, less_equal, equal, not_equal# * #OP = CGT, CGE, CLT, CLE, CEQ, CNE# diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index a2d6b3989..e6fcf5bd4 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -433,16 +433,14 @@ class TestDivision: assert_(np.isnan(y)[0]) def test_floor_division_complex(self): - # check that implementation is correct - msg = "Complex floor division implementation check" + # check that floor division, divmod and remainder raises type errors x = np.array([.9 + 1j, -.1 + 1j, .9 + .5*1j, .9 + 2.*1j], dtype=np.complex128) - y = np.array([0., -1., 0., 0.], dtype=np.complex128) - assert_equal(np.floor_divide(x**2, x), y, err_msg=msg) - # check overflow, underflow - msg = "Complex floor division overflow/underflow check" - x = np.array([1.e+110, 1.e-110], dtype=np.complex128) - y = np.floor_divide(x**2, x) - assert_equal(y, [1.e+110, 0], err_msg=msg) + with pytest.raises(TypeError): + x // 7 + with pytest.raises(TypeError): + np.divmod(x, 7) + with pytest.raises(TypeError): + np.remainder(x, 7) def test_floor_division_signed_zero(self): # Check that the sign bit is correctly set when dividing positive and |