Skip to content

Commit 40ab6c9

Browse files
committed
mypy clean
1 parent a3675c0 commit 40ab6c9

19 files changed

Lines changed: 122 additions & 98 deletions

mlscorecheck/aggregated/_fold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def calculate_scores(
9797
else round_scores(self.scores, rounding_decimals)
9898
)
9999

100-
def set_initial_values(self, scores):
100+
def set_initial_values(self, scores: dict) -> None:
101101
"""
102102
Sets the initial values for the tp and tn variables
103103

mlscorecheck/aggregated/_fold_enumeration.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ def multiclass_fold_partitioning_generator_22(
408408
yield {0: (c_00, n0 - c_00), 1: (c0 - c_00, n1 - c0 + c_00)}
409409

410410

411-
def multiclass_fold_partitioning_generator_2n(n0: int, n1: int, cs: list):
411+
from typing import Iterator
412+
413+
414+
def multiclass_fold_partitioning_generator_2n(n0: int, n1: int, cs: list) -> Iterator[dict]:
412415
"""
413416
Generates the configurations for two folds of cardinalities n0 and n1 and a list
414417
of classes with sizes in cs
@@ -431,7 +434,7 @@ def multiclass_fold_partitioning_generator_2n(n0: int, n1: int, cs: list):
431434
yield {0: (part[0][0], *(part_deep[0])), 1: (part[1][0], *(part_deep[1]))}
432435

433436

