Skip to content

Commit

Permalink
modifications suite aux suggestions de @parmentelat
Browse files Browse the repository at this point in the history
  • Loading branch information
aollier committed Dec 11, 2020
1 parent 385d643 commit a7f4dda
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions data/shipdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def __hash__(self):

# a hashable shall override this special method
def __eq__(self, other):
return self.latitude == other.latitude\
and self.longitude == other.longitude\
and self.timestamp == other.timestamp
return (self.latitude == other.latitude
and self.longitude == other.longitude
and self.timestamp == other.timestamp)
# @END@

# @BEG@ name=shipdict more=suite
Expand Down Expand Up @@ -108,7 +108,7 @@ def add_position(self, position):
def sort_positions(self):
"""
sort of positions made unique thanks to the set by chronological order
for this to work, a Position shall be hashable
for this to work, a Position must be hashable
"""
self.positions = sorted(set(self.positions),
key=lambda position: position.timestamp)
Expand Down Expand Up @@ -173,6 +173,11 @@ def add_chunk(self, chunk):
based on the result of is_abbreviated(),
gets sent to add_extended or add_abbreviated
"""
# here we retrieve the static method through the class
# this form outlines the fact that we're calling a static method
# note that
# self.is_abbreviated(chunk)
# would work fine just as well
if ShipDict.is_abbreviated(chunk):
self.add_abbreviated(chunk)
else:
Expand Down

0 comments on commit a7f4dda

Please sign in to comment.