dantro.mixins.indexing module¶
This module implement mixin classes that provide indexing capabilities
-
class
dantro.mixins.indexing.IntegerItemAccessMixin[source]¶ Bases:
objectThis mixin allows accessing items via integer keys and also supports calling the __contains__ magic method with integer keys. It is meant to be used to add features to an AbstractDataGroup-derived class, although this is not enforced.
NOTE The __setitem__ method is not covered by this!
- NOTE The class using this mixin has to implement index access methods and
the __contains__ magic method independently from this mixin!
-
__getitem__(key: Union[str, int])[source]¶ Adjusts the parent method to allow integer key item access
-
class
dantro.mixins.indexing.PaddedIntegerItemAccessMixin[source]¶ Bases:
dantro.mixins.indexing.IntegerItemAccessMixinThis mixin allows accessing items via integer keys that map to members that have a zero-padded integer name. It can only be used as mixin for AbstractDataGroup-derived classes!
The __contains__ magic method is also supported in this mixin.
- NOTE The class using this mixin has to implement index access methods and
the __contains__ magic method independently from this mixin!
-
_PADDED_INT_KEY_WIDTH= None¶
-
_PADDED_INT_FSTR= None¶
-
_PADDED_INT_STRICT_CHECKING= True¶
-
_PADDED_INT_MAX_VAL= None¶
-
property
padded_int_key_width¶ Returns the width of the zero-padded integer key or None, if it is not already specified.
-
_parse_key(key: Union[str, int]) → str[source]¶ Parse a potentially integer key to a zero-padded string
-
__contains__(key: Union[str, int]) → bool¶ Adjusts the parent method to allow checking for integers
-
__delitem__(key: Union[str, int])¶ Adjusts the parent method to allow item deletion by integer key
-
__getitem__(key: Union[str, int])¶ Adjusts the parent method to allow integer key item access
-
_check_cont(cont: dantro.abc.AbstractDataContainer) → None[source]¶ This method is invoked when adding a member to a group and makes sure the name of the added group is correctly zero-padded.
Also, upon first call, communicates the zero padded integer key width, i.e.: the length of the container name, to the PaddedIntegerItemAccessMixin.
- Parameters
cont – The member container to add
- Returns
None: No return value needed