Skip to content

Commit

Permalink
ENH: special: always show the legacy downcast warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pv committed Nov 11, 2012
1 parent 1123a35 commit 2262093
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scipy/special/_legacy.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ cdef extern from "cephes.h":
double smirnov(int n, double e) nogil
double smirnovi(int n, double p) nogil

cdef extern from "Python.h":
# Purposefully ignore the raised PyError --- assume the ufunc will collect it
int PyErr_WarnEx_noerr "PyErr_WarnEx" (object, char *, int)

cdef inline void _legacy_cast_check(char *func_name, double x, double y) nogil:
if <int>x != x or <int>y != y:
sf_error.error(func_name, sf_error.OTHER,
"floating point number truncated to integer")
with gil:
PyErr_WarnEx_noerr(RuntimeWarning,
"floating point number truncated to an integer",
1)

cdef inline double bdtrc_unsafe(double k, double n, double p) nogil:
_legacy_cast_check("bdtrc", k, n)
Expand Down

0 comments on commit 2262093

Please sign in to comment.