Skip to content

Fix warnings #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tests/test_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def test_1(self):
# no null to detect in the output text file of rdann.

# Target data from WFDB software package
lines = tuple(open("tests/target-output/ann-1", "r"))
with open("tests/target-output/ann-1", "r") as f:
lines = tuple(f)
nannot = len(lines)

target_time = [None] * nannot
Expand Down Expand Up @@ -108,7 +109,8 @@ def test_2(self):
annotation = wfdb.rdann("sample-data/12726", "anI")

# Target data from WFDB software package
lines = tuple(open("tests/target-output/ann-2", "r"))
with open("tests/target-output/ann-2", "r") as f:
lines = tuple(f)
nannot = len(lines)

target_time = [None] * nannot
Expand Down Expand Up @@ -181,7 +183,8 @@ def test_3(self):
annotation = wfdb.rdann("sample-data/1003", "atr")

# Target data from WFDB software package
lines = tuple(open("tests/target-output/ann-3", "r"))
with open("tests/target-output/ann-3", "r") as f:
lines = tuple(f)
nannot = len(lines)

target_time = [None] * nannot
Expand Down
2 changes: 2 additions & 0 deletions wfdb/io/convert/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ def read_edf(
int(np.sum(v) % 65536) for v in np.transpose(sig_data)
] # not all values correct?

edf_file.close()

record = Record(
record_name=record_name_out,
n_sig=n_sig,
Expand Down
12 changes: 5 additions & 7 deletions wfdb/io/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _stream_dat(file_name, pn_dir, byte_count, start_byte, dtype):
content = f.read(byte_count)

# Convert to numpy array
sig_data = np.fromstring(content, dtype=dtype)
sig_data = np.frombuffer(content, dtype=dtype)

return sig_data

Expand Down Expand Up @@ -173,7 +173,7 @@ def _stream_annotation(file_name, pn_dir):
content = f.read()

# Convert to numpy array
ann_data = np.fromstring(content, dtype=np.dtype("<u1"))
ann_data = np.frombuffer(content, dtype=np.dtype("<u1"))

return ann_data

Expand Down Expand Up @@ -343,7 +343,7 @@ def get_annotators(db_dir, annotators):
annotators = ann_list
else:
# In case they didn't input a list
if type(annotators) == str:
if type(annotators) is str:
annotators = [annotators]
# user input ones. Check validity.
for a in annotators:
Expand Down Expand Up @@ -541,8 +541,6 @@ def dl_files(db, dl_dir, files, keep_subdirs=True, overwrite=False):
print("Downloading files...")
# Create multiple processes to download files.
# Limit to 2 connections to avoid overloading the server
pool = multiprocessing.dummy.Pool(processes=2)
pool.map(dl_pn_file, dl_inputs)
with multiprocessing.dummy.Pool(processes=2) as pool:
pool.map(dl_pn_file, dl_inputs)
print("Finished downloading files")

return
6 changes: 2 additions & 4 deletions wfdb/io/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -3117,8 +3117,6 @@ def dl_database(
print("Downloading files...")
# Create multiple processes to download files.
# Limit to 2 connections to avoid overloading the server
pool = multiprocessing.dummy.Pool(processes=2)
pool.map(download.dl_pn_file, dl_inputs)
with multiprocessing.dummy.Pool(processes=2) as pool:
pool.map(download.dl_pn_file, dl_inputs)
print("Finished downloading files")

return
Loading