ipython-books / cookbook-code

[DEPRECATED] See the new edition:

Home Page:http://ipython-books.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vispy Code (6.6) Error

j9ac9k opened this issue · comments

In the 6th python cell:

program['a_position'] = np.c_[
        np.linspace(-1.0, +1.0, 1000),
        np.random.uniform(-0.5, +0.5, 1000)]

results in:

TypeError: data must be 32-bit not float64

I may mess with this later, but I know next to nothing about vispy so I'm not sure how well I can troubleshoot the issue.

try to append .astype(np.float32) at the end of the array
float64 doesn't work well on GPUs so VisPy requires explicit cast to float32

That was going to be my first try, perhaps I should have done that first instead of opening an issue... still learning thing 'git' thing and associated etiquette. Thanks for the fast response!

closed by #23

It looks like this fix did not propagate to http://ipython-books.github.io/featured-06/

Specifically

program['a_position'] = np.c_[
        np.linspace(-1.0, +1.0, 1000),
        np.random.uniform(-0.5, +0.5, 1000)].astype(np.float32)

Should be fixed now