tensorbay.utility.user#
Basic concepts of user-defined 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, start=0, stop=9223372036854775807)[source]#
Return the first index of the value.
- Parameters
value (tensorbay.utility.user._T) – The value to be found.
start (int) – The start index of the subsequence.
stop (int) – The end index of the subsequence.
- Returns
The First index of value.
- Return type
int
- 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, value)[source]#
Insert object before index.
- Parameters
index (int) – Position of the mutable sequence.
value (tensorbay.utility.user._T) – Element to be inserted into the mutable sequence.
- Return type
None
- append(value)[source]#
Append object to the end of the mutable sequence.
- Parameters
value (tensorbay.utility.user._T) – Element to be appended to the mutable sequence.
- Return type
None
- extend(values)[source]#
Extend mutable sequence by appending elements from the iterable.
- Parameters
values (Iterable[tensorbay.utility.user._T]) – Elements to be Extended into the mutable sequence.
- Return type
None
- 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()[source]#
Return a new view of the (key, value) pairs in dict.
- Returns
The (key, value) pairs in dict.
- Return type
AbstractSet[Tuple[tensorbay.utility.user._K, tensorbay.utility.user._V]]
- 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()[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.
- Return type
Tuple[tensorbay.utility.user._K, tensorbay.utility.user._V]
- setdefault(key, default=None)[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 (tensorbay.utility.user._K) – The key for dict, which can be any immutable type.
default (Optional[tensorbay.utility.user._V]) – 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.
- Return type
tensorbay.utility.user._V
- 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.