You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One pattern is to replace your base config with a dataclass:
In [8]: @DataClass
...: class ModelConfig:
...: sources: list[str]
...: model_name: str = "sarix"
...: fit_locations_separately: bool = False
...: # model parameters
...: p: int = 1
...: P: 0 = 0
...: #etc
...: power_transform: str = None
And create a helper function that returns a ModelConfig instance based on passed parameters:
In [9]: def get_model_config(sources: list[str], fit_locations_separately: bool, p:int) -> ModelConf
...: ig:
...: model_config = ModelConfig(sources=sources, fit_locations_separately=fit_locations_separ
...: ately, p=p)
...: return model_config
And then in the code that parses args:
mc = get_model_config(["hhs"], fit_locations_separately=True, p=5)
The dataclass attributes work in the same tidy way as the SimpleNamespace
In [11]: mc
Out[11]: ModelConfig(sources=['hhs'], model_name='sarix', fit_locations_separately=True, p=5, P=0, power_transform=None)
define base_config as a dataclass and then instantiate it with model_name, p, power_transform, etc. as needed
The text was updated successfully, but these errors were encountered: