subset#

IndexSetND.subset(*pattern)#

Get a subset of the IndexSet with a wildcard pattern.

Parameters:
*patternAny

The pattern requires one value for each dimension of the N-dim tuple key. The single-character string '*' (asterisk) can be used as a wildcard to represent all possible values for a dimension.

Returns:
list
Raises:
LookupError

If the IndexSet is empty.

TypeError

If the pattern includes non-scalar(s).

ValueError

If the pattern is not the same as the length of N-dim tuple elements.

ValueError

If the pattern has no wildcard or all wildcards.

Examples

>>> triple = IndexSetND([(0, 7, 'A'), (0, 8, 'B'), (0, 9, 'B'), (1, 7, 'A'), (1, 8, 'B')])

Select the subset having 0 at the first dimension index.

>>> triple.subset(0, '*', '*')
[(0, 7, 'A'), (0, 8, 'B'), (0, 9, 'B')]

Select the subset having 0 at the first and 'B' at the third dimension index:

>>> triple.subset(0, '*', 'B')
[(0, 8, 'B'), (0, 9, 'B')]