From cf34906a955aa15990acaf4873147a015f374405 Mon Sep 17 00:00:00 2001 From: James Meakin <12661555+jmsmkn@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:19:34 +0200 Subject: [PATCH] Drop Python 3.8 --- .github/workflows/ci.yml | 4 ++-- .pre-commit-config.yaml | 2 +- HISTORY.md | 1 + README.md | 5 ++--- docs/conf.py | 5 ++--- evalutils/roc.py | 14 +++++++------- evalutils/scorers.py | 11 +++++------ evalutils/stats.py | 6 +++--- pyproject.toml | 7 +++---- tests/test_stats.py | 8 ++------ 10 files changed, 28 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 402aea8..f57af64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - published env: - MINIMUM_PYTHON_VERSION: "3.8" + MINIMUM_PYTHON_VERSION: "3.9" concurrency: group: ${{ github.head_ref || github.run_id }} @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 - name: Setup Python ${{ matrix.python-version }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d493ee0..7448ef0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: hooks: - id: pyupgrade language: python - args: [--py38-plus] + args: [--py39-plus] - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: diff --git a/HISTORY.md b/HISTORY.md index 637c227..0db72ab 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,7 @@ - Removed templating - Added support for Python 3.12 +- Dropped support for Python 3.8 ## 0.4.2 (2023-06-09) diff --git a/README.md b/README.md index 82cbbdb..431d3c2 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,12 @@ containers for grand-challenge.org. ## Features - - Validation of submitted predictions - - Interface to SciKit-Learn metrics and Pandas aggregations + - Interface to SciKit-Learn metrics - Bounding box annotations with Jaccard Index calculations ## Getting Started -[evalutils](https://github.com/comic/evalutils) requires Python 3.8 or +[evalutils](https://github.com/comic/evalutils) requires Python 3.9 or above, and can be installed from `pip`. Please see the [Getting Started](https://comic.github.io/evalutils/usage.html) documentation for more details. diff --git a/docs/conf.py b/docs/conf.py index 3750d09..f6df797 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,7 +20,6 @@ import os import sys from importlib.metadata import version as _get_version -from typing import Dict, List evalutils_version = _get_version("evalutils") @@ -111,7 +110,7 @@ def setup(app): # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path: List[str] = [] +html_static_path: list[str] = [] # -- Options for HTMLHelp output --------------------------------------- @@ -122,7 +121,7 @@ def setup(app): # -- Options for LaTeX output ------------------------------------------ -latex_elements: Dict[str, str] = { +latex_elements: dict[str, str] = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', diff --git a/evalutils/roc.py b/evalutils/roc.py index db87463..9a08e4d 100644 --- a/evalutils/roc.py +++ b/evalutils/roc.py @@ -1,4 +1,4 @@ -from typing import List, NamedTuple, Tuple +from typing import NamedTuple import numpy as np from numpy import ndarray @@ -55,9 +55,9 @@ def get_bootstrapped_roc_ci_curves( """ rng_seed = 40 # control reproducibility - bootstrapped_az_scores: List[float] = [] + bootstrapped_az_scores: list[float] = [] - tprs_list: List[ndarray] = [] + tprs_list: list[ndarray] = [] base_fpr = np.linspace(0, 1, 101) rng = np.random.RandomState(rng_seed) @@ -114,7 +114,7 @@ def get_bootstrapped_roc_ci_curves( def average_roc_curves( - roc_curves: List[BootstrappedROCCICurves], bins: int = 200 + roc_curves: list[BootstrappedROCCICurves], bins: int = 200 ) -> BootstrappedROCCICurves: """ Averages ROC curves using vertical averaging (fixed FP rates), @@ -237,8 +237,8 @@ def get_bootstrapped_ci_point_error( The fpr vals (one per ROC point) representing the highest val in CI """ rng_seed = 40 # control reproducibility - tprs_list: List[ndarray] = [] - fprs_list: List[ndarray] = [] + tprs_list: list[ndarray] = [] + fprs_list: list[ndarray] = [] rng = np.random.RandomState(rng_seed) num_possible_scores = len(np.unique(y_score)) @@ -302,7 +302,7 @@ def get_bootstrapped_ci_point_error( def _get_confidence_intervals( *, n_bootstraps: int, one_sided_ci: float, points_array -) -> Tuple[ndarray, ndarray]: +) -> tuple[ndarray, ndarray]: ci_upper = [] ci_lower = [] diff --git a/evalutils/scorers.py b/evalutils/scorers.py index 897240a..4b2b2fd 100644 --- a/evalutils/scorers.py +++ b/evalutils/scorers.py @@ -1,5 +1,4 @@ from collections import namedtuple -from typing import List, Tuple from numpy import array from sklearn.neighbors import BallTree @@ -11,8 +10,8 @@ def score_detection( *, - ground_truth: List[Tuple[float, ...]], - predictions: List[Tuple[float, ...]], + ground_truth: list[tuple[float, ...]], + predictions: list[tuple[float, ...]], radius: float = 1.0, ) -> DetectionScore: """ @@ -97,10 +96,10 @@ def score_detection( def find_hits_for_targets( *, - targets: List[Tuple[float, ...]], - predictions: List[Tuple[float, ...]], + targets: list[tuple[float, ...]], + predictions: list[tuple[float, ...]], radius: float, -) -> List[Tuple[int, ...]]: +) -> list[tuple[int, ...]]: """ Generates a list of the predicted points that are within a radius r of the targets. The indicies are returned in sorted order, from closest to diff --git a/evalutils/stats.py b/evalutils/stats.py index a917178..144f9f9 100644 --- a/evalutils/stats.py +++ b/evalutils/stats.py @@ -1,5 +1,5 @@ from collections import namedtuple -from typing import List, Optional, Tuple, Union +from typing import Optional, Union import numpy as np from numpy import ndarray @@ -11,12 +11,12 @@ ) VOXELSPACING_TYPE = Optional[ - Union[Tuple[Union[float, int], ...], List[Union[float, int]], float, int] + Union[tuple[Union[float, int], ...], list[Union[float, int]], float, int] ] def calculate_confusion_matrix( - y_true: ndarray, y_pred: ndarray, labels: List[int] + y_true: ndarray, y_pred: ndarray, labels: list[int] ) -> ndarray: """ Efficient confusion matrix calculation, based on sklearn interface diff --git a/pyproject.toml b/pyproject.toml index f395226..cdcd189 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ evalutils = "evalutils.__main__:main" [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" scipy = "*" numpy = "*" scikit-learn = "*" @@ -42,7 +42,7 @@ line_length = 79 [tool.black] line-length = 79 -target-version = ['py38'] +target-version = ['py39'] [tool.pytest.ini_options] minversion = "6.0" @@ -64,11 +64,10 @@ filterwarnings = [ legacy_tox_ini = """ [tox] isolated_build = True -envlist = py38, py39, py310, py311, py312 +envlist = py39, py310, py311, py312 [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 diff --git a/tests/test_stats.py b/tests/test_stats.py index 2534b66..1dff498 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -1,5 +1,3 @@ -from typing import Tuple - import numpy as np import pytest import scipy.ndimage as ndimage @@ -20,13 +18,11 @@ def reset_seeds(): @pytest.mark.parametrize( "shape, dtype", (((12,), np.int32), ((10, 2), np.int32), ((10,), np.int8)) ) -def test_edt32_indices_wrong_format(shape: Tuple[int, ...], dtype: np.dtype): +def test_edt32_indices_wrong_format(shape: tuple[int, ...], dtype: np.dtype): x = np.random.random((10,)) > 0.5 indices = np.zeros((x.ndim,) + shape, dtype=dtype) with pytest.raises(RuntimeError): - stats.distance_transform_edt_float32( - input=x, sampling=[1.2], indices=indices - ) + stats.distance_transform_edt(input=x, sampling=[1.2], indices=indices) @pytest.mark.parametrize(