cvtools.utils.misc module

cvtools.utils.misc.concat_list(in_list)[源代码]

Concatenate a list of list into a single list.

参数:in_list (list) -- The list of list to be merged.
返回:The concatenated flat list.
返回类型:list
cvtools.utils.misc.is_array_like(obj)[源代码]
cvtools.utils.misc.is_list_of(seq, expected_type)[源代码]

Check whether it is a list of some type.

A partial method of is_seq_of().

cvtools.utils.misc.is_seq_of(seq, expected_type, seq_type=None)[源代码]

Check whether it is a sequence of some type.

参数:
  • seq (Sequence) -- The sequence to be checked.
  • expected_type (type) -- Expected type of sequence items.
  • seq_type (type, optional) -- Expected sequence type.
返回:

Whether the sequence is valid.

返回类型:

bool

cvtools.utils.misc.is_str(x)[源代码]

Whether the input is an string instance.

cvtools.utils.misc.is_tuple_of(seq, expected_type)[源代码]

Check whether it is a tuple of some type.

A partial method of is_seq_of().

cvtools.utils.misc.iter_cast(inputs, dst_type, return_type=None)[源代码]

Cast elements of an iterable object into some type.

参数:
  • inputs (Iterable) -- The input object.
  • dst_type (type) -- Destination type.
  • return_type (type, optional) -- If specified, the output object will be converted to this type, otherwise an iterator.
返回:

The converted object.

返回类型:

iterator or specified type

cvtools.utils.misc.list_cast(inputs, dst_type)[源代码]

Cast elements of an iterable object into a list of some type.

A partial method of iter_cast().

cvtools.utils.misc.slice_list(in_list, lens)[源代码]

Slice a list into several sub lists by a list of given length.

参数:
  • in_list (list) -- The list to be sliced.
  • lens (int or list) -- The expected length of each out list.
返回:

A list of sliced list.

返回类型:

list

cvtools.utils.misc.sort_dict(d, sort_key='key')[源代码]
cvtools.utils.misc.tuple_cast(inputs, dst_type)[源代码]

Cast elements of an iterable object into a tuple of some type.

A partial method of iter_cast().