From e2467e463d7f0c7fe01ef33311d007f7182a0cf7 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 17 Feb 2021 11:05:42 +0000 Subject: [PATCH 1/2] MAINT: Correct code producing warnings Cast to avoid warnings Correct function --- numpy/core/src/multiarray/ctors.c | 2 +- numpy/core/src/umath/fast_loop_macros.h | 2 +- numpy/random/src/distributions/distributions.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index ef105ff2d3f8..fc1152d514fa 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -2907,7 +2907,7 @@ _arange_safe_ceil_to_intp(double value) "arange: cannot compute length"); return -1; } - if (!(NPY_MIN_INTP <= ivalue && ivalue <= NPY_MAX_INTP)) { + if (!(NPY_MIN_INTP <= ivalue && ivalue <= (double)NPY_MAX_INTP)) { PyErr_SetString(PyExc_OverflowError, "arange: overflow while computing length"); return -1; diff --git a/numpy/core/src/umath/fast_loop_macros.h b/numpy/core/src/umath/fast_loop_macros.h index b81795b9621f..4a36c9721879 100644 --- a/numpy/core/src/umath/fast_loop_macros.h +++ b/numpy/core/src/umath/fast_loop_macros.h @@ -305,7 +305,7 @@ abs_ptrdiff(char *a, char *b) */ #define IS_OUTPUT_BLOCKABLE_UNARY(esizein, esizeout, vsize) \ ((steps[0] & (esizein-1)) == 0 && \ - steps[1] == (esizeout) && labs(steps[0]) < MAX_STEP_SIZE && \ + steps[1] == (esizeout) && llabs(steps[0]) < MAX_STEP_SIZE && \ (nomemoverlap(args[1], steps[1] * dimensions[0], args[0], steps[0] * dimensions[0]))) #define IS_BLOCKABLE_REDUCE(esize, vsize) \ diff --git a/numpy/random/src/distributions/distributions.c b/numpy/random/src/distributions/distributions.c index 93e0bdc5f6d2..4494f860e881 100644 --- a/numpy/random/src/distributions/distributions.c +++ b/numpy/random/src/distributions/distributions.c @@ -971,7 +971,7 @@ RAND_INT_TYPE random_zipf(bitgen_t *bitgen_state, double a) { * just reject this value. This function then models a Zipf * distribution truncated to sys.maxint. */ - if (X > RAND_INT_MAX || X < 1.0) { + if (X > (double)RAND_INT_MAX || X < 1.0) { continue; } From 23136aa98a402ed4230bc7e42e1669931c5d8784 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Thu, 18 Feb 2021 17:56:45 +0000 Subject: [PATCH 2/2] CLN: Add additional cast --- numpy/core/src/multiarray/ctors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index fc1152d514fa..c98d2751256c 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -2907,7 +2907,7 @@ _arange_safe_ceil_to_intp(double value) "arange: cannot compute length"); return -1; } - if (!(NPY_MIN_INTP <= ivalue && ivalue <= (double)NPY_MAX_INTP)) { + if (!((double)NPY_MIN_INTP <= ivalue && ivalue <= (double)NPY_MAX_INTP)) { PyErr_SetString(PyExc_OverflowError, "arange: overflow while computing length"); return -1;