NimaBoscarino commited on
Commit
b95b59c
1 Parent(s): 48dea0e

Small refactor with list + dict comprehension

Browse files

Use comprehensions instead of loops to be pythonic

Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -13,10 +13,8 @@ def get_ECCV_spaces():
13
  r = requests.get(path)
14
  d = r.json()
15
  spaces = [SpaceInfo(**x) for x in d]
16
- blocks_spaces = {}
17
- for i in range(0,len(spaces)):
18
- if spaces[i].id.split('/')[0] == 'ECCV2022' and hasattr(spaces[i], 'likes') and spaces[i].id != 'ECCV2022/Leaderboard' and spaces[i].id != 'ECCV2022/README':
19
- blocks_spaces[spaces[i].id]=spaces[i].likes
20
  df = pd.DataFrame(
21
  [{"Spaces_Name": Spaces, "likes": likes} for Spaces,likes in blocks_spaces.items()])
22
  df = df.sort_values(by=['likes'],ascending=False)
 
13
  r = requests.get(path)
14
  d = r.json()
15
  spaces = [SpaceInfo(**x) for x in d]
16
+ spaces = [x for x in spaces if x.id.startswith("ECCV2022") and hasattr(x, 'likes') and x.id != 'ECCV2022/Leaderboard' and x.id != 'ECCV2022/README']
17
+ blocks_spaces = {x.id: x.likes for x in spaces}
 
 
18
  df = pd.DataFrame(
19
  [{"Spaces_Name": Spaces, "likes": likes} for Spaces,likes in blocks_spaces.items()])
20
  df = df.sort_values(by=['likes'],ascending=False)