diff options
-rw-r--r-- | numpy/random/_generator.pyx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index b0bfd860c..cd950b3fa 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -3758,15 +3758,15 @@ cdef class Generator: if kahan_sum(pix, d-1) > (1.0 + 1e-12): # When floating, but not float dtype, and close, improve the error # 1.0001 works for float16 and float32 - if (isinstance(pvals, np.ndarray) and - pvals.dtype != float and - np.issubdtype(pvals.dtype, np.floating) and - pvals.sum() < 1.0001): - msg = ("sum(pvals[:-1].astype(np.float64)) > 1.0. pvals are " - "cast to 64-bit floating point values prior to " - "checking the constraint. Changes in precision when " - "casting may produce violations even if " - "pvals[:-1].sum() <= 1.") + if (isinstance(pvals, np.ndarray) + and np.issubdtype(pvals.dtype, np.floating) + and pvals.dtype != float + and pvals.sum() < 1.0001): + msg = ("sum(pvals[:-1].astype(np.float64)) > 1.0. The pvals " + "array is cast to 64-bit floating point prior to " + "checking the sum. Precision changes when casting may " + "cause problems even if the sum of the original pvals " + "is valid.") else: msg = "sum(pvals[:-1]) > 1.0" raise ValueError(msg) |