tensorbay.utility.user¶
UserSequence, UserMutableSequence, UserMapping and UserMutableMapping.
UserSequence
is a user-defined wrapper around sequence objects.
UserMutableSequence
is a user-defined wrapper around mutable sequence objects.
UserMapping
is a user-defined wrapper around mapping objects.
UserMutableMapping
is a user-defined wrapper around mutable mapping objects.
- class tensorbay.utility.user.UserSequence(*args, **kwds)[source]¶
Bases:
Sequence
[tensorbay.utility.user._T
],tensorbay.utility.repr.ReprMixin
UserSequence is a user-defined wrapper around sequence objects.
- index(value: tensorbay.utility.user._T, start: int = 0, stop: int = 9223372036854775807) int [source]¶
Return the first index of the value.
- Parameters
value – The value to be found.
start – The start index of the subsequence.
stop – The end index of the subsequence.
- Returns
The First index of value.
- class tensorbay.utility.user.UserMutableSequence(*args, **kwds)[source]¶
Bases:
MutableSequence
[tensorbay.utility.user._T
],tensorbay.utility.user.UserSequence
[tensorbay.utility.user._T
]UserMutableSequence is a user-defined wrapper around mutable sequence objects.
- insert(index: int, value: tensorbay.utility.user._T) None [source]¶
Insert object before index.
- Parameters
index – Position of the mutable sequence.
value – Element to be inserted into the mutable sequence.
- append(value: tensorbay.utility.user._T) None [source]¶
Append object to the end of the mutable sequence.
- Parameters
value – Element to be appended to the mutable sequence.
- extend(values: Iterable[tensorbay.utility.user._T]) None [source]¶
Extend mutable sequence by appending elements from the iterable.
- Parameters
values – Elements to be Extended into the mutable sequence.
- class tensorbay.utility.user.UserMapping(*args, **kwds)[source]¶
Bases:
Mapping
[tensorbay.utility.user._K
,tensorbay.utility.user._V
],tensorbay.utility.repr.ReprMixin
UserMapping is a user-defined wrapper around mapping objects.
- get(key: tensorbay.utility.user._K) Optional[tensorbay.utility.user._V] [source]¶
- get(key: tensorbay.utility.user._K, default: Union[tensorbay.utility.user._V, tensorbay.utility.user._T] = None) Union[tensorbay.utility.user._V, tensorbay.utility.user._T]
Return the value for the key if it is in the dict, else default.
- Parameters
key – The key for dict, which can be any immutable type.
default – The value to be returned if key is not in the dict.
- Returns
The value for the key if it is in the dict, else default.
- items() AbstractSet[Tuple[tensorbay.utility.user._K, tensorbay.utility.user._V]] [source]¶
Return a new view of the (key, value) pairs in dict.
- Returns
The (key, value) pairs in dict.
- class tensorbay.utility.user.UserMutableMapping(*args, **kwds)[source]¶
Bases:
MutableMapping
[tensorbay.utility.user._K
,tensorbay.utility.user._V
],tensorbay.utility.user.UserMapping
[tensorbay.utility.user._K
,tensorbay.utility.user._V
]UserMutableMapping is a user-defined wrapper around mutable mapping objects.
- pop(key: tensorbay.utility.user._K) tensorbay.utility.user._V [source]¶
- pop(key: tensorbay.utility.user._K, default: Union[tensorbay.utility.user._V, tensorbay.utility.user._T] = <object object>) Union[tensorbay.utility.user._V, tensorbay.utility.user._T]
Remove specified item and return the corresponding value.
- Parameters
key – The key for dict, which can be any immutable type.
default – The value to be returned if the key is not in the dict and it is given.
- Returns
Value to be removed from the mutable mapping object.
- popitem() Tuple[tensorbay.utility.user._K, tensorbay.utility.user._V] [source]¶
Remove and return a (key, value) pair as a tuple.
Pairs are returned in LIFO (last-in, first-out) order.
- Returns
A (key, value) pair as a tuple.
- setdefault(key: tensorbay.utility.user._K, default: Optional[tensorbay.utility.user._V] = None) tensorbay.utility.user._V [source]¶
Set the value of the item with the specified key.
If the key is in the dict, return the corresponding value. If not, insert the key with a value of default and return default.
- Parameters
key – The key for dict, which can be any immutable type.
default – The value to be set if the key is not in the dict.
- Returns
The value for key if it is in the dict, else default.
- update(__m: Mapping[tensorbay.utility.user._K, tensorbay.utility.user._V], **kwargs: tensorbay.utility.user._V) None [source]¶
- update(__m: Iterable[Tuple[tensorbay.utility.user._K, tensorbay.utility.user._V]], **kwargs: tensorbay.utility.user._V) None
- update(**kwargs: tensorbay.utility.user._V) None
Update the dict.
- Parameters
__m – A dict object, a generator object yielding a (key, value) pair or other object which has a .keys() method.
**kwargs – The value to be added to the mutable mapping.