Skip to content

Commit

Permalink
python 3.9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Mar 26, 2024
1 parent 3201fdd commit 761a2bf
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_newpolygons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from traceback import print_exception
import warnings
from typing import Optional, List
from typing import Optional, List, Union

from PIL import Image

Expand Down Expand Up @@ -96,7 +96,7 @@ def _test_krakencli(self, extractor_mock: Mock, *, args, force_no_legacy: bool=F
for cl in extractor_mock.mock_calls:
self.assertEqual(cl[2]["legacy"], expect_legacy)

def _test_ketoscli(self, *, args, expect_legacy: bool, check_exit_code: Optional[int|List[int]]=0, patching_dir="kraken.lib.dataset.recognition"):
def _test_ketoscli(self, *, args, expect_legacy: bool, check_exit_code: Optional[Union[int, List[int]]] = 0, patching_dir="kraken.lib.dataset.recognition"):
"""
Base recipe for testing ketos_cli with a given polygon extraction method
"""
Expand Down Expand Up @@ -336,9 +336,13 @@ def test_ketoscli_pretrain_old_model(self):
)


def _assertWarnsWhenTrainingArrow(
self, model: str, *dset: str, from_model: str|None=None, force_legacy: bool=False,
expect_warning_msgs: list[str]=[], expect_not_warning_msgs: list[str]=[]):
def _assertWarnsWhenTrainingArrow(self,
model: str,
*dset: str,
from_model: Optional[str] = None,
force_legacy: bool = False,
expect_warning_msgs: List[str] = [],
expect_not_warning_msgs: List[str] = []):

args = ['-f', 'binary', '-N', '1', '-q', 'fixed', '-o', model, *dset]
if force_legacy:
Expand Down Expand Up @@ -446,4 +450,4 @@ def test_ketos_mixed_arrow_train_new(self):
patching_dir="kraken.lib.arrow_dataset",
)

self._assertWarnsWhenTrainingArrow(mfp, dset, self.arrow_data, force_legacy=True, expect_warning_msgs=["WARNING Mixed legacy polygon", "WARNING Setting dataset legacy polygon status to False based on training set"], expect_not_warning_msgs=["model will be flagged to use legacy"])
self._assertWarnsWhenTrainingArrow(mfp, dset, self.arrow_data, force_legacy=True, expect_warning_msgs=["WARNING Mixed legacy polygon", "WARNING Setting dataset legacy polygon status to False based on training set"], expect_not_warning_msgs=["model will be flagged to use legacy"])

0 comments on commit 761a2bf

Please sign in to comment.