From 404a97565e3eee36309c5fecd1d886e1ed5ca412 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 21:56:18 +0000 Subject: [PATCH] style(pre-commit.ci): auto fixes [...] --- src/llspy/bin/llspy_cli.py | 16 ++++++++-------- src/llspy/gui/img_dialog.py | 4 +--- src/llspy/gui/mainwindow.py | 4 ++-- src/llspy/gui/workers.py | 2 +- src/llspy/llsdir.py | 16 ++++++++-------- src/llspy/xzpsf.py | 2 +- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/llspy/bin/llspy_cli.py b/src/llspy/bin/llspy_cli.py index cd73435..1b6696e 100644 --- a/src/llspy/bin/llspy_cli.py +++ b/src/llspy/bin/llspy_cli.py @@ -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: @@ -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): @@ -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 @@ -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"]: @@ -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: @@ -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) diff --git a/src/llspy/gui/img_dialog.py b/src/llspy/gui/img_dialog.py index 0d1e17e..d0400cc 100644 --- a/src/llspy/gui/img_dialog.py +++ b/src/llspy/gui/img_dialog.py @@ -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: diff --git a/src/llspy/gui/mainwindow.py b/src/llspy/gui/mainwindow.py index 33418bc..8896240 100644 --- a/src/llspy/gui/mainwindow.py +++ b/src/llspy/gui/mainwindow.py @@ -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) @@ -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 diff --git a/src/llspy/gui/workers.py b/src/llspy/gui/workers.py index 34e0b2a..eed8093 100644 --- a/src/llspy/gui/workers.py +++ b/src/llspy/gui/workers.py @@ -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() diff --git a/src/llspy/llsdir.py b/src/llspy/llsdir.py index a6ea08c..8f7bef8 100644 --- a/src/llspy/llsdir.py +++ b/src/llspy/llsdir.py @@ -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): @@ -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 ) @@ -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"] @@ -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( @@ -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 @@ -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) @@ -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]) diff --git a/src/llspy/xzpsf.py b/src/llspy/xzpsf.py index bdfe1f3..403dc42 100755 --- a/src/llspy/xzpsf.py +++ b/src/llspy/xzpsf.py @@ -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)