Skip to content

Commit

Permalink
Drop Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn committed Aug 7, 2024
1 parent 604162a commit cf34906
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Removed templating
- Added support for Python 3.12
- Dropped support for Python 3.8

## 0.4.2 (2023-06-09)

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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 ---------------------------------------
Expand All @@ -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',
Expand Down
14 changes: 7 additions & 7 deletions evalutils/roc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, NamedTuple, Tuple
from typing import NamedTuple

import numpy as np
from numpy import ndarray
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 = []

Expand Down
11 changes: 5 additions & 6 deletions evalutils/scorers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import namedtuple
from typing import List, Tuple

from numpy import array
from sklearn.neighbors import BallTree
Expand All @@ -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:
"""
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions evalutils/stats.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
evalutils = "evalutils.__main__:main"

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
scipy = "*"
numpy = "*"
scikit-learn = "*"
Expand All @@ -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"
Expand All @@ -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
Expand Down
8 changes: 2 additions & 6 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Tuple

import numpy as np
import pytest
import scipy.ndimage as ndimage
Expand All @@ -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(
Expand Down

0 comments on commit cf34906

Please sign in to comment.