Fix numpy fatal error: incorrect random_float_fill return type (#2137)

Upstream PR numpy/numpy#20911
This commit is contained in:
Hood Chatham 2022-01-27 00:13:32 -08:00 committed by GitHub
parent ad114b72a2
commit 6bdd96c964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -23,6 +23,7 @@ source:
- patches/fix-invalid-asm-instruction.patch
- patches/fix-removed-decorators-module.patch
- patches/fix-comparator-function-signatures.patch
- patches/fix-random_float_fill-return-type.patch
build:
skip_host: False

View File

@ -0,0 +1,33 @@
From 575e6b726adcd2c1bef5ca0185aa2b2178cea20e Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Wed, 26 Jan 2022 18:59:47 -0800
Subject: [PATCH] BUG: Fix the return type of random_float_fill
The `random_float_fill` function type is declared with return type `double` but
I think this is a typo. The actual implementation of `random_float_fill` is
`random_standard_uniform_fill_f` which has return type `void`:
void random_standard_uniform_fill_f(bitgen_t *bitgen_state, npy_intp cnt, float *out)
Also, `random_double_fill` is declared with return type `void`. This fixes the
return type of `random_float_fill` to match.
---
numpy/random/_common.pxd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/numpy/random/_common.pxd b/numpy/random/_common.pxd
index 9f2e8c3ca..3625634cd 100644
--- a/numpy/random/_common.pxd
+++ b/numpy/random/_common.pxd
@@ -45,7 +45,7 @@
ctypedef double (*random_double_2)(void *state, double a, double b) nogil
ctypedef double (*random_double_3)(void *state, double a, double b, double c) nogil
-ctypedef double (*random_float_fill)(bitgen_t *state, np.npy_intp count, float* out) nogil
+ctypedef void (*random_float_fill)(bitgen_t *state, np.npy_intp count, float* out) nogil
ctypedef float (*random_float_0)(bitgen_t *state) nogil
ctypedef float (*random_float_1)(bitgen_t *state, float a) nogil
--
2.25.1