Skip to content

Commit

Permalink
#180: make truncate and read_only mutually exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Jul 25, 2024
1 parent 351cfd4 commit 8125803
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions alphabase/io/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ def __init__(
Args:
file_name (str): file path.
read_only (bool, optional): If hdf is read-only. Mutually exclusive with `delete_existing`. Defaults to True.
read_only (bool, optional): If hdf is read-only. Mutually exclusive with `delete_existing` and `truncate`. Defaults to True.
truncate (bool, optional): If existing groups and datasets can be
truncated (i.e. are overwitten). Defaults to False.
truncated (i.e. are overwitten). Mutually exclusive with `read_only`. Defaults to False.
delete_existing (bool, optional): If the file already exists,
delete it completely and create a new one. Mutually exclusive with `read_only`. Defaults to False.
Expand All @@ -498,15 +498,15 @@ def __init__(
>>> hdf_file.dfs.df1.data_from
"colleagues"
"""
if delete_existing and read_only:
if read_only and (delete_existing or truncate):
raise ValueError(
"Parameters 'delete_existing' and 'read_only' are mutually exclusive."
"Parameters 'delete_existing'/'truncate' are mutually exclusive with 'read_only'."
)

if delete_existing:
mode = "w"
elif read_only:
if read_only:
mode = "r"
elif delete_existing:
mode = "w"
else:
mode = "a"

Expand Down

0 comments on commit 8125803

Please sign in to comment.