diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c74881a8cfaee431ad893c19b4c9ca8fa5792a1b..2c305176c0f4da15bffc19a7f6dd34cc207c3437 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 64b4d0f77ad7d43b6aebf23c1c3bc670b947d348..676fa8ef96d26b794341dee5c5cd09caf55d06d0 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 e30fac0a4e3340e2dfd6abbfa454d1baa7931370..2876af8f0335acd87313c02ca18ad8b47dd21bcc 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 07b695cce4573ecc80347df15dfb44ea281864a7..7a0c7dce64501dca4d6017874ebf0cdf0ae26be2 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 dbda251e0d319db9db2a1da255ffbbed0c236c8c..8dd831981465af7afa276d67287de5c09008bc36 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 aed16c8fec30a2304f068f802b0a762917941bc6..6ac62f99a2097a4add1349e47652c65e9eb8a913 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 1efd1c029b6fc31534a39597200d5dca1e89c564..dfb3038b24c6097e37edd230f43de29468415f51 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 7f989523e3cb9d9fe807fc58ac6baa1eaec27bcc..c501f7f2029780239f6169e867b547eccefea77e 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 55312665a2ed3ea8d816487d43eb5b63fa6e65e5..4ee73548a5b458ed6e5e043fb5922dcb752cb126 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 7f8830d67c02b9d81444a29c3fd20afa37aa96f7..8cb7c392e50c074c4b6b2523bee17f0953d75acb 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 664da88553ae226357e3108397dc13cbb460b0af..214b85e7e7315b2f0f1d195c57dcd3693c6f71e7 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 cb240a6ec67b932c8760a526499166501117f962..73e683a1072e3ea1065208c1e692481272e1e484 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 e180077808808a4d8bd1bad5ee2b07fd83947d1e..8d95e1217c22acc269e780eccc3b5b3c655317a6 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 5b9d4d479fea9941a06cb1819dae156974d6449a..bacef95ee8c7193eb684fd71fc2cbe46354cc76f 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