Charles Kabui commited on
Commit
1a7472d
·
1 Parent(s): 9faad30

, unzip=True

Browse files
Files changed (2) hide show
  1. utils/remove_duplicates.py +6 -2
  2. utils/unzip.py +0 -2
utils/remove_duplicates.py CHANGED
@@ -1,4 +1,7 @@
1
- def remove_duplicates(items: list, key=lambda x: x, show_process=False):
 
 
 
2
  '''
3
  Remove duplicates from a list of items
4
  Args:
@@ -12,4 +15,5 @@ def remove_duplicates(items: list, key=lambda x: x, show_process=False):
12
  if show_process:
13
  import tqdm
14
  progress = tqdm.tqdm
15
- return list({key(item): item for item in progress(items, desc='Deduping...')}.values())
 
 
1
+ def unzip(items: list):
2
+ return [list(i) for i in zip(*items)]
3
+
4
+ def remove_duplicates(items: list, key=lambda x: x, show_process=False, unzip=False):
5
  '''
6
  Remove duplicates from a list of items
7
  Args:
 
15
  if show_process:
16
  import tqdm
17
  progress = tqdm.tqdm
18
+ deduped_items = list({key(item): item for item in progress(items, desc='Deduping...')}.values())
19
+ return deduped_items if not unzip else unzip(deduped_items)
utils/unzip.py DELETED
@@ -1,2 +0,0 @@
1
- def unzip(items: list):
2
- return list(zip(*items))