enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Select red balls example doesnt work. #1149

Closed PyMarc2 closed 2 years ago

PyMarc2 commented 2 years ago

Mac OS 11.5.2 intel Python 3.8.4 mayavi 4.7.4 pyqt5 5.15.6

Red Balls example Pick On Surface example When clicking on the red balls, nothing happens. Window, MacOs, mouse or trackpad. I can move the view, but nothing else.

drocheam commented 2 years ago

Line 49 in the red ball example is

        point_id = picker.point_id/glyph_points.shape[0]

but should be

        point_id = int(picker.point_id/glyph_points.shape[0])

To guarantee an int value, which is later used for indexing a numpy array. Changing this line fixes the issue.

PyMarc2 commented 2 years ago

It works! Thanks, you should do a pull request for this fix! :)

drocheam commented 2 years ago

I just noticed the example provided with mayavi works, it includes this fix: https://github.com/enthought/mayavi/blob/a0b9f1ccebdbea6387329655ac0d099d029226d3/examples/mayavi/data_interaction/select_red_balls.py#L70 So instead of converting it to an int, it is done by floor division.

It seems that the example code on the website just wasn't updated.

PyMarc2 commented 2 years ago

I guess we will close this issue then! Thanks for your input @drocheam