Skip to content

(#9) change __getitem__ to use self._n instead of self._buf // 4 #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adafruit_dotstar.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _set_item(self, index, value):

def __setitem__(self, index, val):
if isinstance(index, slice):
start, stop, step = index.indices(len(self))
start, stop, step = index.indices(self._n)
length = stop - start
if step != 0:
length = math.ceil(length / step)
Expand All @@ -162,7 +162,7 @@ def __setitem__(self, index, val):
def __getitem__(self, index):
if isinstance(index, slice):
out = []
for in_i in range(*index.indices(len(self._buf) // 4)):
for in_i in range(*index.indices(self._n)):
out.append(
tuple(self._buf[in_i * 4 + (3 - i) + self.start_header_size] for i in range(3)))
return out
Expand Down