Skip to content

Commit

Permalink
Handle ParamDict
Browse files Browse the repository at this point in the history
  • Loading branch information
ggalloni committed Sep 4, 2024
1 parent dc48e84 commit 7a568e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cobaya/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import ForwardRef, Optional, Union, List, Set

from cobaya.log import HasLogger, LoggedError, get_logger
from cobaya.typing import Any, InfoDict, InfoDictIn, empty_dict
from cobaya.typing import Any, InfoDict, InfoDictIn, ParamDict, empty_dict
from cobaya.tools import resolve_packages_path, load_module, get_base_classes, \
get_internal_class_component_name, deepcopy_where_possible, NumberWithUnits, VersionCheckError
from cobaya.conventions import kinds, cobaya_package, reserved_attributes
Expand Down Expand Up @@ -466,6 +466,8 @@ def _validate_type(self, expected_type, value):
if isinstance(expected_type, ForwardRef): # for custom types as ParamDict
if "Dict" in expected_type.__forward_arg__:
expected_type = dict
elif expected_type is ParamDict:
return isinstance(value, dict)
if expected_type is NumberWithUnits:
return isinstance(value, (int, float))
elif expected_type is int: # for numpy integers
Expand Down

0 comments on commit 7a568e7

Please sign in to comment.