From bb828de92d961f2b106f20da5c7616f062393af7 Mon Sep 17 00:00:00 2001 From: dcarron <daniel.carron@idiap.ch> Date: Mon, 5 Feb 2024 09:49:43 +0100 Subject: [PATCH] [doc] Disable docstring summary wrapping with docformatter --- .pre-commit-config.yaml | 3 +++ .../config/data/montgomery_shenzhen_indian/datamodule.py | 6 ++---- .../data/montgomery_shenzhen_indian_padchest/datamodule.py | 3 +-- .../data/montgomery_shenzhen_indian_padchest/default.py | 3 +-- .../data/montgomery_shenzhen_indian_tbx11k/datamodule.py | 3 +-- src/mednet/config/data/nih_cxr14_padchest/idiap.py | 3 +-- src/mednet/config/data/tbx11k/datamodule.py | 3 +-- src/mednet/engine/device.py | 3 +-- src/mednet/models/transforms.py | 6 ++---- src/mednet/scripts/click.py | 4 +--- src/mednet/scripts/predict.py | 3 +-- src/mednet/scripts/train_analysis.py | 3 +-- src/mednet/utils/resources.py | 3 +-- tests/conftest.py | 3 +-- 14 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c74881a8..2c305176 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,9 @@ repos: rev: v1.7.5 hooks: - id: docformatter + args: [ + --wrap-summaries=0, + ] - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: diff --git a/src/mednet/config/data/montgomery_shenzhen_indian/datamodule.py b/src/mednet/config/data/montgomery_shenzhen_indian/datamodule.py index 64b4d0f7..676fa8ef 100644 --- a/src/mednet/config/data/montgomery_shenzhen_indian/datamodule.py +++ b/src/mednet/config/data/montgomery_shenzhen_indian/datamodule.py @@ -1,8 +1,7 @@ # Copyright © 2022 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: GPL-3.0-or-later -"""Aggregated DataModule composed of Montgomery, Shenzhen and Indian -datasets.""" +"""Aggregated DataModule composed of Montgomery, Shenzhen and Indian datasets.""" from ....data.datamodule import ConcatDataModule from ..indian.datamodule import RawDataLoader as IndianLoader @@ -14,8 +13,7 @@ from ..shenzhen.datamodule import make_split as make_shenzhen_split class DataModule(ConcatDataModule): - """Aggregated DataModule composed of Montgomery, Shenzhen and Indian - datasets. + """Aggregated DataModule composed of Montgomery, Shenzhen and Indian datasets. Parameters ---------- diff --git a/src/mednet/config/data/montgomery_shenzhen_indian_padchest/datamodule.py b/src/mednet/config/data/montgomery_shenzhen_indian_padchest/datamodule.py index e30fac0a..2876af8f 100644 --- a/src/mednet/config/data/montgomery_shenzhen_indian_padchest/datamodule.py +++ b/src/mednet/config/data/montgomery_shenzhen_indian_padchest/datamodule.py @@ -1,8 +1,7 @@ # Copyright © 2022 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: GPL-3.0-or-later -"""Aggregated DataModule composed of Montgomery, Shenzhen, Indian, and PadChest -datasets.""" +"""Aggregated DataModule composed of Montgomery, Shenzhen, Indian, and PadChest datasets.""" from ....data.datamodule import ConcatDataModule from ..indian.datamodule import RawDataLoader as IndianLoader diff --git a/src/mednet/config/data/montgomery_shenzhen_indian_padchest/default.py b/src/mednet/config/data/montgomery_shenzhen_indian_padchest/default.py index 07b695cc..7a0c7dce 100644 --- a/src/mednet/config/data/montgomery_shenzhen_indian_padchest/default.py +++ b/src/mednet/config/data/montgomery_shenzhen_indian_padchest/default.py @@ -1,8 +1,7 @@ # Copyright © 2022 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: GPL-3.0-or-later -"""Aggregated dataset composed of Montgomery, Shenzhen, Indian and Padchest -datasets.""" +"""Aggregated dataset composed of Montgomery, Shenzhen, Indian and Padchest datasets.""" from mednet.config.data.montgomery_shenzhen_indian_padchest.datamodule import ( DataModule, diff --git a/src/mednet/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py b/src/mednet/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py index dbda251e..8dd83198 100644 --- a/src/mednet/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py +++ b/src/mednet/config/data/montgomery_shenzhen_indian_tbx11k/datamodule.py @@ -1,8 +1,7 @@ # Copyright © 2022 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: GPL-3.0-or-later -"""Aggregated DataModule composed of Montgomery, Shenzhen, Indian, and TBX11k -datasets.""" +"""Aggregated DataModule composed of Montgomery, Shenzhen, Indian, and TBX11k datasets.""" from ....data.datamodule import ConcatDataModule from ..indian.datamodule import RawDataLoader as IndianLoader diff --git a/src/mednet/config/data/nih_cxr14_padchest/idiap.py b/src/mednet/config/data/nih_cxr14_padchest/idiap.py index aed16c8f..6ac62f99 100644 --- a/src/mednet/config/data/nih_cxr14_padchest/idiap.py +++ b/src/mednet/config/data/nih_cxr14_padchest/idiap.py @@ -1,8 +1,7 @@ # SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch> # # SPDX-License-Identifier: GPL-3.0-or-later -"""Aggregated dataset composed of NIH CXR14 relabeld and PadChest (normalized) -datasets (no-tb-idiap split).""" +"""Aggregated dataset composed of NIH CXR14 relabeld and PadChest (normalized) datasets (no-tb-idiap split).""" from mednet.config.data.nih_cxr14_padchest.datamodule import DataModule diff --git a/src/mednet/config/data/tbx11k/datamodule.py b/src/mednet/config/data/tbx11k/datamodule.py index 1efd1c02..dfb3038b 100644 --- a/src/mednet/config/data/tbx11k/datamodule.py +++ b/src/mednet/config/data/tbx11k/datamodule.py @@ -119,8 +119,7 @@ class BoundingBoxes(collections.abc.Sequence[BoundingBox]): # explained at: # https://pytorch.org/docs/stable/data.html#torch.utils.data.default_collate def _collate_boundingboxes_fn(batch, *, collate_fn_map=None): - """Custom collate_fn() for pytorch dataloaders that ignores BoundingBoxes - objects.""" + """Custom collate_fn() for pytorch dataloaders that ignores BoundingBoxes objects.""" return batch diff --git a/src/mednet/engine/device.py b/src/mednet/engine/device.py index 7f989523..c501f7f2 100644 --- a/src/mednet/engine/device.py +++ b/src/mednet/engine/device.py @@ -21,8 +21,7 @@ SupportedPytorchDevice: typing.TypeAlias = typing.Literal[ def _split_int_list(s: str) -> list[int]: - """Split a list of integers encoded in a string (e.g. "1,2,3") into a - Python list of integers (e.g. ``[1, 2, 3]``).""" + """Split a list of integers encoded in a string (e.g. "1,2,3") into a Python list of integers (e.g. ``[1, 2, 3]``).""" return [int(k.strip()) for k in s.split(",")] diff --git a/src/mednet/models/transforms.py b/src/mednet/models/transforms.py index 55312665..4ee73548 100644 --- a/src/mednet/models/transforms.py +++ b/src/mednet/models/transforms.py @@ -95,8 +95,7 @@ def rgb_to_grayscale(img: torch.Tensor) -> torch.Tensor: class RGB(torch.nn.Module): - """Wrapper class around :py:func:`.grayscale_to_rgb` to be used as a model - transform.""" + """Wrapper class around :py:func:`.grayscale_to_rgb` to be used as a model transform.""" def __init__(self): super().__init__() @@ -106,8 +105,7 @@ class RGB(torch.nn.Module): class Grayscale(torch.nn.Module): - """Wrapper class around :py:func:`rgb_to_grayscale` to be used as a model - transform.""" + """Wrapper class around :py:func:`rgb_to_grayscale` to be used as a model transform.""" def __init__(self): super().__init__() diff --git a/src/mednet/scripts/click.py b/src/mednet/scripts/click.py index 7f8830d6..8cb7c392 100644 --- a/src/mednet/scripts/click.py +++ b/src/mednet/scripts/click.py @@ -8,9 +8,7 @@ from clapper.click import ConfigCommand as _BaseConfigCommand class ConfigCommand(_BaseConfigCommand): - """A click command-class that has the properties of - :py:class:`clapper.click.ConfigCommand` and adds verbatim epilog - formatting.""" + """A click command-class that has the properties of :py:class:`clapper.click.ConfigCommand` and adds verbatim epilog formatting.""" def format_epilog( self, _: click.core.Context, formatter: click.formatting.HelpFormatter diff --git a/src/mednet/scripts/predict.py b/src/mednet/scripts/predict.py index 664da885..214b85e7 100644 --- a/src/mednet/scripts/predict.py +++ b/src/mednet/scripts/predict.py @@ -125,8 +125,7 @@ def predict( parallel, **_, ) -> None: - """Run inference (generates scores) on all input images, using a pre- - trained model.""" + """Run inference (generates scores) on all input images, using a pre-trained model.""" import json import shutil diff --git a/src/mednet/scripts/train_analysis.py b/src/mednet/scripts/train_analysis.py index cb240a6e..73e683a1 100644 --- a/src/mednet/scripts/train_analysis.py +++ b/src/mednet/scripts/train_analysis.py @@ -134,8 +134,7 @@ def train_analysis( logdir: pathlib.Path, output: pathlib.Path, ) -> None: - """Create a plot for each metric in the training logs and saves them in a - .pdf file.""" + """Create a plot for each metric in the training logs and saves them in a .pdf file.""" import matplotlib.pyplot as plt diff --git a/src/mednet/utils/resources.py b/src/mednet/utils/resources.py index e1800778..8d95e121 100644 --- a/src/mednet/utils/resources.py +++ b/src/mednet/utils/resources.py @@ -582,8 +582,7 @@ class ResourceMonitor: self.data[k] = 0.0 def __exit__(self, *_) -> None: - """Stop the monitoring process and returns the summary of - observations.""" + """Stop the monitoring process and returns the summary of observations.""" self.stop_event.set() self.monitor.join() diff --git a/tests/conftest.py b/tests/conftest.py index 5b9d4d47..bacef95e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -76,8 +76,7 @@ def temporary_basedir(tmp_path_factory): def pytest_sessionstart(session: pytest.Session) -> None: - """Preset the session start to ensure the Montgomery dataset is always - available.""" + """Preset the session start to ensure the Montgomery dataset is always available.""" from mednet.utils.rc import load_rc -- GitLab