Skip to content

Commit

Permalink
Fix review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
anuprulez authored May 29, 2020
1 parent fca5516 commit 4a3e79b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/galaxy/tools/recommendations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import logging
import operator
import os

import h5py
Expand Down Expand Up @@ -117,12 +118,10 @@ def __get_latest_tool(self, a_tools):
"""
all_tools = dict()
for t in a_tools:
t_versions = list()
for t_v in a_tools[t]:
t_versions.append(t_v[1])
s_t_v = sorted(t_versions)
t_versions = [t_v[1] for t_v in a_tools[t]]

This comment has been minimized.

Copy link
@bernt-matthias

bernt-matthias May 29, 2020

Contributor

much better, but I guess one can even do this without the extra list t_versions

max_index, _ = max(enumerate(t_versions), key=operator.itemgetter(1))
# get tool with the latest version
latest_t = a_tools[t][t_versions.index(s_t_v[-1])]
latest_t = a_tools[t][max_index]
all_tools[t] = (latest_t[0], latest_t[2])
return all_tools

Expand Down

0 comments on commit 4a3e79b

Please sign in to comment.