diff --git a/cobaya/component.py b/cobaya/component.py index 001be5e7..c1b5cdde 100644 --- a/cobaya/component.py +++ b/cobaya/component.py @@ -332,7 +332,7 @@ class CobayaComponent(HasLogger, HasDefaults): _at_resume_prefer_new: List[str] = ["version"] _at_resume_prefer_old: List[str] = [] - enforce_types: bool = False + _enforce_types: bool = False def __init__(self, info: InfoDictIn = empty_dict, name: Optional[str] = None, @@ -369,7 +369,7 @@ def __init__(self, info: InfoDictIn = empty_dict, " are set (%s, %s)", self, e) raise - if self.enforce_types: + if self._enforce_types: self.validate_attributes() def set_timing_on(self, on): diff --git a/tests/test_type_checking.py b/tests/test_type_checking.py index 65fd10a0..2a921627 100644 --- a/tests/test_type_checking.py +++ b/tests/test_type_checking.py @@ -25,7 +25,7 @@ class GenericLike(Likelihood): params: Dict[str, List[float]] = {"a": [0.0, 1.0], "b": [0, 1]} tuple_params: Tuple[float, float] = (0.0, 1.0) - enforce_types = True + _enforce_types = True def logp(self, **params_values): return 1 @@ -34,7 +34,7 @@ def logp(self, **params_values): def test_sampler_types(): original_info: InputDict = { "likelihood": {"like": GenericLike}, - "sampler": {"mcmc": {"max_samples": 1, "enforce_types": True}}, + "sampler": {"mcmc": {"max_samples": 1}}, } _ = run(original_info) @@ -57,7 +57,7 @@ class GenericComponent(CobayaComponent): params: Dict[str, List[float]] = {"a": [0.0, 1.0], "b": [0, 1]} tuple_params: Tuple[float, float] = (0.0, 1.0) - enforce_types = True + _enforce_types = True def __init__( self, @@ -73,7 +73,7 @@ def __init__( params, tuple_params, ): - if self.enforce_types: + if self._enforce_types: super().validate_attributes()