mirror of
https://github.com/hanzoai/anomalib.git
synced 2026-10-30 18:48:11 +00:00
The previous commit was meant to remove .github/workflows and removed every tracked path instead — 892 files, the whole repo. This puts back the 874 that were never in scope; the eighteen workflow files stay gone, for the reasons that commit gives. Content is byte-identical to 9d2aec9 outside .github/workflows.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
"""Unit tests for WinCLIP's compositional prompt ensemble."""
|
|
|
|
# Copyright (C) 2022-2025 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from anomalib.models.image.winclip.prompting import create_prompt_ensemble
|
|
|
|
|
|
class TestCreatePromptEnsemble:
|
|
"""Test the create_prompt_ensemble function."""
|
|
|
|
@staticmethod
|
|
def test_length() -> None:
|
|
"""Test if the correct number of normal and anomalous prompts are created."""
|
|
normal_prompts, anomalous_prompts = create_prompt_ensemble("object")
|
|
assert len(normal_prompts) == 147
|
|
assert len(anomalous_prompts) == 84
|
|
|
|
@staticmethod
|
|
def test_class_name_in_every_prompt() -> None:
|
|
"""Test prompt ensemble creation."""
|
|
normal_prompts, anomalous_prompts = create_prompt_ensemble("item")
|
|
assert all("item" in prompt for prompt in normal_prompts)
|
|
assert all("item" in prompt for prompt in anomalous_prompts)
|
|
|
|
@staticmethod
|
|
def test_called_without_class_name() -> None:
|
|
"""Test prompt ensemble creation without class name."""
|
|
normal_prompts, anomalous_prompts = create_prompt_ensemble()
|
|
assert all("object" in prompt for prompt in normal_prompts)
|
|
assert all("object" in prompt for prompt in anomalous_prompts)
|