Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sorting so it can't use a dictionary in the comparison. #396

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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