Skip to content

Commit

Permalink
Merge pull request #133 from easy-electrophysiology/try_safe_close
Browse files Browse the repository at this point in the history
added context manager to h5py open
  • Loading branch information
boazmohar committed Oct 29, 2021
2 parents 5aad1d2 + 5263ae9 commit 40554aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pywavesurfer/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def loadDataFile(filename, format_string='double'):
raise RuntimeError("File must be a WaveSurfer-generated HDF5 (.h5) file.")

# Extract dataset at each group level, recursively.
file = h5py.File(filename, mode='r')
data_file_as_dict = crawl_h5_group(file) # an h5py File is also a Group
with h5py.File(filename, mode='r') as file:
data_file_as_dict = crawl_h5_group(file) # an h5py File is also a Group

# Correct the samples rates for files that were generated by versions
# of WS which didn't coerce the sampling rate to an allowed rate.
Expand Down

0 comments on commit 40554aa

Please sign in to comment.