@@ -230,26 +230,27 @@ 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
234
N = 1000
234
235
fft_pow = int ( np .ceil (np .log2 (N ) + 2 ) )
235
236
NW = 4
236
- lines = np .sort (np . random .randint (100 , 2 ** (fft_pow - 4 ), size = (3 ,)))
237
+ lines = np .sort (rng .randint (100 , 2 ** (fft_pow - 4 ), size = (3 ,)))
237
238
while np .any ( np .diff (lines ) < 2 * NW ):
238
- lines = np .sort (np . random .randint (2 ** (fft_pow - 4 ), size = (3 ,)))
239
+ lines = np .sort (rng .randint (2 ** (fft_pow - 4 ), size = (3 ,)))
239
240
lines = lines .astype ('d' )
240
- #lines += np.random .randn(3) # displace from grid locations
241
+ #lines += rng .randn(3) # displace from grid locations
241
242
lines /= 2.0 ** (fft_pow - 2 ) # ensure they are well separated
242
243
243
- phs = np . random .rand (3 ) * 2 * np .pi
244
+ phs = rng .rand (3 ) * 2 * np .pi
244
245
# amps approximately such that RMS power = 1 +/- N(0,1)
245
- amps = np .sqrt (2 )/ 2 + np .abs ( np . random .randn (3 ) )
246
+ amps = np .sqrt (2 )/ 2 + np .abs ( rng .randn (3 ) )
246
247
247
248
nz_sig = 0.05
248
249
tx = np .arange (N )
249
250
250
251
harmonics = amps [:,None ]* np .cos ( 2 * np .pi * tx * lines [:,None ] + phs [:,None ] )
251
252
harmonic = np .sum (harmonics , axis = 0 )
252
- nz = np . random .randn (N ) * nz_sig
253
+ nz = rng .randn (N ) * nz_sig
253
254
sig = harmonic + nz
254
255
255
256
f , b = utils .detect_lines (sig , (NW , 2 * NW ), low_bias = True , NFFT = 2 ** fft_pow )
@@ -286,11 +287,13 @@ def test_detect_lines_2dmode():
286
287
Test multi-sequence operation
287
288
"""
288
289
290
+ rng = np .random .RandomState (0 )
291
+
289
292
N = 1000
290
293
291
- sig = np .cos ( 2 * np .pi * np .arange (N ) * 20. / N ) + np . random .randn (N ) * .01
294
+ sig = np .cos ( 2 * np .pi * np .arange (N ) * 20. / N ) + rng .randn (N ) * .01
292
295
293
- sig2d = np .row_stack ( (sig , sig , sig ) )
296
+ sig2d = np .vstack ( (sig , sig , sig ) )
294
297
295
298
lines = utils .detect_lines (sig2d , (4 , 8 ), low_bias = True , NFFT = 2 ** 12 )
296
299
0 commit comments