Skip to content

Commit

Permalink
Improved coverage, explicitly set mdformat github version
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainTrojan committed Dec 16, 2024
1 parent 555fe2a commit 9fe0b79
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ repos:
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gfm
- mdformat-gfm==0.3.7
2 changes: 1 addition & 1 deletion tests/configs/reid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ model:
params:
loss_name: SupConLoss
embedding_size: *embedding_size
cross_batch_memory_size: &memory_size 200
cross_batch_memory_size: &memory_size 4
attached_to: GhostFaceNetsV2

metrics:
Expand Down
29 changes: 28 additions & 1 deletion tests/integration/test_reid.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def clear_files():


@pytest.mark.parametrize("loss_name", not_class_based_losses)
def test_reid(opts: dict[str, Any], infer_path: Path, loss_name: str):
def test_available_losses(
opts: dict[str, Any], infer_path: Path, loss_name: str
):
config_file = "tests/configs/reid.yaml"
opts["model.losses.0.params.loss_name"] = loss_name

Expand All @@ -113,3 +115,28 @@ def test_reid(opts: dict[str, Any], infer_path: Path, loss_name: str):
assert len(list(infer_path.iterdir())) == 0
model.infer(view="val", save_dir=infer_path)
assert infer_path.exists()


@pytest.mark.parametrize("loss_name", CLASS_EMBEDDING_LOSSES)
@pytest.mark.parametrize("num_classes", [-2, NUM_INDIVIDUALS])
def test_unsupported_class_based_losses(
opts: dict[str, Any], loss_name: str, num_classes: int
):
config_file = "tests/configs/reid.yaml"
opts["model.losses.0.params.loss_name"] = loss_name
opts["model.losses.0.params.num_classes"] = num_classes
opts["model.nodes.0.params.num_classes"] = num_classes

with pytest.raises(ValueError):
model = LuxonisModel(config_file, opts)
model.train()

Check warning on line 132 in tests/integration/test_reid.py

View check run for this annotation

Codecov / codecov/patch

tests/integration/test_reid.py#L132

Added line #L132 was not covered by tests


@pytest.mark.parametrize("loss_name", ["NonExistentLoss"])
def test_nonexistent_losses(opts: dict[str, Any], loss_name: str):
config_file = "tests/configs/reid.yaml"
opts["model.losses.0.params.loss_name"] = loss_name

with pytest.raises(ValueError):
model = LuxonisModel(config_file, opts)
model.train()

Check warning on line 142 in tests/integration/test_reid.py

View check run for this annotation

Codecov / codecov/patch

tests/integration/test_reid.py#L142

Added line #L142 was not covered by tests

0 comments on commit 9fe0b79

Please sign in to comment.