Skip to content

Commit

Permalink
Streamline asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed Dec 20, 2016
1 parent d36ce62 commit bc37be9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions oled/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def add_hotspot(self, hotspot, xy):
of the virtual device. If it does not then an AssertError is raised.
"""
(x, y) = xy
assert(x >= 0)
assert(y >= 0)
assert(x <= self.width - hotspot.width)
assert(y <= self.height - hotspot.height)
assert(0 <= x <= self.width - hotspot.width)
assert(0 <= y <= self.height - hotspot.height)

# TODO: should it check to see whether hotspots overlap each other?
# Is sensible to _allow_ them to overlap?
Expand Down Expand Up @@ -106,10 +104,8 @@ def _crop_box(self):
right = left + self._device.width
bottom = top + self._device.height

assert(left >= 0)
assert(top >= 0)
assert(right <= self.width)
assert(bottom <= self.height)
assert(0 <= left <= right <= self.width)
assert(0 <= top <= bottom <= self.height)

return (left, top, right, bottom)

Expand Down Expand Up @@ -254,8 +250,7 @@ def putch(self, ch, flush=True):
Prints the specific character, which must be a valid printable ASCII
value in the range 32..127 only.
"""
assert(ord(ch) >= 32)
assert(ord(ch) <= 127)
assert(32 <= ord(ch) <= 127)

w = self.font.getsize(ch)[0]
if self._cx + w >= self._device.width:
Expand Down

0 comments on commit bc37be9

Please sign in to comment.