Skip to content

Commit 23b87a8

Browse files
committed
Update deprecated type hints
1 parent 3e83783 commit 23b87a8

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/stamp/statistics/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from collections.abc import Sequence
12
from pathlib import Path
2-
from typing import NewType, Sequence
3+
from typing import NewType
34

45
import numpy as np
56
import pandas as pd

src/stamp/statistics/prc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# %%
2-
from typing import NamedTuple, Optional, Sequence, Tuple, TypeAlias
2+
from collections.abc import Sequence
3+
from typing import NamedTuple, TypeAlias
34

45
import numpy as np
56
import numpy.typing as npt
@@ -30,7 +31,7 @@ def _plot_bootstrapped_pr_curve(
3031
y_true: Bool[np.ndarray, "sample"], # noqa: F821
3132
y_score: Float[np.ndarray, "sample"], # noqa: F821
3233
n_bootstrap_samples: int,
33-
) -> Tuple[_Auprc, _Auprc95CILower, _Auprc95CIUpper]:
34+
) -> tuple[_Auprc, _Auprc95CILower, _Auprc95CIUpper]:
3435
"""Plots a precision-recall curve with bootstrap interval.
3536
3637
Args:
@@ -138,8 +139,8 @@ def plot_multiple_decorated_precision_recall_curves(
138139
ax: Axes,
139140
y_trues: Sequence[npt.NDArray[np.bool_]],
140141
y_scores: Sequence[npt.NDArray[np.float64]],
141-
title: Optional[str] = None,
142-
) -> Tuple[float, float]:
142+
title: str | None = None,
143+
) -> tuple[float, float]:
143144
"""Plots a family of precision-recall curves.
144145
145146
Args:

src/stamp/statistics/roc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import NamedTuple, Optional, Sequence, Tuple, TypeAlias, cast
1+
from collections.abc import Sequence
2+
from typing import NamedTuple, TypeAlias, cast
23

34
import numpy as np
45
import numpy.typing as npt
@@ -67,7 +68,7 @@ def plot_single_decorated_roc_curve(
6768
ax.set_ylabel("True Positive Rate")
6869

6970

70-
def _auc_str(auc: float, lower: Optional[float], upper: Optional[float]) -> str:
71+
def _auc_str(auc: float, lower: float, upper: float) -> str:
7172
return f"AUC = {auc:0.2f} [{lower:0.2f}-{upper:0.2f}]"
7273

7374

@@ -82,8 +83,8 @@ def plot_multiple_decorated_roc_curves(
8283
y_trues: Sequence[npt.NDArray[np.bool_]],
8384
y_scores: Sequence[npt.NDArray[np.float64]],
8485
*,
85-
title: Optional[str] = None,
86-
n_bootstrap_samples: Optional[int] = None,
86+
title: str | None = None,
87+
n_bootstrap_samples: int | None = None,
8788
) -> None:
8889
"""Plots a family of ROC curves.
8990
@@ -156,7 +157,7 @@ def _plot_bootstrapped_roc_curve(
156157
y_score: Float[np.ndarray, "sample"], # noqa: F821
157158
n_bootstrap_samples: int,
158159
threshold_cmap: Colormap | None,
159-
) -> Tuple[_Auc, _Auc95CILower, _Auc95CIUpper]:
160+
) -> tuple[_Auc, _Auc95CILower, _Auc95CIUpper]:
160161
"""Plots a roc curve with bootstrap interval.
161162
162163
Args:

0 commit comments

Comments
 (0)