8000 Merge pull request #15058 from charris/backport-15046 · numpy/numpy@790965f · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 790965f

Browse files
authored
Merge pull request #15058 from charris/backport-15046
API, DOC: change names to multivariate_hypergeometric, improve docs
2 parents 86d912b + ca19ab6 commit 790965f

File tree

7 files changed

+25
-33
lines changed

7 files changed

+25
-33
lines changed

doc/source/reference/random/c-api.rst

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,15 @@ Cython API for random
33

44
.. currentmodule:: numpy.random
55

6-
Typed versions of many of the `Generator` and `BitGenerator` methods can be
7-
accessed directly from Cython: the complete list is given below.
6+
Typed versions of many of the `Generator` and `BitGenerator` methods as well as
7+
the classes themselves can be accessed directly from Cython via
88

9-
The ``_bit_generator`` module is usable via::
9+
.. code-block:: cython
1010
11-
cimport numpy.random._bit_generator
12-
13-
It provides function pointers for quickly accessing the next bytes in the
14-
`BitGenerator` via a :c:type:`bitgen_t` struct.
15-
16-
The ``_generator`` module is usable via::
17-
18-
cimport numpy.random._generator
19-
20-
It provides low-level functions for various distributions. All the functions
21-
require a ``bitgen_t`` BitGenerator structure.
11+
cimport numpy.random
2212
2313
C API for random
24-
---------------------
14+
----------------
2515

2616
Access to various distributions is available via Cython or C-wrapper libraries
2717
like CFFI. All the functions accept a :c:type:`bitgen_t` as their first argument.
@@ -180,9 +170,9 @@ The functions are named with the following conventions:
180170
181171
.. c:function:: void random_multinomial(bitgen_t *bitgen_state, npy_int64 n, npy_int64 *mnix, double *pix, npy_intp d, binomial_t *binomial)
182172
183-
.. c:function:: int random_mvhg_count(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates)
173+
.. c:function:: int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates)
184174
185-
.. c:function:: void random_mvhg_marginals(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates)
175+
.. c:function:: void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state, npy_int64 total, size_t num_colors, npy_int64 *colors, npy_int64 nsample, size_t num_variates, npy_int64 *variates)
186176
187177
Generate a single integer
188178

doc/source/reference/random/examples/cython/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
.. _extending_cython_example:
3+
24
Extending `numpy.random` via Cython
35
-----------------------------------
46

doc/source/reference/random/extending.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ RNG structure.
4848
:language: cython
4949
:start-after: example 2
5050

51-
These functions along with a minimal setup file are included in the
52-
`examples` folder, ``numpy.random.examples``.
51+
See :ref:`extending_cython_example` for a complete working example including a
52+
minimal setup and cython files.
5353

5454
CFFI
5555
====

numpy/core/include/numpy/random/distributions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ DECLDIR void random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n, RAND_IN
169169
double *pix, npy_intp d, binomial_t *binomial);
170170

171171
/* multivariate hypergeometric, "count" method */
172-
DECLDIR int random_mvhg_count(bitgen_t *bitgen_state,
172+
DECLDIR int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
173173
int64_t total,
174174
size_t num_colors, int64_t *colors,
175175
int64_t nsample,
176176
size_t num_variates, int64_t *variates);
177177

178178
/* multivariate hypergeometric, "marginals" method */
179-
DECLDIR void random_mvhg_marginals(bitgen_t *bitgen_state,
179+
DECLDIR void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
180180
int64_t total,
181181
size_t num_colors, int64_t *colors,
182182
int64_t nsample,

numpy/random/_generator.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ cdef extern from "numpy/random/distributions.h":
124124
void random_multinomial(bitgen_t *bitgen_state, int64_t n, int64_t *mnix,
125125
double *pix, np.npy_intp d, binomial_t *binomial) nogil
126126

127-
int random_mvhg_count(bitgen_t *bitgen_state,
127+
int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
128128
int64_t total,
129129
size_t num_colors, int64_t *colors,
130130
int64_t nsample,
131131
size_t num_variates, int64_t *variates) nogil
132-
void random_mvhg_marginals(bitgen_t *bitgen_state,
132+
void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
133133
int64_t total,
134134
size_t num_colors, int64_t *colors,
135135
int64_t nsample,
@@ -4010,18 +4010,18 @@ cdef class Generator:
40104010

40114011
if method == 'count':
40124012
with self.lock, nogil:
4013-
result = random_mvhg_count(&self._bitgen, total,
4014-
num_colors, colors_ptr, nsamp,
4015-
num_variates, variates_ptr)
4013+
result = random_multivariate_hypergeometric_count(&self._bitgen,
4014+
total, num_colors, colors_ptr, nsamp,
4015+
num_variates, variates_ptr)
40164016
if result == -1:
40174017
raise MemoryError("Insufficent memory for multivariate_"
40184018
"hypergeometric with method='count' and "
40194019
"sum(colors)=%d" % total)
40204020
else:
40214021
with self.lock, nogil:
4022-
random_mvhg_marginals(&self._bitgen, total,
4023-
num_colors, colors_ptr, nsamp,
4024-
num_variates, variates_ptr)
4022+
random_multivariate_hypergeometric_marginals(&self._bitgen,
4023+
total, num_colors, colors_ptr, nsamp,
4024+
num_variates, variates_ptr)
40254025
return variates
40264026

40274027
def dirichlet(self, object alpha, size=None):

numpy/random/src/distributions/random_mvhg_count.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "numpy/random/distributions.h"
66

77
/*
8-
* random_mvhg_count
8+
* random_multivariate_hypergeometric_count
99
*
1010
* Draw variates from the multivariate hypergeometric distribution--
1111
* the "count" algorithm.
@@ -57,7 +57,7 @@
5757
* * the product num_variates * num_colors does not overflow
5858
*/
5959

60-
int random_mvhg_count(bitgen_t *bitgen_state,
60+
int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
6161
int64_t total,
6262
size_t num_colors, int64_t *colors,
6363
int64_t nsample,

numpy/random/src/distributions/random_mvhg_marginals.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
/*
11-
* random_mvhg_marginals
11+
* random_multivariate_hypergeometric_marginals
1212
*
1313
* Draw samples from the multivariate hypergeometric distribution--
1414
* the "marginals" algorithm.
@@ -95,7 +95,7 @@
9595
* * the product num_variates * num_colors does not overflow
9696
*/
9797

98-
void random_mvhg_marginals(bitgen_t *bitgen_state,
98+
void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
9999
int64_t total,
100100
size_t num_colors, int64_t *colors,
101101
int64_t nsample,

0 commit comments

Comments
 (0)
0