Skip to content

Commit 3697d2a

Browse files
Sheppard, KevinSheppard, Kevin
authored andcommitted
TST: Fix fallback entropy test on Windows
1 parent a9667c3 commit 3697d2a

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

randomstate/interface.pyx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ from cython_overrides cimport PyFloat_AsDouble, PyInt_AsLong, PyErr_Occurred, Py
1919

2020
np.import_array()
2121

22-
#cdef extern from "Python.h":
23-
# double PyFloat_AsDouble(object ob)
24-
# long PyInt_AsLong(object ob)
25-
# int PyErr_Occurred()
26-
# void PyErr_Clear()
27-
2822
include "config.pxi"
29-
#include "src/common/binomial.pxi"
3023

3124
IF RNG_MOD_NAME == 'pcg32':
3225
include "shims/pcg-32/pcg-32.pxi"
@@ -56,8 +49,6 @@ cdef extern from "distributions.h":
5649

5750
cdef uint64_t random_uint64(aug_state* state) nogil
5851
cdef uint32_t random_uint32(aug_state* state) nogil
59-
cdef int64_t random_positive_int64(aug_state* state) nogil
60-
cdef int32_t random_positive_int32(aug_state* state) nogil
6152

6253
cdef long random_positive_int(aug_state* state) nogil
6354
cdef unsigned long random_uint(aug_state* state) nogil
@@ -112,9 +103,6 @@ cdef extern from "distributions.h":
112103
cdef void random_bounded_uint8_fill(aug_state *state, uint8_t off, uint8_t rng, int cnt, uint8_t *out) nogil
113104
cdef void random_bool_fill(aug_state *state, int8_t off, int8_t rng, int cnt, int8_t *out) nogil
114105

115-
cdef void entropy_fill(void *dest, size_t size)
116-
cdef bint entropy_getbytes(void* dest, size_t size)
117-
cdef bint entropy_fallback_getbytes(void *dest, size_t size)
118106

119107
include "array_utilities.pxi"
120108
include "bounded_integers.pxi"

randomstate/tests/test_smoke.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
import pickle
23
try:
34
import cPickle
@@ -512,12 +513,19 @@ def test_entropy(self):
512513
e1 = entropy.random_entropy()
513514
e2 = entropy.random_entropy()
514515
assert (e1 != e2)
515-
e1 = entropy.random_entropy(source='fallback')
516-
e2 = entropy.random_entropy(source='fallback')
517-
assert (e1 != e2)
518516
e1 = entropy.random_entropy(10)
519517
e2 = entropy.random_entropy(10)
520518
assert (e1 != e2).all()
519+
e1 = entropy.random_entropy(10, source='system')
520+
e2 = entropy.random_entropy(10, source='system')
521+
assert (e1 != e2).all()
522+
523+
def test_fallback(self):
524+
e1 = entropy.random_entropy(source='fallback')
525+
time.sleep(0.1)
526+
e2 = entropy.random_entropy(source='fallback')
527+
assert (e1 != e2)
528+
521529

522530

523531

0 commit comments

Comments
 (0)