Shortcuts

mmengine.utils.is_seq_of

mmengine.utils.is_seq_of(seq, expected_type, seq_type=None)[source]

Check whether it is a sequence of some type.

Parameters:
  • seq (Sequence) – The sequence to be checked.

  • expected_type (type or tuple) – Expected type of sequence items.

  • seq_type (type, optional) – Expected sequence type. Defaults to None.

Returns:

Return True if seq is valid else False.

Return type:

bool

Examples

>>> from mmengine.utils import is_seq_of
>>> seq = ['a', 'b', 'c']
>>> is_seq_of(seq, str)
True
>>> is_seq_of(seq, int)
False