Skip to content

Commit ee7c5a1

Browse files
committed
Remove bool(overwrite)
1 parent 642dc16 commit ee7c5a1

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/aspire/image/image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,10 @@ def save(self, mrcs_filepath, overwrite=None):
506506
if overwrite is None and os.path.exists(mrcs_filepath):
507507
# If the file exists, append a timestamp to the old file and rename it
508508
_ = rename_with_timestamp(mrcs_filepath)
509+
elif overwrite is None:
510+
overwrite = False
509511

510-
with mrcfile.new(mrcs_filepath, overwrite=bool(overwrite)) as mrc:
512+
with mrcfile.new(mrcs_filepath, overwrite=overwrite) as mrc:
511513
# original input format (the image index first)
512514
mrc.set_data(self._data.astype(np.float32))
513515
# Note assigning voxel_size must come after `set_data`

src/aspire/source/image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,9 @@ def save(
10081008
# Allow overwriting old files.
10091009
overwrite = True
10101010

1011+
elif overwrite is None:
1012+
overwrite = False
1013+
10111014
logger.info("save metadata into STAR file")
10121015
filename_indices = self.save_metadata(
10131016
starfile_filepath,
@@ -1021,7 +1024,7 @@ def save(
10211024
starfile_filepath,
10221025
filename_indices=filename_indices,
10231026
batch_size=batch_size,
1024-
overwrite=bool(overwrite),
1027+
overwrite=overwrite,
10251028
)
10261029
# return some information about the saved files
10271030
info = {"starfile": starfile_filepath, "mrcs": unique_filenames}

src/aspire/volume/volume.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,10 @@ def save(self, filename, overwrite=None):
655655
if overwrite is None and os.path.exists(filename):
656656
# If the file exists, append a timestamp to the old file and rename it
657657
_ = rename_with_timestamp(filename)
658+
elif overwrite is None:
659+
overwrite = False
658660

659-
with mrcfile.new(filename, overwrite=bool(overwrite)) as mrc:
661+
with mrcfile.new(filename, overwrite=overwrite) as mrc:
660662
mrc.set_data(self._data.astype(np.float32))
661663
# Note assigning voxel_size must come after `set_data`
662664
if self.pixel_size is not None:

0 commit comments

Comments
 (0)