@@ -20,10 +20,24 @@ class TestRecord(unittest.TestCase):
2020
2121 """
2222
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+ ]
2741
2842 # ----------------------- 1. Basic Tests -----------------------#
2943
@@ -303,11 +317,24 @@ def test_unique_samps_per_frame_e_p_signal(self):
303317 )
304318
305319 # 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+ )
311338
312339 # Check that the written record matches the original
313340 # Read in the original and written records
@@ -320,24 +347,40 @@ def test_unique_samps_per_frame_e_p_signal(self):
320347 # Check that the signals match
321348 for n , name in enumerate (record .sig_name ):
322349 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 } " ,
324353 )
325354
326355 # Filter out the signal
327356 record_filtered = {
328357 k : getattr (record , k )
329358 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+ )
333369 }
334370
335371 record_write_filtered = {
336372 k : getattr (record_write , k )
337373 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+ )
341384 }
342385
343386 # Check that the arguments beyond the signals also match
@@ -356,15 +399,30 @@ def test_unique_samps_per_frame_e_d_signal(self):
356399 )
357400
358401 # 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+ )
364420
365421 # Check that the written record matches the original
366422 # 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+ )
368426 record_write = wfdb .rdrecord (
369427 os .path .join (self .temp_path , "mixedsignals" ),
370428 physical = False ,
@@ -374,24 +432,40 @@ def test_unique_samps_per_frame_e_d_signal(self):
374432 # Check that the signals match
375433 for n , name in enumerate (record .sig_name ):
376434 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 } " ,
378438 )
379439
380440 # Filter out the signal
381441 record_filtered = {
382442 k : getattr (record , k )
383443 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+ )
387454 }
388455
389456 record_write_filtered = {
390457 k : getattr (record_write , k )
391458 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+ )
395469 }
396470
397471 # Check that the arguments beyond the signals also match
0 commit comments