Skip to content

Commit

Permalink
style(pre-commit.ci): auto fixes [...]
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed May 6, 2024
1 parent ba09c55 commit 404a975
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
16 changes: 8 additions & 8 deletions src/llspy/bin/llspy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def delete_cfgfile(self):
def print_cfgfile(self):
if os.path.isfile(self.default_path):
click.secho(
"\nConfig PATH: %s" % click.format_filename(self.default_path),
f"\nConfig PATH: {click.format_filename(self.default_path)}",
fg="cyan",
)
with open(self.default_path) as f:
Expand All @@ -100,7 +100,7 @@ def print_cfgfile(self):
click.echo()
else:
click.echo(
"No config file found at: %s" % click.format_filename(self.default_path)
f"No config file found at: {click.format_filename(self.default_path)}"
)

def update_default(self, key, value):
Expand Down Expand Up @@ -321,7 +321,7 @@ def check_iters(ctx, param, value):

if otfdir is not None and not otf.dir_has_otfs(otfdir):
click.secho(
"\nOTF directory has no OTFs! -> %s" % otfdir, bold=True, fg="red"
f"\nOTF directory has no OTFs! -> {otfdir}", bold=True, fg="red"
)
fail = True

Expand Down Expand Up @@ -611,7 +611,7 @@ def procfolder(dirpath, options):
click.secho(
"\n" + "#" * (int(len(str(E.path))) + 24) + "\n## ", fg="cyan", nl=False
)
click.secho("processing: %s " % str(E.path), fg="yellow", nl=False)
click.secho(f"processing: {E.path!s} ", fg="yellow", nl=False)
click.secho("##\n" + "#" * (int(len(str(E.path))) + 24) + "\n", fg="cyan")

if options["correctFlash"]:
Expand Down Expand Up @@ -664,9 +664,9 @@ def procfolder(dirpath, options):
except voluptuous.error.MultipleInvalid as e:
e = str(e).replace("@ data['", "for ")
e = e.strip("'][0]")
click.secho("VALIDATION ERROR: %s" % e, fg="red")
click.secho(f"VALIDATION ERROR: {e}", fg="red")
except exceptions.LLSpyError as e:
click.secho("ERROR: %s" % e, fg="red")
click.secho(f"ERROR: {e}", fg="red")
click.echo("\n\nDone batch processing!")
sys.exit(0)
except Exception:
Expand All @@ -679,9 +679,9 @@ def procfolder(dirpath, options):
except voluptuous.error.MultipleInvalid as e:
e = str(e).replace("@ data['", "for ")
e = e.strip("'][0]")
click.secho("VALIDATION ERROR: %s" % e, fg="red")
click.secho(f"VALIDATION ERROR: {e}", fg="red")
except exceptions.LLSpyError as e:
click.secho("ERROR: %s" % e, fg="red")
click.secho(f"ERROR: {e}", fg="red")

sys.exit(0)

Expand Down
4 changes: 1 addition & 3 deletions src/llspy/gui/img_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ def setData(self, data):
self.shape = data.shape
self.data = data.copy()
else:
raise TypeError(
"data should be 3-5 dimensional! shape = %s" % str(data.shape)
)
raise TypeError(f"data should be 3-5 dimensional! shape = {data.shape!s}")

self.nT, self.nC, self.nZ, self.nY, self.nX = self.data.shape
if not self.isComplex:
Expand Down
4 changes: 2 additions & 2 deletions src/llspy/gui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def setPref(value):
box.exec_()

return
logger.info("Adding to queue: %s" % shortname(path))
logger.info(f"Adding to queue: {shortname(path)}")

rowPosition = self.rowCount()
self.insertRow(rowPosition)
Expand Down Expand Up @@ -396,7 +396,7 @@ def keyPressEvent(self, event):
for index in sorted(indices):
removerow = index.row() - i
path = self.getPathByIndex(removerow)
logger.info("Removing from queue: %s" % shortname(path))
logger.info(f"Removing from queue: {shortname(path)}")
self.removePath(path)
i += 1

