Skip to content

Commit

Permalink
Remove bool(overwrite)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-c-c committed Oct 28, 2024
1 parent adc6d70 commit 66d2e7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/aspire/image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,10 @@ def save(self, mrcs_filepath, overwrite=None):
if overwrite is None and os.path.exists(mrcs_filepath):
# If the file exists, append a timestamp to the old file and rename it
_ = rename_with_timestamp(mrcs_filepath)
elif overwrite is None:
overwrite = False

with mrcfile.new(mrcs_filepath, overwrite=bool(overwrite)) as mrc:
with mrcfile.new(mrcs_filepath, overwrite=overwrite) as mrc:
# original input format (the image index first)
mrc.set_data(self._data.astype(np.float32))
# Note assigning voxel_size must come after `set_data`
Expand Down
5 changes: 4 additions & 1 deletion src/aspire/source/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,9 @@ def save(
# Allow overwriting old files.
overwrite = True

elif overwrite is None:
overwrite = False

logger.info("save metadata into STAR file")
filename_indices = self.save_metadata(
starfile_filepath,
Expand All @@ -1021,7 +1024,7 @@ def save(
starfile_filepath,
filename_indices=filename_indices,
batch_size=batch_size,
overwrite=bool(overwrite),
overwrite=overwrite,
)
# return some information about the saved files
info = {"starfile": starfile_filepath, "mrcs": unique_filenames}
Expand Down
4 changes: 3 additions & 1 deletion src/aspire/volume/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@ def save(self, filename, overwrite=None):
if overwrite is None and os.path.exists(filename):
# If the file exists, append a timestamp to the old file and rename it
_ = rename_with_timestamp(filename)
elif overwrite is None:
overwrite = False

with mrcfile.new(filename, overwrite=bool(overwrite)) as mrc:
with mrcfile.new(filename, overwrite=overwrite) as mrc:
mrc.set_data(self._data.astype(np.float32))
# Note assigning voxel_size must come after `set_data`
if self.pixel_size is not None:
Expand Down

0 comments on commit 66d2e7a

Please sign in to comment.