Skip to content

Commit

Permalink
Make the utils.isnan function inline (jmschrei#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhenrie authored and jmschrei committed Oct 1, 2019
1 parent 52e7d30 commit 2dc0f9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pomegranate/utils.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cdef int* GPU
cdef extern from "numpy/npy_math.h":
bint npy_isnan(double x) nogil

cdef bint isnan(double x) nogil
cdef inline bint isnan(double x) nogil:
return npy_isnan(x)

cdef int _is_gpu_enabled() nogil
cdef python_log_probability(model, double* X, double* log_probability, int n)
cdef python_summarize(model, double* X, double* weights, int n)
Expand Down
5 changes: 1 addition & 4 deletions pomegranate/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ numpy.import_array()
cdef extern from "numpy/ndarraytypes.h":
void PyArray_ENABLEFLAGS(numpy.ndarray X, int flags)

cdef bint isnan(double x) nogil:
return npy_isnan(x)

# Define some useful constants
DEF NEGINF = float("-inf")
DEF INF = float("inf")
Expand Down Expand Up @@ -487,4 +484,4 @@ def check_random_state(seed):
return seed
raise ValueError('%r cannot be used to seed a numpy.random.RandomState'
' instance' % seed)


0 comments on commit 2dc0f9d

Please sign in to comment.