Expand Down
2 changes: 1 addition & 1 deletion src/llspy/gui/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def work(self):
# with the argQueue populated, we can now start the workers
if not len(self.__argQueue):
self._logger.error(
"No channel arguments to process in LLSitem: %s" % self.shortname
f"No channel arguments to process in LLSitem: {self.shortname}"
)
self._logger.debug(f"LLSitemWorker FINISH: {self.E.basename}")
self.finished.emit()
Expand Down
16 changes: 8 additions & 8 deletions src/llspy/llsdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def register_image_to_wave(
if not isinstance(regCalibObj, (RegDir, RegFile)):
raise RegistrationError(
"Calibration object for register_image_to_wave "
"must be either RegDir or RegFile. Received: %s" % str(type(regCalibObj))
f"must be either RegDir or RegFile. Received: {type(regCalibObj)!s}"
)

if isinstance(img, np.ndarray):
Expand Down Expand Up @@ -876,7 +876,7 @@ def is_corrected(self):
return False

def compress(self, subfolder=".", compression=None):
logger.info("compressing %s..." % str(self.path.joinpath(subfolder)))
logger.info(f"compressing {self.path.joinpath(subfolder)!s}...")
return compress.compress(
str(self.path.joinpath(subfolder)), compression=compression
)
Expand All @@ -896,7 +896,7 @@ def reduce_to_raw(self, keepmip=True, verbose=True):
need to consider the case of sepmips
"""
if verbose:
logger.info("reducing %s..." % str(self.path.name))
logger.info(f"reducing {self.path.name!s}...")

subfolders = ["GPUdecon", "CPPdecon", "Deskewed", "Corrected"]

Expand All @@ -914,7 +914,7 @@ def reduce_to_raw(self, keepmip=True, verbose=True):
if self.path.joinpath(folder).exists():
try:
if verbose:
logger.info("\tdeleting %s..." % folder)
logger.info(f"\tdeleting {folder}...")
shutil.rmtree(str(self.path.joinpath(folder)))
except Exception as e:
logger.error(
Expand Down Expand Up @@ -1101,7 +1101,7 @@ def mergemips(self, subdir=None, delete=True):
if self.path.joinpath(subdir).is_dir():
subdir = self.path.joinpath(subdir)
else:
logger.error("Could not find subdir: %s" % subdir)
logger.error(f"Could not find subdir: {subdir}")
return
else:
subdir = self.path
Expand Down Expand Up @@ -1561,10 +1561,10 @@ def rename_iters(folder, splitpositions=True):
for it in iterset:
iterdict[it] = {}
iterdict[it]["setfile"] = util.find_filepattern(
folder, "*Iter_%s_*Settings.txt" % it
folder, f"*Iter_{it}_*Settings.txt"
)
# all the files from this Iter group
g = [f for f in filelist if "Iter_%s_" % it in f]
g = [f for f in filelist if f"Iter_{it}_" in f]
# tuple of nFiles in each channel in this group
nFilesPerChannel.append(
tuple(len([f for f in g if "ch%d" % d in f]) for d in chanset)
Expand Down Expand Up @@ -1604,7 +1604,7 @@ def rename_iters(folder, splitpositions=True):
t0 = [0] * nPositions
for i in iterset:
flist = sorted(
f for f in filelist if "ch%s" % chan in f and "Iter_%s_" % i in f
f for f in filelist if f"ch{chan}" in f and f"Iter_{i}_" in f
)
for pos in range(nPositions):
base = os.path.basename(flist[pos])
Expand Down
2 changes: 1 addition & 1 deletion src/llspy/xzpsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main(infile, nx, nz, sig=1, pad=12):
warnings.simplefilter("ignore")
indat = tf.imread(infile)
except OSError:
print("File %s does not exist or is no readable.\n Quit" % infile)
print(f"File {infile} does not exist or is no readable.\n Quit")
return

mip = indat.max(0)
Expand Down

0 comments on commit 404a975

Please sign in to comment.