jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
951 stars 188 forks source link

Warning with plane SurfaceGrid #159

Closed tpaviot closed 6 years ago

tpaviot commented 6 years ago

Making a plane surface geometry raises a warning:

surf_geo = SurfaceGeometry(z=[0] * 121, width=100, height=100, width_segments=10,
                           height_segments=10)

outputs in a jupyter notebook:

/lib/python3.6/site-packages/pythreejs/pythreejs.py:78: RuntimeWarning: invalid value encountered in true_divide
  uvs = ((positions - vmin) / vrange)[:, :2]

actually vrange is 0, thus leading to a division issue.

vidartf commented 6 years ago

I think the assumption being made is that a surface necessarily is defined by more than one point. I agree that the warning message is not very good at conveying this though. How would you expect this function to behave when passed a single point?

vidartf commented 6 years ago

I'm sorry, I read that wrong. I missed the * 121.

vidartf commented 6 years ago

Fix proposed in #160.