Skip to content

Commit

Permalink
Rewrite reduce for python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed Dec 19, 2016
1 parent 6356092 commit b784636
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions oled/virtual.py
Expand Up @@ -194,12 +194,12 @@ def __init__(self, device, font=None, color="white", bgcolor="black", tabstop=4,
self.animate = animate
self.tabstop = tabstop

def inflate(a, b):
ax, ay = a
bx, by = b
return max(ax, bx), max(ay, by)
self._cw, self._ch = (0, 0)
for i in range(32, 128):
w, h = self.font.getsize(chr(i))
self._cw = max(w, self._cw)
self._ch = max(h, self._ch)

self._cw, self._ch = reduce(inflate, (self.font.getsize(chr(i)) for i in range(32, 128)), (0, 0))
self._ch = line_height or self._ch
self.width = device.width // self._cw
self.height = device.height // self._ch
Expand Down

0 comments on commit b784636

Please sign in to comment.