Commit 0d00f1a6 authored by Ye Liu's avatar Ye Liu Committed by Kai Chen
Browse files

Fix int support in mmcv.slice_list (#161)

parent ead4bc39
...@@ -110,8 +110,11 @@ def slice_list(in_list, lens): ...@@ -110,8 +110,11 @@ def slice_list(in_list, lens):
Returns: Returns:
list: A list of sliced list. list: A list of sliced list.
""" """
if isinstance(lens, int):
assert len(in_list) % lens == 0
lens = [lens] * int(len(in_list) / lens)
if not isinstance(lens, list): if not isinstance(lens, list):
raise TypeError('"indices" must be a list of integers') raise TypeError('"indices" must be an integer or a list of integers')
elif sum(lens) != len(in_list): elif sum(lens) != len(in_list):
raise ValueError( raise ValueError(
'sum of lens and list length does not match: {} != {}'.format( 'sum of lens and list length does not match: {} != {}'.format(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment