ert
ert copied to clipboard
Refactor data source for GenKwConfig
To be able to distinguish between the source of data when instantiating GenKwConfig we need to speicify either it's sample_prior, forward_init or design_matrix. Currently we rely on setting some flags in GenKwConfig; nevertheless this causes a lots of unnecessary if statements to check what the GenKw really is. Therefore we should implement each sub init_source as @dataclass instead.
For instance:
@dataclass
class DesignMatrix:
name: Literal['design_matrix']= 'design_matrix'
@dataclass
class SamplePrior:
name: Literal['sample_prior']= 'sample_prior'
@dataclass
class ForwardInit:
name: Literal['init_file']= 'init_file'
init_file: str
@dataclass
class GenKwConfig(ParameterConfig):
....
init_source: Union[SamplePrior, ForwardInit, DesignMatrix] = SamplePrior()