Skip to content

Commit bcc26a6

Browse files
committed
Implement mkl_random.interfaces
Slips in changes updating get_state, set_state, and multivariate_normal to align with recent numpy changes
1 parent 77466f9 commit bcc26a6

9 files changed

Lines changed: 1513 additions & 508 deletions

File tree

mkl_random/__init__.py

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,58 @@
2828

2929
from . import _init_helper
3030

31-
from .mklrand import *
31+
from .mklrand import (
32+
MKLRandomState,
33+
RandomState,
34+
seed,
35+
get_state,
36+
set_state,
37+
random_sample,
38+
choice,
39+
randint,
40+
bytes,
41+
uniform,
42+
rand,
43+
randn,
44+
random_integers,
45+
standard_normal,
46+
normal,
47+
beta,
48+
exponential,
49+
standard_exponential,
50+
standard_gamma,
51+
gamma,
52+
f,
53+
noncentral_f,
54+
chisquare,
55+
noncentral_chisquare,
56+
standard_cauchy,
57+
standard_t,
58+
vonmises,
59+
pareto,
60+
weibull,
61+
power,
62+
laplace,
63+
gumbel,
64+
logistic,
65+
lognormal,
66+
rayleigh,
67+
wald,
68+
triangular,
69+
binomial,
70+
negative_binomial,
71+
poisson,
72+
zipf,
73+
geometric,
74+
hypergeometric,
75+
logseries,
76+
multivariate_normal,
77+
multinormal_cholesky,
78+
multinomial,
79+
dirichlet,
80+
shuffle,
81+
permutation,
82+
)
3283
from ._version import __version__
3384

3485
try:
@@ -42,4 +93,60 @@
4293
test = PytestTester(__name__)
4394
del PytestTester
4495

96+
import mkl_random.interfaces
97+
98+
__all__ = [
99+
"MKLRandomState",
100+
"RandomState",
101+
"seed",
102+
"get_state",
103+
"set_state",
104+
"random_sample",
105+
"choice",
106+
"randint",
107+
"bytes",
108+
"uniform",
109+
"rand",
110+
"randn",
111+
"random_integers",
112+
"standard_normal",
113+
"normal",
114+
"beta",
115+
"exponential",
116+
"standard_exponential",
117+
"standard_gamma",
118+
"gamma",
119+
"f",
120+
"noncentral_f",
121+
"chisquare",
122+
"noncentral_chisquare",
123+
"standard_cauchy",
124+
"standard_t",
125+
"vonmises",
126+
"pareto",
127+
"weibull",
128+
"power",
129+
"laplace",
130+
"gumbel",
131+
"logistic",
132+
"lognormal",
133+
"rayleigh",
134+
"wald",
135+
"triangular",
136+
"binomial",
137+
"negative_binomial",
138+
"poisson",
139+
"zipf",
140+
"geometric",
141+
"hypergeometric",
142+
"logseries",
143+
"multivariate_normal",
144+
"multinormal_cholesky",
145+
"multinomial",
146+
"dirichlet",
147+
"shuffle",
148+
"permutation",
149+
"interfaces",
150+
]
151+
45152
del _init_helper

mkl_random/interfaces/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Interfaces
2+
The `mkl_random` package provides interfaces that serve as drop-in replacements for equivalent functions in NumPy.
3+
4+
---
5+
6+
## NumPy interface - `mkl_random.interfaces.numpy_random`
7+
8+
This interface is a drop-in replacement for the legacy portion of the [`numpy.random`](https://numpy.org/devdocs/reference/random/legacy.html) module and includes **all** classes and functions available there:
9+
10+
* random generator: `RandomState`.
11+
12+
* seeding and state functions: `get_state`, `set_state`, and `seed`.
13+
14+
* simple random data: `rand`, `randn`, `randint`, `random_integers`, `random_sample`, `choice` and `bytes`.
15+
16+
* permutations: `shuffle` and `permutation`
17+
18+
* distributions: `beta`, `binomial`, `chisquare`, `dirichlet`, `exponential`, `f`, `gamma`, `geometric`, `gumbel`, `hypergeometric`, `laplace`, `logistic`, `lognormal`, `multinomial`, `multivariate_normal`, `negative_binomial`, `noncentral_chisquare`, `noncentral_f`, `normal`, `pareto`, `poisson`, `power`, `rayleigh`, `standard_cauchy`, `standard_exponential`, `standard_gamma`, `standard_normal`, `standard_t`, `triangular`, `uniform`, `vonmises`, `wald`, `weibull`, and `zipf`.

mkl_random/interfaces/__init__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) 2017, Intel Corporation
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
# * Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
# * Neither the name of Intel Corporation nor the names of its contributors
13+
# may be used to endorse or promote products derived from this software
14+
# without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
from . import numpy_random

0 commit comments

Comments
 (0)