@@ -230,27 +230,28 @@ def test_detect_lines():
230
230
"""
231
231
Tests detect_lines utility in the reliable low-SNR scenario.
232
232
"""
233
- rng = np .random .RandomState (0 )
233
+ np .random .seed (0 )
234
+
234
235
N = 1000
235
236
fft_pow = int ( np .ceil (np .log2 (N ) + 2 ) )
236
237
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 ,)))
238
239
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 ,)))
240
241
lines = lines .astype ('d' )
241
- #lines += rng .randn(3) # displace from grid locations
242
+ #lines += np.random .randn(3) # displace from grid locations
242
243
lines /= 2.0 ** (fft_pow - 2 ) # ensure they are well separated
243
244
244
- phs = rng .rand (3 ) * 2 * np .pi
245
+ phs = np . random .rand (3 ) * 2 * np .pi
245
246
# 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 ) )
247
248
248
249
nz_sig = 0.05
249
250
tx = np .arange (N )
250
251
251
252
harmonics = amps [:,None ]* np .cos ( 2 * np .pi * tx * lines [:,None ] + phs [:,None ] )
252
253
harmonic = np .sum (harmonics , axis = 0 )
253
- nz = rng .randn (N ) * nz_sig
254
+ nz = np . random .randn (N ) * nz_sig
254
255
sig = harmonic + nz
255
256
256
257
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():
287
288
Test multi-sequence operation
288
289
"""
289
290
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 )
291
294
292
295
N = 1000
293
296
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
295
298
296
299
sig2d = np .vstack ( (sig , sig , sig ) )
297
300
0 commit comments