11import datetime
22import multiprocessing .dummy
3- import posixpath
43import os
4+ import posixpath
55import re
66
77import fsspec
88import numpy as np
99import pandas as pd
1010
11- from wfdb .io import _header
12- from wfdb .io import _signal
13- from wfdb .io import _url
14- from wfdb .io .archive import get_archive
15- from wfdb .io import download
16- from wfdb .io import header
17- from wfdb .io import util
11+ from wfdb .io import _header , _signal , _url , download , header , util
1812from wfdb .io ._coreio import CLOUD_PROTOCOLS
19-
13+ from wfdb . io . archive import get_archive
2014
2115# -------------- WFDB Signal Calibration and Classification ---------- #
2216
@@ -935,13 +929,17 @@ def wrsamp(self, expanded=False, write_dir="", wfdb_archive=None):
935929
936930 # Perform field validity and cohesion checks, and write the
937931 # header file.
938- self .wrheader (write_dir = write_dir , expanded = expanded ,
939- wfdb_archive = wfdb_archive )
932+ self .wrheader (
933+ write_dir = write_dir , expanded = expanded , wfdb_archive = wfdb_archive
934+ )
940935 if self .n_sig > 0 :
941936 # Perform signal validity and cohesion checks, and write the
942937 # associated dat files.
943- self .wr_dats (expanded = expanded , write_dir = write_dir ,
944- wfdb_archive = wfdb_archive )
938+ self .wr_dats (
939+ expanded = expanded ,
940+ write_dir = write_dir ,
941+ wfdb_archive = wfdb_archive ,
942+ )
945943
946944 def _arrange_fields (self , channels , sampfrom , smooth_frames ):
947945 """
@@ -2046,10 +2044,13 @@ def rdrecord(
20462044 hea_file = os .path .basename (record_base ) + ".hea"
20472045
20482046 import tempfile
2047+
20492048 with wfdb_archive .open (hea_file , "r" ) as f :
20502049 header_str = f .read ()
20512050
2052- with tempfile .NamedTemporaryFile ("w+" , suffix = ".hea" , delete = False ) as tmpf :
2051+ with tempfile .NamedTemporaryFile (
2052+ "w+" , suffix = ".hea" , delete = False
2053+ ) as tmpf :
20532054 tmpf .write (header_str )
20542055 tmpf .flush ()
20552056 record = rdheader (tmpf .name )
@@ -2074,7 +2075,9 @@ def rdrecord(
20742075 if "." not in pn_dir :
20752076 dir_list = pn_dir .split ("/" )
20762077 pn_dir = posixpath .join (
2077- dir_list [0 ], download .get_version (dir_list [0 ]), * dir_list [1 :]
2078+ dir_list [0 ],
2079+ download .get_version (dir_list [0 ]),
2080+ * dir_list [1 :],
20782081 )
20792082
20802083 record = rdheader (record_name , pn_dir = pn_dir , rd_segments = False )
@@ -2783,7 +2786,9 @@ def wfdbtime(record_name, input_times, pn_dir=None):
27832786 )
27842787 if not times .startswith ("s" ):
27852788 sample_num = int (
2786- sum (x * 60 ** i for i , x in enumerate ([seconds , minutes , hours ]))
2789+ sum (
2790+ x * 60 ** i for i , x in enumerate ([seconds , minutes , hours ])
2791+ )
27872792 * record .fs
27882793 )
27892794 sample_num = "s" + str (sample_num )
@@ -3080,11 +3085,14 @@ def wrsamp(
30803085 expanded = False
30813086
30823087 if wfdb_archive :
3083- wfdb_archive = get_archive (os .path .join (write_dir , record_name ),
3084- mode = "w" )
3088+ wfdb_archive = get_archive (
3089+ os .path .join (write_dir , record_name ), mode = "w"
3090+ )
30853091
30863092 # Write the record files - header and associated dat
3087- record .wrsamp (write_dir = write_dir , expanded = expanded , wfdb_archive = wfdb_archive )
3093+ record .wrsamp (
3094+ write_dir = write_dir , expanded = expanded , wfdb_archive = wfdb_archive
3095+ )
30883096
30893097
30903098def dl_database (
0 commit comments