Skip to content

Commit 47b6151

Browse files
author
Release Manager
committed
gh-36038: `sage.plot`: Add/update `# needs` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> - Part of: #29705 - Cherry-picked from: #35095 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36038 Reported by: Matthias Köppe Reviewer(s): David Coudert, Kwankyu Lee, Matthias Köppe
2 parents d150b9a + e18852a commit 47b6151

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1233
-883
lines changed

src/sage/ext/fast_callable.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def _builder_and_stream(vars, domain):
493493
sage: _builder_and_stream(["x", "y"], ZZ)
494494
(<class 'sage.ext.interpreters.wrapper_el.Wrapper_el'>,
495495
<sage.ext.fast_callable.InstructionStream object at 0x...>)
496-
sage: _builder_and_stream(["x", "y"], RR) # optional - sage.rings.real_mpfr
496+
sage: _builder_and_stream(["x", "y"], RR) # needs sage.rings.real_mpfr
497497
(<class 'sage.ext.interpreters.wrapper_rr.Wrapper_rr'>,
498498
<sage.ext.fast_callable.InstructionStream object at 0x...>)
499499
@@ -503,7 +503,7 @@ def _builder_and_stream(vars, domain):
503503
interpreter::
504504
505505
sage: domain = RDF
506-
sage: from sage.structure.element import Element as domain # optional - sage.modules
506+
sage: from sage.structure.element import Element as domain # needs sage.modules
507507
sage: _builder_and_stream(["x", "y"], domain)
508508
(<class 'sage.ext.interpreters.wrapper_el.Wrapper_el'>,
509509
<sage.ext.fast_callable.InstructionStream object at 0x...>)
@@ -1622,7 +1622,7 @@ class IntegerPowerFunction():
16221622
sage: cube = IntegerPowerFunction(3)
16231623
sage: cube
16241624
(^3)
1625-
sage: cube(AA(7)^(1/3))
1625+
sage: cube(AA(7)^(1/3)) # needs sage.rings.number_field
16261626
7.000000000000000?
16271627
sage: cube.exponent
16281628
3
@@ -1820,18 +1820,18 @@ cpdef generate_code(Expression expr, InstructionStream stream):
18201820
25
18211821
sage: fc.op_list()
18221822
[('load_arg', 0), ('load_arg', 1), ('py_call', <function my_norm at 0x...>, 2), 'return']
1823-
sage: fc = fast_callable(expr) # optional - sage.symbolic
1824-
sage: fc(3.0r) # optional - sage.symbolic
1823+
sage: fc = fast_callable(expr) # needs sage.symbolic
1824+
sage: fc(3.0r) # needs sage.symbolic
18251825
4.0*pi + 12.0
1826-
sage: fc = fast_callable(x+3, domain=ZZ) # optional - sage.symbolic
1827-
sage: fc(4) # optional - sage.symbolic
1826+
sage: fc = fast_callable(x+3, domain=ZZ) # needs sage.symbolic
1827+
sage: fc(4) # needs sage.symbolic
18281828
7
1829-
sage: fc = fast_callable(x/3, domain=ZZ) # optional - sage.symbolic
1830-
sage: fc(4) # optional - sage.symbolic
1829+
sage: fc = fast_callable(x/3, domain=ZZ) # needs sage.symbolic
1830+
sage: fc(4) # needs sage.symbolic
18311831
Traceback (most recent call last):
18321832
...
18331833
TypeError: no conversion of this rational to integer
1834-
sage: fc(6) # optional - sage.symbolic
1834+
sage: fc(6) # needs sage.symbolic
18351835
2
18361836
sage: fc = fast_callable(etb.call(sin, x), domain=ZZ)
18371837
sage: fc(0)

src/sage/misc/replace_dot_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def process_line(location, line, replacements, row_index, verbose=False):
298298
sage: from sage.misc.replace_dot_all import *
299299
sage: location = os.path.join(sage.env.SAGE_SRC, 'sage/plot/arc.py')
300300
sage: replacements = find_replacements(location, package_regex='sage[.]plot[.]all', verbose=True); replacements
301-
[[471, 24, 'from sage.plot.graphics import Graphics']]
301+
[[476, 24, 'from sage.plot.graphics import Graphics']]
302302
sage: with open(location, "r") as file:
303303
....: lines = file.readlines()
304304
sage: row_index, col_number, *_ = replacements[0]

src/sage/plot/animate.py

Lines changed: 104 additions & 74 deletions
Large diffs are not rendered by default.

