pimoroni / unicorn-hat-hd

Python library and examples for Unicorn HAT HD
https://shop.pimoroni.com/products/unicorn-hat-hd
MIT License
173 stars 69 forks source link

stars.py errors #15

Closed westwind79 closed 6 years ago

westwind79 commented 7 years ago

Traceback (most recent call last): File "stars.py", line 41, in unicornhathd.set_pixel(stars[i][0], stars[i][1], v, v, v) File "/usr/lib/python2.7/dist-packages/unicornhathd/init.py", line 79, in set_pixel _buf[x][y] = r, g, b IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None ) and integer or boolean arrays are valid indices

Gadgetoid commented 6 years ago

Also reported here: https://forums.pimoroni.com/t/unicorn-hat-hd-stars-py-not-working/6125/3

Looks like the output of random.uniform needs coercing into an integer.

Gadgetoid commented 6 years ago

I have fixed this with a simple cast to integer of the values used to index _buf internally to the library. This should keep code examples tidier.

This issue arose because, as of NumPy 1.12.0, the ability to use floats as indices for an array was changed from a deprecation warning, to an error.