diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2022-06-28 09:58:12 -0700 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-06-28 10:10:20 -0700 |
| commit | 86d2a87cf97b99bcff13bbbd5c4211fdfc5ff2af (patch) | |
| tree | cb29599cdc2c0c0af9e4133d2e6c2cfcaa2f03c8 /numpy/core/src/multiarray | |
| parent | a2caa35dd9f2dae9f492a1af9faa1619e4fcce02 (diff) | |
| download | numpy-86d2a87cf97b99bcff13bbbd5c4211fdfc5ff2af.tar.gz | |
ENH,MAINT: Improve and simplify scalar floating point warnings
This makes the scalar operations warnings read e.g.:
overflow encountered in scalar multiply
rather than:
overflow encountered in float_scalars
It also fixes one case where "assignment" rather than "cast" was
used when I added the FPEs for casts.
Otherwise, uses the helper that I intrudced for for the floating
point casts in all places to simplify the code, the only
"complicated" thing is that I try to give "scalar divide" rather
than "scalar true_divide" as warnings, since "true_divide" should
not really be something that end-users need be aware of.
Diffstat (limited to 'numpy/core/src/multiarray')
| -rw-r--r-- | numpy/core/src/multiarray/arraytypes.c.src | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 2539fdb57..7cd80ba9a 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -394,19 +394,9 @@ static int /* Overflow could have occured converting double to float */ if (NPY_UNLIKELY((npy_isinf(temp.real) && !npy_isinf(oop.real)) || (npy_isinf(temp.imag) && !npy_isinf(oop.imag)))) { - int bufsize, errmask; - PyObject *errobj; - - if (PyUFunc_GetPyValues("assignment", &bufsize, &errmask, - &errobj) < 0) { - return -1; - } - int first = 1; - if (PyUFunc_handlefperr(errmask, errobj, NPY_FPE_OVERFLOW, &first)) { - Py_XDECREF(errobj); + if (PyUFunc_GiveFloatingpointErrors("cast", NPY_FPE_OVERFLOW) < 0) { return -1; } - Py_XDECREF(errobj); } #endif } |
