8000 MAINT: remove the entropy c-extension module · numpy/numpy@fb83476 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb83476

Browse files
mattipcharris
authored andcommitted
MAINT: remove the entropy c-extension module
1 parent 706deec commit fb83476

File tree

7 files changed

+5
-320
lines changed

7 files changed

+5
-320
lines changed

numpy/random/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181
from . import _pickle
182182
from . import common
183183
from . import bounded_integers
184-
from . import entropy
185184

186185
from .mtrand import *
187186
from .generator import Generator, default_rng

numpy/random/entropy.pyx

Lines changed: 0 additions & 155 deletions
This file was deleted.

numpy/random/mt19937.pyx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ cimport numpy as np
55

66
from .common cimport *
77
from .bit_generator cimport BitGenerator, SeedSequence
8-
from .entropy import random_entropy
98

109
__all__ = ['MT19937']
1110

@@ -156,7 +155,8 @@ cdef class MT19937(BitGenerator):
156155
Random seed initializing the pseudo-random number generator.
157156
Can be an integer in [0, 2**32-1], array of integers in
158157
[0, 2**32-1], a `SeedSequence, or ``None``. If `seed`
159-
is ``None``, then sample entropy for a seed.
158+
is ``None``, then fresh, unpredictable entropy will be pulled from
159+
the OS.
160160
161161
Raises
162162
------
@@ -167,7 +167,8 @@ cdef class MT19937(BitGenerator):
167167
with self.lock:
168168
try:
169169
if seed is None:
170-
val = random_entropy(RK_STATE_LEN)
170+
seed = SeedSequence()
171+
val = seed.generate_state(RK_STATE_LEN)
171172
# MSB is 1; assuring non-zero initial array
172173
self.rng_state.key[0] = 0x80000000UL
173174
for i in range(1, RK_STATE_LEN):

numpy/random/setup.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,6 @@ def generate_libraries(ext, build_dir):
6161
# One can force emulated 128-bit arithmetic if one wants.
6262
#PCG64_DEFS += [('PCG_FORCE_EMULATED_128BIT_MATH', '1')]
6363

64-
config.add_extension('entropy',
65-
sources=['entropy.c', 'src/entropy/entropy.c'] +
66-
[generate_libraries],
67-
libraries=EXTRA_LIBRARIES,
68-
extra_compile_args=EXTRA_COMPILE_ARGS,
69-
extra_link_args=EXTRA_LINK_ARGS,
70-
depends=[join('src', 'splitmix64', 'splitmix.h'),
71-
join('src', 'entropy', 'entropy.h'),
72-
'entropy.pyx',
73-
],
74-
define_macros=defs,
75-
)
7664
for gen in ['mt19937']:
7765
# gen.pyx, src/gen/gen.c, src/gen/gen-jump.c
7866
config.add_extension(gen,

numpy/random/src/entropy/entropy.c

Lines changed: 0 additions & 114 deletions
This file was deleted.

numpy/random/src/entropy/entropy.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

numpy/random/tests/test_smoke.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77
from numpy.testing import assert_equal, assert_, assert_array_equal
8-
from numpy.random import (Generator, MT19937, PCG64, Philox, SFC64, entropy)
8+
from numpy.random import (Generator, MT19937, PCG64, Philox, SFC64)
99

1010
@pytest.fixture(scope='module',
1111
params=(np.bool, np.int8, np.int16, np.int32, np.int64,
@@ -806,23 +806,3 @@ def test_seed(self):
806806
np.random.default_rng(-1)
807807
with pytest.raises(ValueError):
808808
np.random.default_rng([12345, -1])
809-
810-
811-
class TestEntropy(object):
812-
def test_entropy(self):
813-
e1 = entropy.random_entropy()
814-
e2 = entropy.random_entropy()
815-
assert_((e1 != e2))
816-
e1 = entropy.random_entropy(10)
817-
e2 = entropy.random_entropy(10)
818-
assert_((e1 != e2).all())
819-
e1 = entropy.random_entropy(10, source='system')
820-
e2 = entropy.random_entropy(10, source='system')
821-
assert_((e1 != e2).all())
822-
823-
def test_fallback(self):
824-
e1 = entropy.random_entropy(source='fallback')
825-
time.sleep(0.1)
826-
e2 = entropy.random_entropy(source='fallback')
827-
assert_((e1 != e2))
828-

0 commit comments

Comments
 (0)
0