Coverage for src / autoencodix / configs / ontix_config.py: 58%
12 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-21 10:09 +0200
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-21 10:09 +0200
1from typing import Literal
2from pydantic import Field, model_validator
3from .default_config import DefaultConfig
6class OntixConfig(DefaultConfig):
7 """
8 A specialized configuration for Ontix that only allows scaling methods
9 guaranteeing non-negative outputs.
10 """
12 # 1. Override the top-level 'scaling' attribute
13 scaling: Literal["MINMAX", "NONE", "NOTSET", "LOG1P"] = Field(
14 default="MINMAX",
15 description="Global scaling method. For Ontix, only 'MINMAX' and 'NONE' are allowed, because we need positive values only",
16 )
18 # 2. Add a validator for the nested 'scaling' attributes
19 @model_validator(mode="after")
20 def validate_nested_scaling(self) -> "OntixConfig":
21 """
22 Ensures that any scaling method set within DataInfo is also a valid
23 positive-value scaler.
24 """
25 # Define the set of allowed scaling methods
26 allowed_scalers = {"MINMAX", "NONE", "NOTSET"}
28 # Loop through each data modality defined in the data_config
29 for modality_name, data_info in self.data_config.data_info.items():
30 if data_info.scaling not in allowed_scalers:
31 raise ValueError(
32 f"Invalid scaling '{data_info.scaling}' for modality '{modality_name}'. "
33 f"OntixConfig only permits {list(allowed_scalers)}."
34 )
35 return self