sagemath / sage

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

Clarify how actual output can vary from documented output #33258

Open umedoblock opened 2 years ago

umedoblock commented 2 years ago

For some examples from the Sage documentation, the output observed in an actual session can be slightly different from the documented one.

In particular with respect to line breaks, and for Graphics objects.

Colors example

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.5.rc2, Release Date: 2022-01-16                 │
│ Using Python 3.9.9. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

colors map

example

sage: sorted(colormaps)
[u'Accent', u'Blues', ...]

run

sage: sage: sorted(colormaps) 
....:                                                                           
['Accent',
 'Blues',
 'BrBG',
...

"Launched png viewer for ..."

example

sage: p = Graphics()
sage: for phi in xsrange(0, 2 * pi, 1 / pi):
....:     p += plot(sin(x + phi), (x, -7, 7), rgbcolor = hue(phi))
sage: p
Graphics object consisting of 20 graphics primitives

run

sage: sage: p = Graphics() 
....: sage: for phi in xsrange(0, 2 * pi, 1 / pi): 
....: ....:     p += plot(sin(x + phi), (x, -7, 7), rgbcolor = hue(phi)) 
....: sage: p 
....:                                                                           
Launched png viewer for Graphics object consisting of 20 graphics primitives

CC: @slel

Component: documentation

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

slel commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,10 @@
+For some examples from the Sage documentation,
+the output observed in an actual session can be
+slightly different from the documented one.
+
+In particular with respect to line breaks,
+and for Graphics objects.
+
 [Colors example](https://doc.sagemath.org/html/en/reference/plotting/sage/plot/colors.html)
umedoblock commented 2 years ago
comment:3

I tried to run some EXAMPLEs in Histograms

environment

macOS Monterey
Version 12.1
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.5.rc2, Release Date: 2022-01-16                 │
│ Using Python 3.9.9. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

EXAMPLE

g.get_minmax_data() # random output
{'xmax': 0.99729312925213209, 'xmin': 0.00013024562219410285, 'ymax': 61, 'ymin': 0}

run, also too...

sage: g.get_minmax_data() # random output 
....:                                                                           
{'xmin': 0.0012932458294986349,
 'xmax': 0.998853072119053,
 'ymin': 0,
 'ymax': 59}
umedoblock commented 2 years ago
comment:4

"doctest:..." remain in EXAMPLE of Graphics objects

I tried to run some EXAMPLEs in Graphics objects

environment

macOS Monterey
Version 12.1
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.5.rc2, Release Date: 2022-01-16                 │
│ Using Python 3.9.9. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

EXAMPLE

list_plot_loglog([(1,2),(2,3)], plotjoined=True, ticks=[[1],[1]])

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
doctest:...: UserWarning: The x-axis contains fewer than 2 ticks;
the logarithmic scale of the plot may not be apparent to the reader.
doctest:...: UserWarning: The y-axis contains fewer than 2 ticks;
the logarithmic scale of the plot may not be apparent to the reader.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Graphics object consisting of 1 graphics primitive

run

list_plot_loglog([(1,2),(2,3)], plotjoined=True, ticks=[[1],[1]])
Launched png viewer for Graphics object consisting of 1 graphics primitive

EXAMPLE

plot(x, -4, 4, title='Plot x', title_pos=0.05)

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
doctest:...: ...RichReprWarning: Exception in _rich_repr_ while displaying object: 'title_pos' must be a list or tuple of two real numbers.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Graphics object consisting of 1 graphics primitive

run

sage: plot(x, -4, 4, title='Plot x', title_pos=0.05) 
....:                                                                           
Graphics object consisting of 1 graphics primitive
umedoblock commented 2 years ago
comment:5

I tried to run some EXAMPLEs in Graphics arrays and insets

EXAMPLE

tiny tiny tiny difference

lack of head space

G = graphics_array([[g1, g2], [g3, g4]])  # back to the 2x2 array
G[:]
[Graphics object consisting of 1 graphics primitive,
Graphics object consisting of 1 graphics primitive,
Graphics object consisting of 51 graphics primitives,
Graphics object consisting of 2 graphics primitives]

run

sage: G[:]                                                                      
[Graphics object consisting of 1 graphics primitive,
 Graphics object consisting of 1 graphics primitive,
 Graphics object consisting of 51 graphics primitives,
 Graphics object consisting of 2 graphics primitives]
fchapoton commented 2 years ago
comment:6

Stop making this list, please. This is useless.

umedoblock commented 2 years ago
comment:7

Yes.

I don't make a new comment.

sorry.