From 8443f4afc2940fb5896ec4b9fa8caa20c2508e4c Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Fri, 27 Oct 2023 09:48:40 +0100 Subject: [PATCH] run all --- mapreader/_version.py | 4 +++- mapreader/classify/classifier.py | 4 +--- mapreader/classify/datasets.py | 4 +--- mapreader/download/tile_loading.py | 6 +----- mapreader/download/tile_merging.py | 10 +++------- versioneer.py | 8 ++++++-- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/mapreader/_version.py b/mapreader/_version.py index 40cc6dd5..7ad083de 100644 --- a/mapreader/_version.py +++ b/mapreader/_version.py @@ -142,7 +142,9 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): if verbose: print( - "Tried directories {} but none started with prefix {}".format(str(rootdirs), parentdir_prefix) + "Tried directories {} but none started with prefix {}".format( + str(rootdirs), parentdir_prefix + ) ) raise NotThisMethod("rootdir doesn't start with parentdir_prefix") diff --git a/mapreader/classify/classifier.py b/mapreader/classify/classifier.py index 0543973e..1cfa60ff 100644 --- a/mapreader/classify/classifier.py +++ b/mapreader/classify/classifier.py @@ -565,9 +565,7 @@ def unfreeze_layers(self, layers_to_unfreeze: list[str] | None = None): elif (layer[-1] != "*") and (layer == name): param.requires_grad = True - def only_keep_layers( - self, only_keep_layers_list: list[str] | None = None - ) -> None: + def only_keep_layers(self, only_keep_layers_list: list[str] | None = None) -> None: """ Only keep the specified layers (``only_keep_layers_list``) for gradient computation during the backpropagation. diff --git a/mapreader/classify/datasets.py b/mapreader/classify/datasets.py index 3fee2e4d..21cdf3fe 100644 --- a/mapreader/classify/datasets.py +++ b/mapreader/classify/datasets.py @@ -163,9 +163,7 @@ def __len__(self) -> int: """ return len(self.patch_df) - def __getitem__( - self, idx: int | torch.Tensor - ) -> tuple[torch.Tensor, str, int]: + def __getitem__(self, idx: int | torch.Tensor) -> tuple[torch.Tensor, str, int]: """ Return the image, its label and the index of that label at the given index in the dataset. diff --git a/mapreader/download/tile_loading.py b/mapreader/download/tile_loading.py index 96d83924..40f257e8 100644 --- a/mapreader/download/tile_loading.py +++ b/mapreader/download/tile_loading.py @@ -172,11 +172,7 @@ def _update_progressbar(self, share: float): print( "\r", - f"{share * 100:3.0f}%" - + "|" - + "■" * visible - + "□" * invisible - + "|", + f"{share * 100:3.0f}%" + "|" + "■" * visible + "□" * invisible + "|", end="", ) diff --git a/mapreader/download/tile_merging.py b/mapreader/download/tile_merging.py index d0b3f768..4fdc110b 100644 --- a/mapreader/download/tile_merging.py +++ b/mapreader/download/tile_merging.py @@ -129,7 +129,7 @@ def _load_tile_size(self, grid_bb: GridBoundingBox): logger.warning("Image has missing tiles in bottom left corner.") try: start_image = self._load_image_to_grid_cell(grid_bb.upper_corner) - except FileNotFoundError as err: + except FileNotFoundError: logger.warning("Image has missing tiles in upper right corner.") raise FileNotFoundError( "[ERROR] Image is missing tiles for both lower left and upper right corners." @@ -142,9 +142,7 @@ def _load_tile_size(self, grid_bb: GridBoundingBox): tile_size = img_size[0] return tile_size - def merge( - self, grid_bb: GridBoundingBox, file_name: str | None = None - ) -> bool: + def merge(self, grid_bb: GridBoundingBox, file_name: str | None = None) -> bool: """Merges cells contained within GridBoundingBox. Parameters @@ -196,9 +194,7 @@ def merge( merged_image.save(out_path, self.img_output_format[1]) success = True if os.path.exists(out_path) else False if success: - logger.info( - f"Merge successful! The image has been stored at '{out_path}'" - ) + logger.info(f"Merge successful! The image has been stored at '{out_path}'") else: logger.warning(f"Merge unsuccessful! '{out_path}' not saved.") diff --git a/versioneer.py b/versioneer.py index 380e05dd..aa891c49 100644 --- a/versioneer.py +++ b/versioneer.py @@ -368,7 +368,9 @@ def get_root(): vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) if me_dir != vsr_dir and "VERSIONEER_PEP518" not in globals(): print( - "Warning: build in {} is using versioneer.py from {}".format(os.path.dirname(my_path), versioneer_py) + "Warning: build in {} is using versioneer.py from {}".format( + os.path.dirname(my_path), versioneer_py + ) ) except NameError: pass @@ -1444,7 +1446,9 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): if verbose: print( - "Tried directories {} but none started with prefix {}".format(str(rootdirs), parentdir_prefix) + "Tried directories {} but none started with prefix {}".format( + str(rootdirs), parentdir_prefix + ) ) raise NotThisMethod("rootdir doesn't start with parentdir_prefix")