unique¶
- odl.util.utility.unique(seq)[source]¶
Return the unique values in a sequence.
- Parameters:
- seqsequence
Sequence with (possibly duplicate) elements.
- Returns:
- uniquelist
Unique elements of
seq
. Order is guaranteed to be the same as in seq.
Examples
Determine unique elements in list
>>> unique([1, 2, 3, 3]) [1, 2, 3]
>>> unique((1, 'str', 'str')) [1, 'str']
The utility also works with unhashable types:
>>> unique((1, [1], [1])) [1, [1]]