@@ -23,28 +23,29 @@ from cython_overrides cimport PyFloat_AsDouble, PyInt_AsLong, PyErr_Occurred, Py
2323np .import_array ()
2424
2525include "config.pxi"
26+ include "defaults.pxi"
2627
27- IF RNG_MOD_NAME == 'pcg32' :
28+ IF RS_RNG_MOD_NAME == 'pcg32' :
2829 include "shims/pcg-32/pcg-32.pxi"
29- IF RNG_MOD_NAME == 'pcg64' :
30- IF PCG128_EMULATED :
30+ IF RS_RNG_MOD_NAME == 'pcg64' :
31+ IF RS_PCG128_EMULATED :
3132 include "shims/pcg-64/pcg-64-emulated.pxi"
3233 ELSE :
3334 include "shims/pcg-64/pcg-64.pxi"
34- IF RNG_MOD_NAME == 'mt19937' :
35+ IF RS_RNG_MOD_NAME == 'mt19937' :
3536 include "shims/random-kit/random-kit.pxi"
36- IF RNG_MOD_NAME == 'xorshift128' :
37+ IF RS_RNG_MOD_NAME == 'xorshift128' :
3738 include "shims/xorshift128/xorshift128.pxi"
38- IF RNG_MOD_NAME == 'xorshift1024' :
39+ IF RS_RNG_MOD_NAME == 'xorshift1024' :
3940 include "shims/xorshift1024/xorshift1024.pxi"
40- IF RNG_MOD_NAME == 'mrg32k3a' :
41+ IF RS_RNG_MOD_NAME == 'mrg32k3a' :
4142 include "shims/mrg32k3a/mrg32k3a.pxi"
42- IF RNG_MOD_NAME == 'mlfg_1279_861' :
43+ IF RS_RNG_MOD_NAME == 'mlfg_1279_861' :
4344 include "shims/mlfg-1279-861/mlfg-1279-861.pxi"
44- IF RNG_MOD_NAME == 'dsfmt' :
45+ IF RS_RNG_MOD_NAME == 'dsfmt' :
4546 include "shims/dSFMT/dSFMT.pxi"
4647
47- IF NORMAL_METHOD == 'inv' :
48+ IF RS_NORMAL_METHOD == 'inv' :
4849 __normal_method = 'inv'
4950ELSE :
5051 __normal_method = 'zig'
@@ -139,11 +140,11 @@ cdef class RandomState:
139140 poisson_lam_max = POISSON_LAM_MAX
140141 __MAXSIZE = < uint64_t > sys .maxsize
141142
142- IF RNG_SEED == 1 :
143+ IF RS_RNG_SEED == 1 :
143144 def __init__ (self , seed = None ):
144145 self .rng_state .rng = < rng_t * > PyArray_malloc_aligned (sizeof (rng_t ))
145146 self .rng_state .binomial = & self .binomial_info
146- IF RNG_MOD_NAME == 'dsfmt' :
147+ IF RS_RNG_MOD_NAME == 'dsfmt' :
147148 self .rng_state .buffered_uniforms = < double * > PyArray_malloc_aligned (2 * DSFMT_N * sizeof (double ))
148149 self .lock = Lock ()
149150 self ._reset_state_variables ()
@@ -158,7 +159,7 @@ cdef class RandomState:
158159
159160 def __dealloc__ (self ):
160161 PyArray_free_aligned (self .rng_state .rng )
161- IF RNG_MOD_NAME == 'dsfmt' :
162+ IF RS_RNG_MOD_NAME == 'dsfmt' :
162163 PyArray_free_aligned (self .rng_state .buffered_uniforms )
163164
164165 # Pickling support:
@@ -169,9 +170,9 @@ cdef class RandomState:
169170 self .set_state (state )
170171
171172 def __reduce__ (self ):
172- return (randomstate .prng .__generic_ctor , (RNG_MOD_NAME ,), self .get_state ())
173+ return (randomstate .prng .__generic_ctor , (RS_RNG_MOD_NAME ,), self .get_state ())
173174
174- IF RNG_NAME == 'mt19937' :
175+ IF RS_RNG_NAME == 'mt19937' :
175176 def seed (self , seed = None ):
176177 """
177178 seed(seed=None)
@@ -212,7 +213,7 @@ cdef class RandomState:
212213 set_seed_by_array (& self .rng_state , < unsigned long * > np .PyArray_DATA (obj ), np .PyArray_DIM (obj , 0 ))
213214 self ._reset_state_variables ()
214215
215- ELIF RNG_SEED == 1 :
216+ ELIF RS_RNG_SEED == 1 :
216217 def seed (self , val = None ):
217218 """
218219 seed(seed=None)
@@ -272,8 +273,8 @@ cdef class RandomState:
272273 raise ValueError ('val < 0' )
273274 if inc < 0 :
274275 raise ValueError ('inc < 0' )
275- IF RNG_NAME == 'pcg64' :
276- IF PCG128_EMULATED :
276+ IF RS_RNG_NAME == 'pcg64' :
277+ IF RS_PCG128_EMULATED :
277278 set_seed (& self .rng_state ,
278279 pcg128_from_pylong (val ),
279280 pcg128_from_pylong (inc ))
@@ -292,7 +293,7 @@ cdef class RandomState:
292293 self .rng_state .uinteger = 0
293294 self .rng_state .binomial .has_binomial = 0
294295
295- IF RNG_ADVANCEABLE :
296+ IF RS_RNG_ADVANCEABLE :
296297 def advance (self , delta ):
297298 """
298299 advance(delta)
@@ -314,8 +315,8 @@ cdef class RandomState:
314315 Advancing the prng state resets any pre-computed random numbers.
315316 This is required to ensure exact reproducibility.
316317 """
317- IF RNG_NAME == 'pcg64' :
318- IF PCG128_EMULATED :
318+ IF RS_RNG_NAME == 'pcg64' :
319+ IF RS_PCG128_EMULATED :
319320 advance_state (& self .rng_state , pcg128_from_pylong (delta ))
320321 ELSE :
321322 advance_state (& self .rng_state , delta )
@@ -326,7 +327,7 @@ cdef class RandomState:
326327 self .rng_state .gauss = 0.0
327328 return None
328329
329- IF RNG_JUMPABLE :
330+ IF RS_RNG_JUMPABLE :
330331 def jump (self , uint32_t iter = 1 ):
331332 """
332333 jump(iter = 1)
@@ -356,7 +357,7 @@ cdef class RandomState:
356357 self .rng_state .gauss = 0.0
357358 return None
358359
359- IF RNG_NAME == 'mt19937' :
360+ IF RS_RNG_NAME == 'mt19937' :
360361 def get_state (self , legacy = False ):
361362 """
362363 get_state()
@@ -394,11 +395,11 @@ cdef class RandomState:
394395 component, see the class documentation.
395396 """
396397 if legacy :
397- return (RNG_NAME ,) \
398+ return (RS_RNG_NAME ,) \
398399 + _get_state (self .rng_state ) \
399400 + (self .rng_state .has_gauss , self .rng_state .gauss )
400401
401- return {'name' : RNG_NAME ,
402+ return {'name' : RS_RNG_NAME ,
402403 'state' : _get_state (self .rng_state ),
403404 'gauss' : {'has_gauss' : self .rng_state .has_gauss , 'gauss' : self .rng_state .gauss },
404405 'uint32' : {'has_uint32' : self .rng_state .has_uint32 , 'uint32' : self .rng_state .uinteger }
@@ -435,7 +436,7 @@ cdef class RandomState:
435436 For information about the specific structure of the PRNG-specific
436437 component, see the class documentation.
437438 """
438- return {'name' : RNG_NAME ,
439+ return {'name' : RS_RNG_NAME ,
439440 'state' : _get_state (self .rng_state ),
440441 'gauss' : {'has_gauss' : self .rng_state .has_gauss , 'gauss' : self .rng_state .gauss },
441442 'uint32' : {'has_uint32' : self .rng_state .has_uint32 , 'uint32' : self .rng_state .uinteger }
@@ -478,8 +479,8 @@ cdef class RandomState:
478479 For information about the specific structure of the PRNG-specific
479480 component, see the class documentation.
480481 """
481- rng_name = RNG_NAME
482- IF RNG_NAME == 'mt19937' :
482+ rng_name = RS_RNG_NAME
483+ IF RS_RNG_NAME == 'mt19937' :
483484 if isinstance (state , tuple ):
484485 if state [0 ] != 'MT19937' :
485486 raise ValueError ('Not a ' + rng_name + ' RNG state' )
@@ -4227,7 +4228,7 @@ permutation = _rand.permutation
42274228
42284229sample = ranf = random = random_sample
42294230
4230- IF RNG_JUMPABLE :
4231+ IF RS_RNG_JUMPABLE :
42314232 jump = _rand .jump
4232- IF RNG_ADVANCEABLE :
4233+ IF RS_RNG_ADVANCEABLE :
42334234 advance = _rand .advance
0 commit comments