Skip to content

Commit

Permalink
#180: open HDF in read mode if read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Jul 17, 2024
1 parent bb624c0 commit 40c9434
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions alphabase/io/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,16 @@ def __init__(
>>> hdf_file.dfs.df1.data_from
"colleagues"
"""
mode = "w" if delete_existing else "a"
with h5py.File(file_name, mode): # , swmr=True):
if delete_existing:
mode = "w"
elif read_only:
mode = "r"
else:
mode = "a"

with h5py.File(file_name, mode):
pass

super().__init__(
file_name=file_name,
name="/",
Expand Down

0 comments on commit 40c9434

Please sign in to comment.