src/sage/plot/arc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Arc(GraphicPrimitive):
4545
4646
Note that the construction should be done using ``arc``::
4747
48+
sage: from math import pi
4849
sage: from sage.plot.arc import Arc
4950
sage: print(Arc(0,0,1,1,pi/4,pi/4,pi/2,{}))
5051
Arc with center (0.0,0.0) radii (1.0,1.0) angle 0.78539816339... inside the sector (0.78539816339...,1.5707963267...)
@@ -115,6 +116,7 @@ def get_minmax_data(self):
115116
116117
The same example with a rotation of angle `\pi/2`::
117118
119+
sage: from math import pi
118120
sage: p = arc((-2, 3), 1, 2, pi/2)
119121
sage: d = p.get_minmax_data()
120122
sage: d['xmin']
@@ -293,6 +295,7 @@ def bezier_path(self):
293295
sage: Arc(2,3,2.2,2.2,0,2,3,op).bezier_path()
294296
Graphics object consisting of 1 graphics primitive
295297
298+
sage: from math import pi
296299
sage: a = arc((0,0),2,1,0,(pi/5,pi/2+pi/12), linestyle="--", color="red")
297300
sage: b = a[0].bezier_path()
298301
sage: b[0]
@@ -348,6 +351,7 @@ def _render_on_subplot(self, subplot):
348351
"""
349352
TESTS::
350353
354+
sage: from math import pi
351355
sage: A = arc((1,1),3,4,pi/4,(pi,4*pi/3)); A
352356
Graphics object consisting of 1 graphics primitive
353357
"""
@@ -421,6 +425,7 @@ def arc(center, r1, r2=None, angle=0.0, sector=(0.0, 2 * pi), **options):
421425
Plot an arc of circle centered at (0,0) with radius 1 in the sector
422426
`(\pi/4,3*\pi/4)`::
423427
428+
sage: from math import pi
424429
sage: arc((0,0), 1, sector=(pi/4,3*pi/4))
425430
Graphics object consisting of 1 graphics primitive
426431

src/sage/plot/arrow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ def arrow2d(tailpoint=None, headpoint=None, path=None, **options):
586586
587587
A pretty circle of arrows::
588588
589-
sage: sum([arrow2d((0,0), (cos(x),sin(x)), hue=x/(2*pi)) for x in [0..2*pi,step=0.1]])
589+
sage: sum(arrow2d((0,0), (cos(x),sin(x)), hue=x/(2*pi)) # needs sage.symbolic
590+
....: for x in [0..2*pi, step=0.1])
590591
Graphics object consisting of 63 graphics primitives
591592
592593
.. PLOT::

src/sage/plot/bezier_path.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def plot3d(self, z=0, **kwds):
168168
EXAMPLES::
169169
170170
sage: b = bezier_path([[(0,0),(0,1),(1,0)]])
171-
sage: A = b.plot3d()
172-
sage: B = b.plot3d(z=2)
173-
sage: A + B
171+
sage: A = b.plot3d() # needs sage.symbolic
172+
sage: B = b.plot3d(z=2) # needs sage.symbolic
173+
sage: A + B # needs sage.symbolic
174174
Graphics3d Object
175175
176176
.. PLOT::
@@ -182,7 +182,7 @@ def plot3d(self, z=0, **kwds):
182182
183183
::
184184
185-
sage: bezier3d([[(0,0,0),(1,0,0),(0,1,0),(0,1,1)]])
185+
sage: bezier3d([[(0,0,0),(1,0,0),(0,1,0),(0,1,1)]]) # needs sage.symbolic
186186
Graphics3d Object
187187
188188
.. PLOT::

src/sage/plot/circle.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525

2626
class Circle(GraphicPrimitive):
2727
"""
28-
Primitive class for the Circle graphics type. See circle? for information
28+
Primitive class for the :class:`Circle` graphics type. See ``circle?`` for information
2929
about actually plotting circles.
3030
3131
INPUT:
3232
33-
- x -- `x`-coordinate of center of Circle
33+
- ``x`` -- `x`-coordinate of center of Circle
3434
35-
- y -- `y`-coordinate of center of Circle
35+
- ``y`` -- `y`-coordinate of center of Circle
3636
37-
- r -- radius of Circle object
37+
- ``r`` -- radius of Circle object
3838
39-
- options -- dict of valid plot options to pass to constructor
39+
- ``options`` -- dict of valid plot options to pass to constructor
4040
4141
EXAMPLES:
4242
@@ -80,7 +80,7 @@ def __init__(self, x, y, r, options):
8080

8181
def get_minmax_data(self):
8282
"""
83-
Returns a dictionary with the bounding box data.
83+
Return a dictionary with the bounding box data.
8484
8585
EXAMPLES::
8686
@@ -139,6 +139,7 @@ def _render_on_subplot(self, subplot):
139139
"""
140140
TESTS::
141141
142+
sage: from math import pi
142143
sage: C = circle((2,pi), 2, edgecolor='black', facecolor='green', fill=True)
143144
"""
144145
import matplotlib.patches as patches
@@ -182,7 +183,8 @@ def plot3d(self, z=0, **kwds):
182183
This example uses this method implicitly, but does not pass
183184
the optional parameter z to this method::
184185
185-
sage: sum([circle((random(),random()), random()).plot3d(z=random()) for _ in range(20)])
186+
sage: sum(circle((random(),random()), random()).plot3d(z=random())
187+
....: for _ in range(20))
186188
Graphics3d Object
187189
188190
.. PLOT::
@@ -192,6 +194,7 @@ def plot3d(self, z=0, **kwds):
192194
193195
These examples are explicit, and pass z to this method::
194196
197+
sage: from math import pi
195198
sage: C = circle((2,pi), 2, hue=.8, alpha=.3, fill=True)
196199
sage: c = C[0]
197200
sage: d = c.plot3d(z=2)
@@ -304,14 +307,16 @@ def circle(center, radius, **options):
304307
Here we make a more complicated plot, with many circles of different colors::
305308
306309
sage: g = Graphics()
307-
sage: step=6; ocur=1/5; paths=16
310+
sage: step = 6; ocur = 1/5; paths = 16
308311
sage: PI = math.pi # numerical for speed -- fine for graphics
309312
sage: for r in range(1,paths+1):
310-
....: for x,y in [((r+ocur)*math.cos(n), (r+ocur)*math.sin(n)) for n in srange(0, 2*PI+PI/step, PI/step)]:
313+
....: for x,y in [((r+ocur)*math.cos(n), (r+ocur)*math.sin(n))
314+
....: for n in srange(0, 2*PI+PI/step, PI/step)]:
311315
....: g += circle((x,y), ocur, rgbcolor=hue(r/paths))
312316
....: rnext = (r+1)^2
313317
....: ocur = (rnext-r)-ocur
314-
sage: g.show(xmin=-(paths+1)^2, xmax=(paths+1)^2, ymin=-(paths+1)^2, ymax=(paths+1)^2, figsize=[6,6])
318+
sage: g.show(xmin=-(paths+1)^2, xmax=(paths+1)^2,
319+
....: ymin=-(paths+1)^2, ymax=(paths+1)^2, figsize=[6,6])
315320
316321
.. PLOT::
317322
@@ -358,7 +363,8 @@ def circle(center, radius, **options):
358363
359364
And circles with legends::
360365
361-
sage: circle((4,5), 1, rgbcolor='yellow', fill=True, legend_label='the sun').show(xmin=0, ymin=0)
366+
sage: circle((4,5), 1, rgbcolor='yellow', fill=True,
367+
....: legend_label='the sun').show(xmin=0, ymin=0)
362368
363369
.. PLOT::
364370
@@ -368,7 +374,8 @@ def circle(center, radius, **options):
368374
369375
::
370376
371-
sage: circle((4,5), 1, legend_label='the sun', legend_color='yellow').show(xmin=0, ymin=0)
377+
sage: circle((4,5), 1,
378+
....: legend_label='the sun', legend_color='yellow').show(xmin=0, ymin=0)
372379
373380
.. PLOT::
374381
@@ -378,12 +385,12 @@ def circle(center, radius, **options):
378385
379386
Extra options will get passed on to show(), as long as they are valid::
380387
381-
sage: circle((0, 0), 2, figsize=[10,10]) # That circle is huge!
388+
sage: circle((0, 0), 2, figsize=[10,10]) # That circle is huge!
382389
Graphics object consisting of 1 graphics primitive
383390
384391
::
385392
386-
sage: circle((0, 0), 2).show(figsize=[10,10]) # These are equivalent
393+
sage: circle((0, 0), 2).show(figsize=[10,10]) # These are equivalent
387394
388395
TESTS:
389396

src/sage/plot/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# sage.doctest: needs sage.plot
22
r"""
33
Colors
44

0 commit comments

Comments
 (0)