ctapipe is not stable yet, so expect large and rapid changes to structure and functionality as we explore various design choices before the 1.0 release.

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 of value_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.

item_from_string(s)

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) and name under which the descriptor has been assigned.

element_error(obj: Any, element: Any, validator: Any, side: str = 'Values') None[source]#
from_string(s: str) dict[K, V] | None[source]#

Load value from a single string

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().

subclass_init(cls: type[Any]) None[source]#
validate(obj: t.Any, value: t.Any) dict[K, V] | None[source]#
validate_elements(obj: t.Any, value: dict[t.Any, t.Any]) dict[K, V] | None[source]#