Skip to content

Commit

Permalink
Change enforce_types to private attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ggalloni committed Oct 2, 2024
1 parent 4cdd11e commit 436e70d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cobaya/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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,
Expand All @@ -73,7 +73,7 @@ def __init__(
params,
tuple_params,
):
if self.enforce_types:
if self._enforce_types:
super().validate_attributes()


Expand Down

0 comments on commit 436e70d

Please sign in to comment.