Skip to content

Commit

Permalink
Merge pull request #3 from jayfiro/patch-1
Browse files Browse the repository at this point in the history
Fixed Box __repr__ and __str__ AttributeError with self.traits handling
  • Loading branch information
alanbato authored Jun 19, 2018
2 parents d311a76 + 75bc393 commit 8ba48f1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions palletier/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def __eq__(self, other):

def __repr__(self):
repr_str = f'Box(idx={self.idx}, dims={self.dims}'
if self.weight != 0:
repr_str += f', weight={self.weight}'
if self.traits is not None:
for key in self.traits:
repr_str += f', {key}={self.traits[key]}'
if self.name != 'NoName':
repr_str += f'name={self.name}'
if self.pos != Coords(0, 0, 0):
Expand All @@ -55,8 +56,9 @@ def __repr__(self):

def __str__(self):
output = f'Box([{self.dims.dim1}, {self.dims.dim2}, {self.dims.dim3}]'
if self.weight != 0:
output += f', weight={self.weight}'
if self.traits is not None:
for key in self.traits:
output += f', {key}={self.traits[key]}'
output += ')'
return output

Expand Down

0 comments on commit 8ba48f1

Please sign in to comment.