Dict#
- class ctapipe.core.traits.Dict(klass: type[T] = ..., args: tuple[Any, ...] | None = ..., kw: dict[str, Any] | None = ..., allow_none: Literal[False] = ..., read_only: bool | None = ..., help: str | None = ..., **kwargs: Any)#
- class ctapipe.core.traits.Dict(klass: type[T] = ..., args: tuple[Any, ...] | None = ..., kw: dict[str, Any] | None = ..., allow_none: Literal[True] = ..., read_only: bool | None = ..., help: str | None = ..., **kwargs: Any)
- class ctapipe.core.traits.Dict(klass: str | None = ..., args: tuple[Any, ...] | None = ..., kw: dict[str, Any] | None = ..., allow_none: Literal[False] = ..., read_only: bool | None = ..., help: str | None = ..., **kwargs: Any)
- class ctapipe.core.traits.Dict(klass: str | None = ..., args: tuple[Any, ...] | None = ..., kw: dict[str, Any] | None = ..., allow_none: Literal[True] = ..., read_only: bool | None = ..., help: str | None = ..., **kwargs: Any)
Bases:
Instance
[dict[K, V]
]An instance of a Python dict.
One or more traits can be passed to the constructor to validate the keys and/or values of the dict. If you need more detailed validation, you may use a custom validator method.
Changed in version 5.0: Added key_trait for validating dict keys.
Changed in version 5.0: Deprecated ambiguous
trait
,traits
args in favor ofvalue_trait
,per_key_traits
.Methods Summary
class_init
(cls, name)Part of the initialization which may depend on the underlying HasDescriptors class.
element_error
(obj, element, validator[, side])from_string
(s)Load value from a single string
from_string_list
(s_list)Return a dict from a list of config strings.
Cast a single-key dict from a string.
subclass_init
(cls)validate
(obj, value)validate_elements
(obj, value)Methods Documentation
- class_init(cls: type[Any], name: str | None) None [source]#
Part of the initialization which may depend on the underlying HasDescriptors class.
It is typically overloaded for specific types.
This method is called by
MetaHasDescriptors.__init__()
passing the class (cls
) andname
under which the descriptor has been assigned.
- from_string_list(s_list: list[str]) Any [source]#
Return a dict from a list of config strings.
This is where we parse CLI configuration.
Each item should have the form
"key=value"
.item parsing is done in
item_from_string()
.
- item_from_string(s: str) dict[K, V] [source]#
Cast a single-key dict from a string.
Evaluated when parsing CLI configuration from a string.
Dicts expect strings of the form key=value.
Returns a one-key dictionary, which will be merged in
from_string_list()
.