mekosotto Claude Sonnet 4.6 commited on
Commit
1914360
·
1 Parent(s): a189a33

fix(fusion): drop unused protected_namespaces; pin tighter bound tests

Browse files
Files changed (2) hide show
  1. src/fusion/types.py +1 -2
  2. tests/fusion/test_types.py +22 -0
src/fusion/types.py CHANGED
@@ -3,7 +3,7 @@ from __future__ import annotations
3
 
4
  from typing import Annotated
5
 
6
- from pydantic import BaseModel, ConfigDict, Field
7
 
8
 
9
  class ModalityClassProb(BaseModel):
@@ -13,7 +13,6 @@ class ModalityClassProb(BaseModel):
13
 
14
  class ModalityPrediction(BaseModel):
15
  """One modality's classifier output (MRI or EEG)."""
16
- model_config = ConfigDict(protected_namespaces=())
17
 
18
  label_text: str
19
  label: int = Field(..., ge=0)
 
3
 
4
  from typing import Annotated
5
 
6
+ from pydantic import BaseModel, Field
7
 
8
 
9
  class ModalityClassProb(BaseModel):
 
13
 
14
  class ModalityPrediction(BaseModel):
15
  """One modality's classifier output (MRI or EEG)."""
 
16
 
17
  label_text: str
18
  label: int = Field(..., ge=0)
tests/fusion/test_types.py CHANGED
@@ -30,6 +30,20 @@ class TestModalityPrediction:
30
  with pytest.raises(ValidationError):
31
  ModalityPrediction(label_text="x", label=0, confidence=0.5, probabilities=[])
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  class TestClinicalScores:
35
  def test_all_optional(self) -> None:
@@ -40,6 +54,14 @@ class TestClinicalScores:
40
  with pytest.raises(ValidationError):
41
  ClinicalScores(mmse=42.0)
42
 
 
 
 
 
 
 
 
 
43
 
44
  class TestFusionInputOutput:
45
  def test_fusion_input_allows_no_modalities(self) -> None:
 
30
  with pytest.raises(ValidationError):
31
  ModalityPrediction(label_text="x", label=0, confidence=0.5, probabilities=[])
32
 
33
+ def test_rejects_probability_above_one(self) -> None:
34
+ with pytest.raises(ValidationError):
35
+ ModalityPrediction(
36
+ label_text="x", label=0, confidence=0.5,
37
+ probabilities=[{"label_text": "x", "probability": 1.5}],
38
+ )
39
+
40
+ def test_rejects_negative_label(self) -> None:
41
+ with pytest.raises(ValidationError):
42
+ ModalityPrediction(
43
+ label_text="x", label=-1, confidence=0.5,
44
+ probabilities=[{"label_text": "x", "probability": 0.5}],
45
+ )
46
+
47
 
48
  class TestClinicalScores:
49
  def test_all_optional(self) -> None:
 
54
  with pytest.raises(ValidationError):
55
  ClinicalScores(mmse=42.0)
56
 
57
+ def test_rejects_negative_mmse(self) -> None:
58
+ with pytest.raises(ValidationError):
59
+ ClinicalScores(mmse=-1.0)
60
+
61
+ def test_rejects_out_of_range_updrs(self) -> None:
62
+ with pytest.raises(ValidationError):
63
+ ClinicalScores(updrs=200.0)
64
+
65
 
66
  class TestFusionInputOutput:
67
  def test_fusion_input_allows_no_modalities(self) -> None: