Skip to content

Commit

Permalink
Merge pull request #2 from ianhi/fix-pre-commit
Browse files Browse the repository at this point in the history
pre-commit fixes
  • Loading branch information
ianhi authored Oct 27, 2021
2 parents 3fc233d + ca1a127 commit bba3084
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions mpl_image_labeller/_labeller.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def __init__(
label_keymap : list of str, or str
If a str must be one of the predefined values *1234* (1, 2, 3,..),
*qwerty* (q, w, e, r, t, y). If an iterable then the items will be assigned
in order to the classes. WARNING: These keys will be removed from the default
keymap for that figure. So if *s* is included then *s* will no longer save the
figure.
in order to the classes. WARNING: These keys will be removed from the
default keymap for that figure. So if *s* is included then *s* will no
longer perform savefig.
labelling_advances_image : bool, default: True
Whether labelling an image should advance to the next image.
fig : Figure
Expand All @@ -56,15 +56,17 @@ def __init__(
if label_keymap == "1234":
if len(classes) > 10:
raise ValueError(
"More classes than numbers on the keyboard, please provide a custom keymap"
"More classes than numbers on the keyboard,"
"please provide a custom keymap"
)
self._label_keymap = {f"{(i+1)%10}": i for i in range(len(classes))}
elif label_keymap == "qwerty":
if len(classes) > len("qwertyuiop"):
raise ValueError(
"More classes than length of qwertyuiop, please provide a custom keymap"
"More classes than length of qwertyuiop,"
"please provide a custom keymap"
)
self._label_keymap = {c: c for c in "qwertyuiop"[: len(classes)]}
self._label_keymap = {"qwertyuiop"[c]: c for c in range(len(classes))}
else:
self._label_keymap = {label_keymap[i]: i for i in range(len(label_keymap))}

Expand Down Expand Up @@ -186,7 +188,7 @@ def _key_press(self, event):
self._label_keymap[event.key]
]
if self._label_advances:
if self.image_index == len(self._images)-1:
if self.image_index == len(self._images) - 1:
# make sure we update the title we are on the last image
self._update_title()
self._fig.canvas.draw_idle()
Expand Down

0 comments on commit bba3084

Please sign in to comment.