Skip to content

Commit

Permalink
Vary the representation of distanceToLs
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Feb 26, 2015
1 parent 3598391 commit c39f389
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,15 @@ def distFromStar(self, addSuffix=False):
return "Unk"
else:
return '?'
if ls < 4000:
if ls < 1000:
suffix = 'ls' if addSuffix else ''
return '{:n}'.format(ls)+suffix
if ls < 100000:
if ls < 10000:
suffix = 'ls' if addSuffix else ''
return '{:.1f}K'.format(ls / 1000)+suffix
if ls < 100000:
suffix = 'ls' if addSuffix else ''
return '{:n}K'.format(int(ls / 1000))+suffix
return '{:.2f}ly'.format(ls / (365*24*60*60))

def str(self):
Expand Down

0 comments on commit c39f389

Please sign in to comment.