Indices#
navground.learning.indices
A union type that can be used to get a part of a sequence or of a dictionary with integer keys.
Indices.all
-> select all itemsset
-> select the items with indices in the setslice
-> select the items covered by the slide.
For example:
>>> Indices.all().sub_sequence([1, 2, 3]) [1, 2, 3] >>> Indices.all().sub_dict({1: 2, 3: 4, 5: 6}) {1: 2, 3: 4, 5: 6} >>> Indices({0, 2}).sub_sequence((1, 2, 3)) (1, 3) >>> Indices({0, 2}).sub_dict({1: 2, 3: 4, 5: 6}) {} >>> Indices(slice(-2, None)).sub_sequence((1, 2, 3, 4, 5)) (4, 5) >>> Indices(slice(1, 3)).sub_dict({1: 2, 3: 4, 5: 6}) {1: 2}
- Parameters:
value (IndicesLike) – The value -
"ALL"
: initializesIndices.all
-set
: initializes the indices from the set -slice
: initializes the indices from the slide. -Indices
: copy the value
Indices that covers all the items.
- Return type:
Covert to a set of the indices. Uses length to evaluate slices using
slice.indices()
.
Read the indices from the representation
asdict
.- Parameters:
- Returns:
The indices
- Raises:
ValueError – if no conversion is possible
- Return type:
Intersects with another set of indices.
Extracts a sub-set.
Extracts a sub-sequence.
A JSON-able representation.
- Returns:
A JSON-able dict
The lowest index
- Returns:
The lowest index if the available, else
None
.