@@ -20,10 +20,24 @@ class TestRecord(unittest.TestCase):
20
20
21
21
"""
22
22
23
-
24
- wrsamp_params = ['record_name' , 'fs' , 'units' , 'sig_name' , 'p_signal' , 'd_signal' , 'e_p_signal' , 'e_d_signal' ,
25
- 'samps_per_frame' , 'fmt' , 'adc_gain' , 'baseline' , 'comments' , 'base_time' , 'base_date' ,
26
- 'base_datetime' ]
23
+ wrsamp_params = [
24
+ "record_name" ,
25
+ "fs" ,
26
+ "units" ,
27
+ "sig_name" ,
28
+ "p_signal" ,
29
+ "d_signal" ,
30
+ "e_p_signal" ,
31
+ "e_d_signal" ,
32
+ "samps_per_frame" ,
33
+ "fmt" ,
34
+ "adc_gain" ,
35
+ "baseline" ,
36
+ "comments" ,
37
+ "base_time" ,
38
+ "base_date" ,
39
+ "base_datetime" ,
40
+ ]
27
41
28
42
# ----------------------- 1. Basic Tests -----------------------#
29
43
@@ -303,11 +317,24 @@ def test_unique_samps_per_frame_e_p_signal(self):
303
317
)
304
318
305
319
# Write the signals
306
- wfdb .io .wrsamp ('mixedsignals' , fs = record .fs , units = record .units , sig_name = record .sig_name ,
307
- base_date = record .base_date , base_time = record .base_time , comments = record .comments ,
308
- p_signal = record .p_signal , d_signal = record .d_signal , e_p_signal = record .e_p_signal ,
309
- e_d_signal = record .e_d_signal , samps_per_frame = record .samps_per_frame , baseline = record .baseline ,
310
- adc_gain = record .adc_gain , fmt = record .fmt , write_dir = self .temp_path )
320
+ wfdb .io .wrsamp (
321
+ "mixedsignals" ,
322
+ fs = record .fs ,
323
+ units = record .units ,
324
+ sig_name = record .sig_name ,
325
+ base_date = record .base_date ,
326
+ base_time = record .base_time ,
327
+ comments = record .comments ,
328
+ p_signal = record .p_signal ,
329
+ d_signal = record .d_signal ,
330
+ e_p_signal = record .e_p_signal ,
331
+ e_d_signal = record .e_d_signal ,
332
+ samps_per_frame = record .samps_per_frame ,
333
+ baseline = record .baseline ,
334
+ adc_gain = record .adc_gain ,
335
+ fmt = record .fmt ,
336
+ write_dir = self .temp_path ,
337
+ )
311
338
312
339
# Check that the written record matches the original
313
340
# Read in the original and written records
@@ -320,24 +347,40 @@ def test_unique_samps_per_frame_e_p_signal(self):
320
347
# Check that the signals match
321
348
for n , name in enumerate (record .sig_name ):
322
349
np .testing .assert_array_equal (
323
- record .e_p_signal [n ], record_write .e_p_signal [n ], f"Mismatch in { name } "
350
+ record .e_p_signal [n ],
351
+ record_write .e_p_signal [n ],
352
+ f"Mismatch in { name } " ,
324
353
)
325
354
326
355
# Filter out the signal
327
356
record_filtered = {
328
357
k : getattr (record , k )
329
358
for k in self .wrsamp_params
330
- if not (isinstance (getattr (record , k ), np .ndarray ) or
331
- (isinstance (getattr (record , k ), list ) and all (
332
- isinstance (item , np .ndarray ) for item in getattr (record , k ))))
359
+ if not (
360
+ isinstance (getattr (record , k ), np .ndarray )
361
+ or (
362
+ isinstance (getattr (record , k ), list )
363
+ and all (
364
+ isinstance (item , np .ndarray )
365
+ for item in getattr (record , k )
366
+ )
367
+ )
368
+ )
333
369
}
334
370
335
371
record_write_filtered = {
336
372
k : getattr (record_write , k )
337
373
for k in self .wrsamp_params
338
- if not (isinstance (getattr (record_write , k ), np .ndarray ) or
339
- (isinstance (getattr (record_write , k ), list ) and all (
340
- isinstance (item , np .ndarray ) for item in getattr (record_write , k ))))
374
+ if not (
375
+ isinstance (getattr (record_write , k ), np .ndarray )
376
+ or (
377
+ isinstance (getattr (record_write , k ), list )
378
+ and all (
379
+ isinstance (item , np .ndarray )
380
+ for item in getattr (record_write , k )
381
+ )
382
+ )
383
+ )
341
384
}
342
385
343
386
# Check that the arguments beyond the signals also match
@@ -356,15 +399,30 @@ def test_unique_samps_per_frame_e_d_signal(self):
356
399
)
357
400
358
401
# Write the signals
359
- wfdb .io .wrsamp ('mixedsignals' , fs = record .fs , units = record .units , sig_name = record .sig_name ,
360
- base_date = record .base_date , base_time = record .base_time , comments = record .comments ,
361
- p_signal = record .p_signal , d_signal = record .d_signal , e_p_signal = record .e_p_signal ,
362
- e_d_signal = record .e_d_signal , samps_per_frame = record .samps_per_frame , baseline = record .baseline ,
363
- adc_gain = record .adc_gain , fmt = record .fmt , write_dir = self .temp_path )
402
+ wfdb .io .wrsamp (
403
+ "mixedsignals" ,
404
+ fs = record .fs ,
405
+ units = record .units ,
406
+ sig_name = record .sig_name ,
407
+ base_date = record .base_date ,
408
+ base_time = record .base_time ,
409
+ comments = record .comments ,
410
+ p_signal = record .p_signal ,
411
+ d_signal = record .d_signal ,
412
+ e_p_signal = record .e_p_signal ,
413
+ e_d_signal = record .e_d_signal ,
414
+ samps_per_frame = record .samps_per_frame ,
415
+ baseline = record .baseline ,
416
+ adc_gain = record .adc_gain ,
417
+ fmt = record .fmt ,
418
+ write_dir = self .temp_path ,
419
+ )
364
420
365
421
# Check that the written record matches the original
366
422
# Read in the original and written records
367
- record = wfdb .rdrecord ("sample-data/mixedsignals" , physical = False , smooth_frames = False )
423
+ record = wfdb .rdrecord (
424
+ "sample-data/mixedsignals" , physical = False , smooth_frames = False
425
+ )
368
426
record_write = wfdb .rdrecord (
369
427
os .path .join (self .temp_path , "mixedsignals" ),
370
428
physical = False ,
@@ -374,24 +432,40 @@ def test_unique_samps_per_frame_e_d_signal(self):
374
432
# Check that the signals match
375
433
for n , name in enumerate (record .sig_name ):
376
434
np .testing .assert_array_equal (
377
- record .e_d_signal [n ], record_write .e_d_signal [n ], f"Mismatch in { name } "
435
+ record .e_d_signal [n ],
436
+ record_write .e_d_signal [n ],
437
+ f"Mismatch in { name } " ,
378
438
)
379
439
380
440
# Filter out the signal
381
441
record_filtered = {
382
442
k : getattr (record , k )
383
443
for k in self .wrsamp_params
384
- if not (isinstance (getattr (record , k ), np .ndarray ) or
385
- (isinstance (getattr (record , k ), list ) and all (
386
- isinstance (item , np .ndarray ) for item in getattr (record , k ))))
444
+ if not (
445
+ isinstance (getattr (record , k ), np .ndarray )
446
+ or (
447
+ isinstance (getattr (record , k ), list )
448
+ and all (
449
+ isinstance (item , np .ndarray )
450
+ for item in getattr (record , k )
451
+ )
452
+ )
453
+ )
387
454
}
388
455
389
456
record_write_filtered = {
390
457
k : getattr (record_write , k )
391
458
for k in self .wrsamp_params
392
- if not (isinstance (getattr (record_write , k ), np .ndarray ) or
393
- (isinstance (getattr (record_write , k ), list ) and all (
394
- isinstance (item , np .ndarray ) for item in getattr (record_write , k ))))
459
+ if not (
460
+ isinstance (getattr (record_write , k ), np .ndarray )
461
+ or (
462
+ isinstance (getattr (record_write , k ), list )
463
+ and all (
464
+ isinstance (item , np .ndarray )
465
+ for item in getattr (record_write , k )
466
+ )
467
+ )
468
+ )
395
469
}
396
470
397
471
# Check that the arguments beyond the signals also match
0 commit comments