Skip to content

Commit 94fff32

Browse files
author
Matthias Koeppe
committed
sage.plot: Doctest cosmetics (copied from #35095)
1 parent 0c80b72 commit 94fff32

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

src/sage/plot/animate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ def make_image(self, frame, filename, **kwds):
453453
....: floor(G.ymin()), ceil(G.ymax()))
454454
....: G.save_image(filename, **kwds)
455455
456-
sage: B = MyAnimation([graphs.CompleteGraph(n) for n in range(7,11)], figsize=5)
456+
sage: B = MyAnimation([graphs.CompleteGraph(n)
457+
....: for n in range(7,11)], figsize=5)
457458
sage: d = B.png()
458459
sage: v = os.listdir(d); v.sort(); v
459460
['00000000.png', '00000001.png', '00000002.png', '00000003.png']

src/sage/plot/plot.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ def b(n): return lambda x: bessel_J(n, x) + 0.5*(n-1)
17631763
17641764
.. PLOT::
17651765
1766-
g = plot(sin(pi*x), (x, -8, 8), ticks=[[-7,-3,0,3,7],[-1/2,0,1/2]])
1766+
g = plot(sin(pi*x), (x, -8, 8), ticks=[[-7,-3,0,3,7], [-1/2,0,1/2]])
17671767
sphinx_plot(g)
17681768
17691769
::
@@ -1799,7 +1799,7 @@ def b(n): return lambda x: bessel_J(n, x) + 0.5*(n-1)
17991799
18001800
.. PLOT::
18011801
1802-
g = plot(x**2, (x,0,3), ticks=[[1,2.5],[0.5,1,2]], tick_formatter=[["$x_1$","$x_2$"],["$y_1$","$y_2$","$y_3$"]])
1802+
g = plot(x**2, (x,0,3), ticks=[[1,2.5],[0.5,1,2]], tick_formatter=[["$x_1$","$x_2$"], ["$y_1$","$y_2$","$y_3$"]])
18031803
sphinx_plot(g)
18041804
18051805
You can force Type 1 fonts in your figures by providing the relevant
@@ -1891,7 +1891,7 @@ def f(x): return (floor(x)+0.5) / (1-(x-0.5)**2)
18911891
18921892
sage: plot(arcsec(x/2), -2, 2) # plot should be empty; no valid points
18931893
Graphics object consisting of 0 graphics primitives
1894-
sage: plot(sqrt(x^2-1), -2, 2) # [-1, 1] is excluded automatically
1894+
sage: plot(sqrt(x^2 - 1), -2, 2) # [-1, 1] is excluded automatically
18951895
Graphics object consisting of 2 graphics primitives
18961896
18971897
.. PLOT::
@@ -2573,7 +2573,7 @@ def parametric_plot(funcs, *args, **kwargs):
25732573
is 1, so that circles look like circles. ::
25742574
25752575
sage: t = var('t')
2576-
sage: parametric_plot( (cos(t), sin(t)), (t, 0, 2*pi))
2576+
sage: parametric_plot((cos(t), sin(t)), (t, 0, 2*pi))
25772577
Graphics object consisting of 1 graphics primitive
25782578
25792579
.. PLOT::
@@ -2613,23 +2613,25 @@ def parametric_plot(funcs, *args, **kwargs):
26132613
26142614
.. PLOT::
26152615
2616-
t =var('t')
2616+
t = var('t')
26172617
g = parametric_plot((t, t**2), (t, -4, 4), fill=True)
26182618
sphinx_plot(g)
26192619
26202620
A filled Hypotrochoid::
26212621
2622-
sage: parametric_plot([cos(x) + 2 * cos(x/4), sin(x) - 2 * sin(x/4)], (x,0, 8*pi), fill=True)
2622+
sage: parametric_plot([cos(x) + 2 * cos(x/4), sin(x) - 2 * sin(x/4)],
2623+
....: (x, 0, 8*pi), fill=True)
26232624
Graphics object consisting of 2 graphics primitives
26242625
26252626
.. PLOT::
26262627
2627-
g = parametric_plot([cos(x) + 2 * cos(x/4), sin(x) - 2 * sin(x/4)], (x,0, 8*pi), fill=True)
2628+
g = parametric_plot([cos(x) + 2 * cos(x/4), sin(x) - 2 * sin(x/4)], (x, 0, 8*pi), fill=True)
26282629
sphinx_plot(g)
26292630
26302631
::
26312632
2632-
sage: parametric_plot( (5*cos(x), 5*sin(x), x), (x,-12, 12), plot_points=150, color="red") # long time
2633+
sage: parametric_plot((5*cos(x), 5*sin(x), x), (x, -12, 12), # long time
2634+
....: plot_points=150, color="red")
26332635
Graphics3d Object
26342636
26352637
.. PLOT::
@@ -2829,7 +2831,8 @@ def polar_plot(funcs, *args, **kwds):
28292831
28302832
Fill the area between two functions::
28312833
2832-
sage: polar_plot(cos(4*x) + 1.5, 0, 2*pi, fill=0.5 * cos(4*x) + 2.5, fillcolor='orange')
2834+
sage: polar_plot(cos(4*x) + 1.5, 0, 2*pi, fill=0.5 * cos(4*x) + 2.5,
2835+
....: fillcolor='orange')
28332836
Graphics object consisting of 2 graphics primitives
28342837
28352838
.. PLOT::
@@ -2839,7 +2842,8 @@ def polar_plot(funcs, *args, **kwds):
28392842
28402843
Fill the area between several spirals::
28412844
2842-
sage: polar_plot([(1.2+k*0.2)*log(x) for k in range(6)], 1, 3 * pi, fill={0: [1], 2: [3], 4: [5]})
2845+
sage: polar_plot([(1.2+k*0.2)*log(x) for k in range(6)], 1, 3 * pi,
2846+
....: fill={0: [1], 2: [3], 4: [5]})
28432847
Graphics object consisting of 9 graphics primitives
28442848
28452849
.. PLOT::
@@ -2895,7 +2899,7 @@ def list_plot(data, plotjoined=False, **kwargs):
28952899
28962900
EXAMPLES::
28972901
2898-
sage: list_plot([i^2 for i in range(5)]) # long time
2902+
sage: list_plot([i^2 for i in range(5)]) # long time
28992903
Graphics object consisting of 1 graphics primitive
29002904
29012905
.. PLOT::
@@ -3008,7 +3012,9 @@ def list_plot(data, plotjoined=False, **kwargs):
30083012
sage: list_plot(x_coords, y_coords)
30093013
Traceback (most recent call last):
30103014
...
3011-
TypeError: The second argument 'plotjoined' should be boolean (True or False). If you meant to plot two lists 'x' and 'y' against each other, use 'list_plot(list(zip(x,y)))'.
3015+
TypeError: The second argument 'plotjoined' should be boolean (True or False).
3016+
If you meant to plot two lists 'x' and 'y' against each other,
3017+
use 'list_plot(list(zip(x,y)))'.
30123018
30133019
Dictionaries with numeric keys and values can be plotted::
30143020
@@ -3055,12 +3061,12 @@ def list_plot(data, plotjoined=False, **kwargs):
30553061
30563062
Instead this will work. We drop the point `(0,1)`.::
30573063
3058-
sage: list_plot(list(zip(range(1,len(yl)), yl[1:])), scale='loglog') # long time
3064+
sage: list_plot(list(zip(range(1,len(yl)), yl[1:])), scale='loglog') # long time
30593065
Graphics object consisting of 1 graphics primitive
30603066
30613067
We use :func:`list_plot_loglog` and plot in a different base.::
30623068
3063-
sage: list_plot_loglog(list(zip(range(1,len(yl)), yl[1:])), base=2) # long time
3069+
sage: list_plot_loglog(list(zip(range(1,len(yl)), yl[1:])), base=2) # long time
30643070
Graphics object consisting of 1 graphics primitive
30653071
30663072
.. PLOT::
@@ -3267,22 +3273,22 @@ def plot_semilogy(funcs, *args, **kwds):
32673273
32683274
EXAMPLES::
32693275
3270-
sage: plot_semilogy(exp, (1,10)) # long time # plot in semilogy scale, base 10
3276+
sage: plot_semilogy(exp, (1, 10)) # long time # plot in semilogy scale, base 10
32713277
Graphics object consisting of 1 graphics primitive
32723278
32733279
.. PLOT::
32743280
3275-
g = plot_semilogy(exp, (1,10)) # long time # plot in semilogy scale, base 10
3281+
g = plot_semilogy(exp, (1,10)) # long time # plot in semilogy scale, base 10
32763282
sphinx_plot(g)
32773283
32783284
::
32793285
3280-
sage: plot_semilogy(exp, (1,10), base=2) # long time # with base 2
3286+
sage: plot_semilogy(exp, (1, 10), base=2) # long time # with base 2
32813287
Graphics object consisting of 1 graphics primitive
32823288
32833289
.. PLOT::
32843290
3285-
g = plot_semilogy(exp, (1,10), base=2) # long time # with base 2
3291+
g = plot_semilogy(exp, (1,10), base=2) # long time # with base 2
32863292
sphinx_plot(g)
32873293
32883294
"""
@@ -3505,13 +3511,14 @@ def reshape(v, n, m):
35053511
35063512
::
35073513
3508-
sage: M = [[plot(sin(k*x),(x,-pi,pi)) for k in range(3)],[plot(cos(j*x),(x,-pi,pi)) for j in [3..5]]]
3514+
sage: M = [[plot(sin(k*x), (x,-pi,pi)) for k in range(3)],
3515+
....: [plot(cos(j*x), (x,-pi,pi)) for j in [3..5]]]
35093516
sage: graphics_array(M,6,1) # long time (up to 4s on sage.math, 2012)
35103517
Graphics Array of size 6 x 1
35113518
35123519
TESTS::
35133520
3514-
sage: L = [plot(sin(k*x),(x,-pi,pi)) for k in [1..3]]
3521+
sage: L = [plot(sin(k*x), (x,-pi,pi)) for k in [1..3]]
35153522
sage: graphics_array(L,0,-1) # indirect doctest
35163523
Traceback (most recent call last):
35173524
...
@@ -3860,7 +3867,8 @@ def adaptive_refinement(f, p1, p2, adaptive_tolerance=0.01,
38603867
TESTS::
38613868
38623869
sage: from sage.plot.plot import adaptive_refinement
3863-
sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01, adaptive_recursion=0)
3870+
sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01,
3871+
....: adaptive_recursion=0)
38643872
[]
38653873
sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01)
38663874
[(0.125*pi, 0.3826834323650898), (0.1875*pi, 0.5555702330196022),
@@ -3881,7 +3889,8 @@ def adaptive_refinement(f, p1, p2, adaptive_tolerance=0.01,
38813889
sage: f(x) = sin(1/x)
38823890
sage: n1 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_tolerance=0.01)); n1
38833891
15
3884-
sage: n2 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_recursion=10, adaptive_tolerance=0.01)); n2
3892+
sage: n2 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_recursion=10,
3893+
....: adaptive_tolerance=0.01)); n2
38853894
79
38863895
sage: n3 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_tolerance=0.001)); n3
38873896
26

src/sage/plot/plot3d/list_plot3d.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ def list_plot3d_tuples(v, interpolation_type, **kwds):
530530
531531
.. PLOT::
532532
533-
sphinx_plot(list_plot3d([[1, 1, 1], [1, 2, 1], [0, 1, 3], [1, 0, 4]], point_list=True))
533+
sphinx_plot(list_plot3d([[1, 1, 1], [1, 2, 1], [0, 1, 3], [1, 0, 4]],
534+
....: point_list=True))
534535
535536
::
536537

0 commit comments

Comments
 (0)