Open antonio-rojas opened 1 year ago
Here is this happening without --long
for a different seed:
sage -t --warn-long 63.8 --random-seed=282881802734238572874437030739135357256 /usr/lib/python3.11/site-packages/sage/plot/plot.py
**********************************************************************
File "/usr/lib/python3.11/site-packages/sage/plot/plot.py", line 1824, in sage.plot.plot.plot
Failed example:
plot(f, (x, -3.5, 3.5), detect_poles='show', exclude=[-3..3], ymin=-5, ymax=5)
Expected:
Graphics object consisting of 12 graphics primitives
Got:
Graphics object consisting of 13 graphics primitives
**********************************************************************
In fact, this happens about 0.5% of the time:
sage: f(x) = (floor(x)+0.5) / (1-(x-0.5)^2)
sage: ls = [ len(plot(f, (x, -3.5, 3.5), detect_poles='show', exclude=[-3..3], ymin=-5, ymax=5)) for _ in range(1000) ]
sage: ls.count(12)
994
sage: ls.count(13)
6
I guess an easy fix is to replace 12
by ...
but I wonder if this is the only place where this happens.
Plotting seems highly non-deterministic:
sage: [len(p) for p in plot(f, (x, -3.5, 3.5), detect_poles='show', exclude=[-3..3], ymin=-5, ymax=5)]
[19, 33, 45, 167, 2, 138, 43, 184, 2, 209, 58, 17]
sage: [len(p) for p in plot(f, (x, -3.5, 3.5), detect_poles='show', exclude=[-3..3], ymin=-5, ymax=5)]
[19, 33, 48, 128, 2, 172, 43, 211, 2, 192, 58, 16]
sage: [len(p) for p in plot(f, (x, -3.5, 3.5), detect_poles='show', exclude=[-3..3], ymin=-5, ymax=5)]
[17, 35, 47, 155, 2, 152, 39, 207, 2, 205, 59, 16]
...
sage: [len(p) for p in plot(f, (x, -3.5, 3.5), detect_poles='show', exclude=[-3..3], ymin=-5, ymax=5)]
[16, 36, 48, 160, 2, 140, 2, 41, 209, 2, 211, 56, 16]
Aha, the segments of length 2 above correspond to the vertical asymptotes drawn at the poles. The difference between 12 or 13 primitives is an extra 2 drawing a vertical segment on x=0 which the axes shadow. You can see it with axes=False
:
12 primitives
13 primitives
So this seems to be a bug after all, as this function doesn't have a pole at x=0.
Only happens when testing with
--long
and using this specific random seed (even though the test itself is not tagged long and does not use any random data)Component: graphics
Issue created by migration from https://trac.sagemath.org/ticket/34772