Skip to content

Commit 5f5fae5

Browse files
committed
FIX: Seed directly [build wheels]
1 parent e7ba859 commit 5f5fae5

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

nitime/tests/test_utils.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,28 @@ def test_detect_lines():
230230
"""
231231
Tests detect_lines utility in the reliable low-SNR scenario.
232232
"""
233-
rng = np.random.RandomState(0)
233+
np.random.seed(0)
234+
234235
N = 1000
235236
fft_pow = int( np.ceil(np.log2(N) + 2) )
236237
NW = 4
237-
lines = np.sort(rng.randint(100, 2**(fft_pow-4), size=(3,)))
238+
lines = np.sort(np.random.randint(100, 2**(fft_pow-4), size=(3,)))
238239
while np.any( np.diff(lines) < 2*NW ):
239-
lines = np.sort(rng.randint(2**(fft_pow-4), size=(3,)))
240+
lines = np.sort(np.random.randint(2**(fft_pow-4), size=(3,)))
240241
lines = lines.astype('d')
241-
#lines += rng.randn(3) # displace from grid locations
242+
#lines += np.random.randn(3) # displace from grid locations
242243
lines /= 2.0**(fft_pow-2) # ensure they are well separated
243244

244-
phs = rng.rand(3) * 2 * np.pi
245+
phs = np.random.rand(3) * 2 * np.pi
245246
# amps approximately such that RMS power = 1 +/- N(0,1)
246-
amps = np.sqrt(2)/2 + np.abs( rng.randn(3) )
247+
amps = np.sqrt(2)/2 + np.abs( np.random.randn(3) )
247248

248249
nz_sig = 0.05
249250
tx = np.arange(N)
250251

251252
harmonics = amps[:,None]*np.cos( 2*np.pi*tx*lines[:,None] + phs[:,None] )
252253
harmonic = np.sum(harmonics, axis=0)
253-
nz = rng.randn(N) * nz_sig
254+
nz = np.random.randn(N) * nz_sig
254255
sig = harmonic + nz
255256

256257
f, b = utils.detect_lines(sig, (NW, 2*NW), low_bias=True, NFFT=2**fft_pow)
@@ -287,11 +288,13 @@ def test_detect_lines_2dmode():
287288
Test multi-sequence operation
288289
"""
289290

290-
rng = np.random.RandomState(0)
291+
# This seed affects not just the signal we generate below, but then also
292+
# detect_lines->dpss_windows->tridi_inverse_iteration
293+
np.random.seed(0)
291294

292295
N = 1000
293296

294-
sig = np.cos( 2*np.pi*np.arange(N) * 20./N ) + rng.randn(N) * .01
297+
sig = np.cos( 2*np.pi*np.arange(N) * 20./N ) + np.random.randn(N) * .01
295298

296299
sig2d = np.vstack( (sig, sig, sig) )
297300

0 commit comments

Comments
 (0)