Skip to content

Commit 1509aab

Browse files
committed
Merge pull request #16 from bashtage/double-fill
Double fill
2 parents 74573bf + 7ca40cc commit 1509aab

File tree

6 files changed

+422
-288
lines changed

6 files changed

+422
-288
lines changed

appveyor.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ build_script:
1818
- SET PATH=C:\Py;C:\Py\Scripts;C:\Py\Library\bin;%PATH%
1919
- conda config --set always_yes yes
2020
- conda update conda --quiet
21-
- conda install numpy cython nose --quiet
21+
- conda install numpy cython nose pandas --quiet
2222
- pip install . -vvv
23+
- set "GIT_DIR=%cd%"
2324

2425
test_script:
2526
- cd ..
26-
- nosetests randomstate
27+
- nosetests randomstate
28+
29+
on_success:
30+
- cd %GIT_DIR%\randomstate
31+
- IF %PYTHON_ARCH%==x86_64 python performance.py

randomstate/array_utilities.pxi

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ ctypedef uint32_t (* random_uint_1_i_32)(aug_state* state, uint32_t a) nogil
1616
ctypedef int32_t (* random_int_2_i_32)(aug_state* state, int32_t a, int32_t b) nogil
1717
ctypedef int64_t (* random_int_2_i)(aug_state* state, int64_t a, int64_t b) nogil
1818

19+
ctypedef void (* random_double_fill)(aug_state* state, int count, double *out) nogil
20+
1921
cdef Py_ssize_t compute_numel(size):
2022
cdef Py_ssize_t i, n = 1
2123
if isinstance(size, tuple):
@@ -568,3 +570,20 @@ cdef object disc(aug_state* state, void* func, object size, object lock,
568570
randoms[i] = fiii(state, _ia, _ib, _ic)
569571

570572
return np.asarray(randoms).reshape(size)
573+
574+
575+
cdef object double_fill(aug_state* state, void *func, object size, object lock):
576+
cdef random_double_fill f = <random_double_fill>func
577+
cdef double out
578+
cdef double [::1] out_array
579+
cdef Py_ssize_t n
580+
if size is None:
581+
with lock:
582+
f(state, 1, &out)
583+
return out
584+
else:
585+
n = compute_numel(size)
586+
out_array = np.empty(n, np.double)
587+
with lock, nogil:
588+
f(state, n, &out_array[0])
589+
return np.asarray(out_array).reshape(size)

0 commit comments

Comments
 (0)