Skip to content

Commit

Permalink
Merge pull request #396 from girder/fix-394
Browse files Browse the repository at this point in the history
Fix sorting so it can't use a dictionary in the comparison.
  • Loading branch information
manthey authored Nov 22, 2019
2 parents b0782ce + 029f337 commit ef1c266
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sources/openslide/large_image_source_openslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ def _getAvailableLevels(self, path):
'height': svsLevelDimensions[svslevel][1],
}
if level['width'] > 0 and level['height'] > 0:
# add to the list so that we can sort by resolution
levels.append((level['width'] * level['height'], level))
# add to the list so that we can sort by resolution and
# then by earlier entries
levels.append((level['width'] * level['height'], -len(levels), level))
except openslide.lowlevel.OpenSlideError:
self._openslide = openslide.OpenSlide(path)
# sort highest resolution first.
levels = [entry[-1] for entry in sorted(levels, reverse=True)]
levels = [entry[-1] for entry in sorted(levels, reverse=True, key=lambda x: x[:-1])]
# Discard levels that are not a power-of-two compared to the highest
# resolution level.
levels = [entry for entry in levels if
Expand Down

0 comments on commit ef1c266

Please sign in to comment.