-
Notifications
You must be signed in to change notification settings - Fork 1
add __repr__ for Board and Markers #86
base: master
Are you sure you want to change the base?
Changes from all commits
5b5b002
2e6e65d
99cb3b3
ac2266c
8b485a5
dada805
7f9cfee
515e0a3
d4e364e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,9 +168,12 @@ def spherical(self) -> SphericalCoord: | |
| """ | ||
| return SphericalCoord(*self._raw_data['spherical']) | ||
|
|
||
| def __repr__(self): | ||
| return "<{}>".format(self) | ||
|
|
||
| def __str__(self): | ||
| bearing = self.spherical.rot_y_degrees | ||
| return "<Marker {}: {:.0f}° {}, {:.2f}m away>".format( | ||
| return "Marker {}: {:.0f}° {}, {:.2f}m away".format( | ||
| self.id, | ||
| abs(bearing), | ||
| "right" if bearing > 0 else "left", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to specify "left" and "right" here if this is a bearing? Also, I think clockwise and anti-clockwise might be more appropriate here as they are less ambiguous.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the issue here is that 'bearing' is the wrong variable name. I don't like mentioning clockwise or counter clockwise, as it's given without context here, and they might think it's the orientation of the marker
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either way, this isn't changed in this PR and thus should be fixed separately
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that this be:
That would be truer
reprbehaviour, though would admittedly rely on classes which take other construction parameters overriding the default.If we do that, we can then drop the
__str__entirely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, this would not be truer
reprbehaviour. Please see my above comment and link to the Python 3 documentation.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Apparently I meant
self.socket_path, notself.serial.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case we might want to keep the
__str__.