Skip to content

Commit

Permalink
im2txt: make python3 compatible adding lt and eq
Browse files Browse the repository at this point in the history
__cmp__ is deprecated on python3, so it fails to compare class Caption on python3
  • Loading branch information
tae-jun authored Jan 3, 2017
1 parent bfa1bb1 commit 306fad2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions im2txt/im2txt/inference_utils/caption_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def __cmp__(self, other):
return -1
else:
return 1

# for version 3 compatibility (__cmp__ is deprecated)
def __lt__(self, other):
assert isinstance(other, Caption)
return self.score < other.score

# also for version 3 compatibility
def __eq__(self, other):
assert isinstance(other, Caption)
return self.score == other.score


class TopN(object):
Expand Down

0 comments on commit 306fad2

Please sign in to comment.