diff --git a/numpy/random/_common.pyx b/numpy/random/_common.pyx index 4c34c503cd2f..86828e200241 100644 --- a/numpy/random/_common.pyx +++ b/numpy/random/_common.pyx @@ -5,6 +5,7 @@ from cpython cimport PyFloat_AsDouble import sys import numpy as np cimport numpy as np +cimport numpy.math as npmath from libc.stdint cimport uintptr_t @@ -398,10 +399,10 @@ cdef int check_array_constraint(np.ndarray val, object name, constraint_type con cdef int check_constraint(double val, object name, constraint_type cons) except -1: cdef bint is_nan if cons == CONS_NON_NEGATIVE: - if not np.isnan(val) and np.signbit(val): + if not npmath.isnan(val) and npmath.signbit(val): raise ValueError(name + " < 0") elif cons == CONS_POSITIVE or cons == CONS_POSITIVE_NOT_NAN: - if cons == CONS_POSITIVE_NOT_NAN and np.isnan(val): + if cons == CONS_POSITIVE_NOT_NAN and npmath.isnan(val): raise ValueError(name + " must not be NaN") elif val <= 0: raise ValueError(name + " <= 0")