434-
def multiclass_fold_partitioning_generator_kn(ns: list, cs: list):
437+
def multiclass_fold_partitioning_generator_kn(ns: list, cs: list) -> Iterator[dict]:
435438
"""
436439
Generates the configurations for a list of folds of sizes ns and a list
437440
of classes with sizes in cs

mlscorecheck/aggregated/_generate_problems.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def generate_folding(
6262
max_folds: int = 10,
6363
max_repeats: int = 5,
6464
strategies: list | None = None,
65-
random_state=None,
65+
random_state: int | np.random.RandomState | None = None,
6666
no_folds: bool = False,
6767
) -> dict:
6868
"""
@@ -113,7 +113,7 @@ def generate_evaluation( # pylint: disable=too-many-locals
113113
strategies: list | None = None,
114114
feasible_fold_score_bounds: bool | None = None,
115115
aggregation: str | None = None,
116-
random_state=None,
116+
random_state: int | np.random.RandomState | None = None,
117117
return_scores: bool = False,
118118
rounding_decimals: int | None = None,
119119
no_name: bool = False,
@@ -222,7 +222,7 @@ def generate_experiment(
222222
evaluation_params: dict | None = None,
223223
feasible_dataset_score_bounds: bool | None = None,
224224
aggregation: str | None = None,
225-
random_state=None,
225+
random_state: int | np.random.RandomState | None = None,
226226
return_scores: bool = False,
227227
rounding_decimals: int | None = None,
228228
score_subset: list | None = None,
@@ -332,8 +332,12 @@ def get_dataset_score_bounds(
332332

333333

334334
def generate_scores_for_testsets(
335-
testsets, rounding_decimals=None, subset=None, random_state=None, aggregation="mos"
336-
):
335+
testsets: list,
336+
rounding_decimals: int | None = None,
337+
subset: list | None = None,
338+
random_state: int | np.random.RandomState | None = None,
339+
aggregation: str = "mos"
340+
) -> dict:
337341
"""
338342
Sample scores for testsets
339343
@@ -375,18 +379,18 @@ def generate_scores_for_testsets(
375379

376380
def generate_dataset_folding_multiclass(
377381
*,
378-
random_state=None,
379-
max_n_classes=5,
380-
min_n_classes=3,
381-
max_class_size=200,
382-
min_class_size=10,
383-
max_n_folds=5,
384-
max_n_repeats=3,
385-
average=None,
386-
aggregation=None,
387-
rounding_decimals=None,
388-
subset=None,
389-
):
382+
random_state: int | np.random.RandomState | None = None,
383+
max_n_classes: int = 5,
384+
min_n_classes: int = 3,
385+
max_class_size: int = 200,
386+
min_class_size: int = 10,
387+
max_n_folds: int = 5,
388+
max_n_repeats: int = 3,
389+
average: str | None = None,
390+
aggregation: str | None = None,
391+
rounding_decimals: int | None = None,
392+
subset: list | None = None,
393+
) -> tuple:
390394
"""
391395
Generates a multiclass dataset and folding with scores
392396

mlscorecheck/check/binary/_check_1_testset_no_kfold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def check_1_testset_no_kfold(
1616
testset: dict,
1717
scores: dict,
18-
eps: float,
18+
eps: float | dict,
1919
*,
2020
numerical_tolerance: float = NUMERICAL_TOLERANCE,
2121
prefilter_by_pairs: bool = True,

mlscorecheck/check/binary/_check_n_datasets_mos_known_folds_mos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def check_n_datasets_mos_known_folds_mos(
1717
evaluations: list,
1818
scores: dict,
19-
eps: float,
19+
eps: float | dict,
2020
dataset_score_bounds: dict | None = None,
2121
*,
2222
solver_name: str | None = None,

mlscorecheck/check/binary/_check_n_testsets_mos_no_kfold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def check_n_testsets_mos_no_kfold(
1515
testsets: list,
1616
scores: dict,
17-
eps: float,
17+
eps: float | dict,
1818
*,
1919
testset_score_bounds: dict | None = None,
2020
solver_name: str | None = None,

mlscorecheck/check/binary/_check_n_testsets_som_no_kfold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def check_n_testsets_som_no_kfold(
1515
testsets: list,
1616
scores: dict,
17-
eps: float,
17+
eps: float | dict,
1818
*,
1919
numerical_tolerance: float = NUMERICAL_TOLERANCE,
2020
prefilter_by_pairs: bool = True,

mlscorecheck/check/bundles/retina/_chasedb1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ def check_chasedb1_vessel_aggregated_som(
165165

166166

167167
def check_chasedb1_vessel_aggregated(
168-
imageset,
168+
imageset: str | list,
169169
annotator: str,
170170
scores: dict,
171-
eps,
171+
eps: float | dict,
172172
*,
173173
score_bounds: dict | None = None,
174174
solver_name: str | None = None,
@@ -249,7 +249,7 @@ def check_chasedb1_vessel_image(
249249
image_identifier: str,
250250
annotator: str,
251251
scores: dict,
252-
eps,
252+
eps: float | dict,
253253
*,
254254
numerical_tolerance: float = NUMERICAL_TOLERANCE,
255255
) -> dict:

mlscorecheck/check/bundles/retina/_diaretdb0.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
]
1717

1818

19-
def _prepare_configuration_diaretdb0(subset: str, batch, class_name: str | list) -> list:
19+
def _prepare_configuration_diaretdb0(subset: str, batch: str | list, class_name: str | list) -> list:
2020
"""
2121
Prepare the testset specifications for a "one vs rest" setup
2222
@@ -52,10 +52,10 @@ def _prepare_configuration_diaretdb0(subset: str, batch, class_name: str | list)
5252

5353
def check_diaretdb0_class_som(
5454
subset: str,
55-
batch,
56-
class_name,
55+
batch: str | list,
56+
class_name: str | list,
5757
scores: dict,
58-
eps,
58+
eps: float | dict,
5959
*,
6060
numerical_tolerance: float = NUMERICAL_TOLERANCE,
6161
) -> dict:
@@ -130,10 +130,10 @@ def check_diaretdb0_class_som(
130130

131131
def check_diaretdb0_class_mos(
132132
subset: str,
133-
batch,
134-
class_name,
133+
batch: str | list,
134+
class_name: str | list,
135135
scores: dict,
136-
eps,
136+
eps: float | dict,
137137
*,
138138
score_bounds: dict | None = None,
139139
solver_name: str | None = None,
@@ -212,10 +212,10 @@ def check_diaretdb0_class_mos(
212212

213213
def check_diaretdb0_class(
214214
subset: str,
215-
batch,
216-
class_name,
215+
batch: str | list,
216+
class_name: str | list,
217217
scores: dict,
218-
eps,
218+
eps: float | dict,
219219
*,
220220
score_bounds: dict | None = None,
221221
solver_name: str | None = None,

mlscorecheck/check/bundles/retina/_diaretdb1.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ def _prepare_configuration_diaretdb1(
111111
def check_diaretdb1_class(
112112
*,
113113
subset: str,
114-
class_name,
114+
class_name: str,
115115
confidence: float,
116116
scores: dict,
117-
eps,
117+
eps: float | dict,
118118
numerical_tolerance: float = NUMERICAL_TOLERANCE,
119119
) -> dict:
120120
"""
@@ -196,11 +196,11 @@ def check_diaretdb1_class(
196196
def check_diaretdb1_segmentation_image_assumption(
197197
*,
198198
image_identifier: str,
199-
class_name,
199+
class_name: str,
200200
assumption: str,
201201
confidence: float,
202202
scores: dict,
203-
eps,
203+
eps: float | dict,
204204
numerical_tolerance: float = NUMERICAL_TOLERANCE,
205205
) -> dict:
206206
"""
@@ -275,10 +275,10 @@ def check_diaretdb1_segmentation_image_assumption(
275275
def check_diaretdb1_segmentation_image(
276276
*,
277277
image_identifier: str,
278-
class_name,
278+
class_name: str,
279279
confidence: float,
280280
scores: dict,
281-
eps,
281+
eps: float | dict,
282282
numerical_tolerance: float = NUMERICAL_TOLERANCE,
283283
) -> dict:
284284
"""
@@ -356,12 +356,12 @@ def check_diaretdb1_segmentation_image(
356356
def check_diaretdb1_segmentation_aggregated_assumption(
357357
*,
358358
subset: str,
359-
class_name,
359+
class_name: str,
360360
assumption: str,
361361
confidence: float,
362362
only_valid: bool,
363363
scores: dict,
364-
eps,
364+
eps: float | dict,
365365
score_bounds: dict | None = None,
366366
solver_name: str | None = None,
367367
timeout: int | None = None,
@@ -446,11 +446,11 @@ def check_diaretdb1_segmentation_aggregated_assumption(
446446
def check_diaretdb1_segmentation_aggregated(
447447
*,
448448
subset: str,
449-
class_name,
449+
class_name: str,
450450
confidence: float,
451451
only_valid: bool,
452452
scores: dict,
453-
eps,
453+
eps: float | dict,
454454
score_bounds: dict | None = None,
455455
solver_name: str | None = None,
456456
timeout: int | None = None,

0 commit comments

Comments
 (0)