Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiommendes committed Sep 9, 2016
1 parent a9abd5a commit d0da3eb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/colortools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ def __iter__(self):

def __getitem__(self, key):
if isinstance(key, int):
if key < 0:
key += len(self)
if key < 0:
raise IndexError(key)
if key == 0:
return self._red
elif key == 1:
Expand All @@ -270,11 +274,6 @@ def __getitem__(self, key):
return self._blue
elif key == 3:
return self._alpha
elif key < 0:
key = len(self) - key
if key < 0:
raise IndexError
return self[key]
else:
return tuple(self[i] for i in self._RANGE[key])
raise IndexError(key)
Expand Down

0 comments on commit d0da3eb

Please sign in to comment.