sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.41k stars 475 forks source link

list_plot3d.py should not generate NaN coordinates #13135

Closed jdemeyer closed 6 years ago

jdemeyer commented 12 years ago

Both #12798 and the matplotlib upgrade (#23696) cause this:

sage -t --long --warn-long 10.0 src/sage/plot/plot3d/list_plot3d.py
**********************************************************************
File "src/sage/plot/plot3d/list_plot3d.py", line 143, in sage.plot.plot3d.list_plot3d.list_plot3d
Warning, slow doctest:
    list_plot3d(l, interpolation_type='clough', texture='yellow', num_points=100)
Test ran for 926.47 s
**********************************************************************

on hardware which is slow in computing with NaN values.

This plot is done by tachyon but in the input to tachyon, there are many NaNs. This can be seen by applying attachment: nancount.patch. The result is

sage -t --long src/sage/plot/plot3d/list_plot3d.py
**********************************************************************
File "src/sage/plot/plot3d/list_plot3d.py", line 143, in sage.plot.plot3d.list_plot3d.list_plot3d
Failed example:
    list_plot3d(l, interpolation_type='clough', texture='yellow', num_points=100)
Expected:
    Graphics3d Object
Got:
    Got 3206 NaN values
    Graphics3d Object
**********************************************************************
File "src/sage/plot/plot3d/list_plot3d.py", line 387, in sage.plot.plot3d.list_plot3d.list_plot3d_tuples
Failed example:
    show(list_plot3d([[1, 1, 1], [1, 2, 1], [0, 1, 3], [1, 0, 4]], point_list=True))
Expected nothing
Got:
    Got 31 NaN values
**********************************************************************
File "src/sage/plot/plot3d/list_plot3d.py", line 391, in sage.plot.plot3d.list_plot3d.list_plot3d_tuples
Failed example:
    list_plot3d([(1, 2, 3), (0, 1, 3), (2, 1, 4), (1, 0, -2)], texture='yellow', num_points=50)
Expected:
    Graphics3d Object
Got:
    Got 1273 NaN values
    Graphics3d Object
**********************************************************************

CC: @strogdon @kiwifb

Component: graphics

Author: Jeroen Demeyer

Branch/Commit: 4d17a73

Reviewer: Steven Trogdon

Issue created by migration from https://trac.sagemath.org/ticket/13135

vbraun commented 6 years ago
comment:55

Doesn't strike me as a release blocker bug...

jdemeyer commented 6 years ago
comment:56

It is. It yields a massive (orders of magnitude) slowdown on most platforms (x86_64 is the exception here), causing make ptest to timeout consistently and it is a recent regression.

jdemeyer commented 6 years ago

Author: Jeroen Demeyer

jdemeyer commented 6 years ago

Branch: u/jdemeyer/list_plot3d_py_should_not_generate_nan_coordinates

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

4c5a373Remove vertices containing a NaN or infinity
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Commit: 4c5a373

strogdon commented 6 years ago
comment:61

I thought all along that if there was a problem it had to be with the code that does the triangulation, not with the inputs. It's good that someone was capable of sorting through the code. I see no NaNs in the output and the surfaces appear to be drawn over the full convex hull. It may be interesting to see what are the CPU savings? But I do see at least one failure

sage -t --long src/sage/plot/plot3d/parametric_surface.pyx
**********************************************************************
File "src/sage/plot/plot3d/parametric_surface.pyx", line 257, in sage.plot.plot3d.parametric_surface.ParametricSurface.obj_repr
Failed example:
    s[:2]+s[2][:3]+s[3][:3]
Expected:
    ['g obj_1',
     'usemtl texture91',
     'v -2 -2 0',
     'v -2 -1.89744 0.399737',
     'v -1.89744 -1.89744 0',
     'f 1 2 3 4',
     'f 2 5 6 3',
     'f 5 7 8 6']
Got:
    ['g obj_1',
     'usemtl texture111',
     'v -2 -2 0',
     'v -2 -1.89744 0.399737',
     'v -1.89744 -1.89744 0',
     'f 1 2 3 4',
     'f 2 5 6 3',
     'f 5 7 8 6']
**********************************************************************
1 item had failures:
   1 of   5 in sage.plot.plot3d.parametric_surface.ParametricSurface.obj_repr
jdemeyer commented 6 years ago
comment:62

Replying to @strogdon:

But I do see at least one failure

I cannot reproduce that failure but the original test had texture... so I'll change that.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Changed commit from 4c5a373 to 4d17a73

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 6 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

4d17a73Remove vertices containing a NaN or infinity
strogdon commented 6 years ago
comment:65

On my very old, although x86_64, computer

sage -t --long --warn-long 10.0 src/sage/plot/plot3d/list_plot3d.py
    [45 tests, 23.20 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 23.3 seconds
    cpu time: 4.4 seconds
    cumulative wall time: 23.2 seconds

The results do visually look to be correct. I can't test on anything but x86_64 but if it is slow elsewhere it's not now due to the NaNs.

strogdon commented 6 years ago

Reviewer: Steven Trogdon

vbraun commented 6 years ago

Changed branch from u/jdemeyer/list_plot3d_py_should_not_generate_nan_coordinates to 4d17a73