mirror of
https://github.com/macaodha/batdetect2.git
synced 2026-01-10 17:19:34 +01:00
Update tests
This commit is contained in:
parent
b7ae526071
commit
95a884ea16
@ -33,7 +33,8 @@ class TargetClassConfig(BaseConfig):
|
||||
alias="match_if",
|
||||
default=None,
|
||||
)
|
||||
tags: Optional[List[data.Tag]] = None
|
||||
|
||||
tags: Optional[List[data.Tag]] = Field(default=None, exclude=True)
|
||||
|
||||
assign_tags: List[data.Tag] = Field(default_factory=list)
|
||||
|
||||
@ -42,20 +43,24 @@ class TargetClassConfig(BaseConfig):
|
||||
_match_if: SoundEventConditionConfig = PrivateAttr()
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _process_shorthands(self) -> "TargetClassConfig":
|
||||
def _process_tags(self) -> "TargetClassConfig":
|
||||
if self.tags and self.condition_input:
|
||||
raise ValueError("Use either 'tags' or 'match_if', not both.")
|
||||
|
||||
if self.condition_input:
|
||||
final_condition = self.condition_input
|
||||
elif self.tags:
|
||||
final_condition = HasAllTagsConfig(tags=self.tags)
|
||||
else:
|
||||
if self.condition_input is not None:
|
||||
self._match_if = self.condition_input
|
||||
return self
|
||||
|
||||
if self.tags is None:
|
||||
raise ValueError(
|
||||
f"Class '{self.name}' must have a 'tags' or 'match_if' rule."
|
||||
)
|
||||
|
||||
self._match_if = final_condition
|
||||
self._match_if = HasAllTagsConfig(tags=self.tags)
|
||||
|
||||
if not self.assign_tags:
|
||||
self.assign_tags = self.tags
|
||||
|
||||
return self
|
||||
|
||||
@computed_field
|
||||
|
||||
@ -26,6 +26,7 @@ clip = data.Clip(
|
||||
def test_generated_heatmap_are_non_zero_at_correct_positions(
|
||||
sample_target_config: TargetConfig,
|
||||
pippip_tag: data.Tag,
|
||||
bat_tag: data.Tag,
|
||||
):
|
||||
config = sample_target_config.model_copy(
|
||||
update=dict(
|
||||
@ -48,7 +49,7 @@ def test_generated_heatmap_are_non_zero_at_correct_positions(
|
||||
coordinates=[10, 10, 20, 30],
|
||||
),
|
||||
),
|
||||
tags=[data.Tag(key=pippip_tag.key, value=pippip_tag.value)], # type: ignore
|
||||
tags=[pippip_tag, bat_tag],
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user