Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/sage/ext/fast_callable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def _builder_and_stream(vars, domain):
sage: _builder_and_stream(["x", "y"], ZZ)
(<class 'sage.ext.interpreters.wrapper_el.Wrapper_el'>,
<sage.ext.fast_callable.InstructionStream object at 0x...>)
sage: _builder_and_stream(["x", "y"], RR) # optional - sage.rings.real_mpfr
sage: _builder_and_stream(["x", "y"], RR) # needs sage.rings.real_mpfr
(<class 'sage.ext.interpreters.wrapper_rr.Wrapper_rr'>,
<sage.ext.fast_callable.InstructionStream object at 0x...>)

Expand All @@ -503,7 +503,7 @@ def _builder_and_stream(vars, domain):
interpreter::

sage: domain = RDF
sage: from sage.structure.element import Element as domain # optional - sage.modules
sage: from sage.structure.element import Element as domain # needs sage.modules
sage: _builder_and_stream(["x", "y"], domain)
(<class 'sage.ext.interpreters.wrapper_el.Wrapper_el'>,
<sage.ext.fast_callable.InstructionStream object at 0x...>)
Expand Down Expand Up @@ -1622,7 +1622,7 @@ class IntegerPowerFunction():
sage: cube = IntegerPowerFunction(3)
sage: cube
(^3)
sage: cube(AA(7)^(1/3))
sage: cube(AA(7)^(1/3)) # needs sage.rings.number_field
7.000000000000000?
sage: cube.exponent
3
Expand Down Expand Up @@ -1820,18 +1820,18 @@ cpdef generate_code(Expression expr, InstructionStream stream):
25
sage: fc.op_list()
[('load_arg', 0), ('load_arg', 1), ('py_call', <function my_norm at 0x...>, 2), 'return']
sage: fc = fast_callable(expr) # optional - sage.symbolic
sage: fc(3.0r) # optional - sage.symbolic
sage: fc = fast_callable(expr) # needs sage.symbolic
sage: fc(3.0r) # needs sage.symbolic
4.0*pi + 12.0
sage: fc = fast_callable(x+3, domain=ZZ) # optional - sage.symbolic
sage: fc(4) # optional - sage.symbolic
sage: fc = fast_callable(x+3, domain=ZZ) # needs sage.symbolic
sage: fc(4) # needs sage.symbolic
7
sage: fc = fast_callable(x/3, domain=ZZ) # optional - sage.symbolic
sage: fc(4) # optional - sage.symbolic
sage: fc = fast_callable(x/3, domain=ZZ) # needs sage.symbolic
sage: fc(4) # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer
sage: fc(6) # optional - sage.symbolic
sage: fc(6) # needs sage.symbolic
2
sage: fc = fast_callable(etb.call(sin, x), domain=ZZ)
sage: fc(0)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/replace_dot_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def process_line(location, line, replacements, row_index, verbose=False):
sage: from sage.misc.replace_dot_all import *
sage: location = os.path.join(sage.env.SAGE_SRC, 'sage/plot/arc.py')
sage: replacements = find_replacements(location, package_regex='sage[.]plot[.]all', verbose=True); replacements
[[471, 24, 'from sage.plot.graphics import Graphics']]
[[476, 24, 'from sage.plot.graphics import Graphics']]
sage: with open(location, "r") as file:
....: lines = file.readlines()
sage: row_index, col_number, *_ = replacements[0]
Expand Down
178 changes: 104 additions & 74 deletions src/sage/plot/animate.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/sage/plot/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Arc(GraphicPrimitive):

Note that the construction should be done using ``arc``::

sage: from math import pi
sage: from sage.plot.arc import Arc
sage: print(Arc(0,0,1,1,pi/4,pi/4,pi/2,{}))
Arc with center (0.0,0.0) radii (1.0,1.0) angle 0.78539816339... inside the sector (0.78539816339...,1.5707963267...)
Expand Down Expand Up @@ -115,6 +116,7 @@ def get_minmax_data(self):

The same example with a rotation of angle `\pi/2`::

sage: from math import pi
sage: p = arc((-2, 3), 1, 2, pi/2)
sage: d = p.get_minmax_data()
sage: d['xmin']
Expand Down Expand Up @@ -293,6 +295,7 @@ def bezier_path(self):
sage: Arc(2,3,2.2,2.2,0,2,3,op).bezier_path()
Graphics object consisting of 1 graphics primitive

sage: from math import pi
sage: a = arc((0,0),2,1,0,(pi/5,pi/2+pi/12), linestyle="--", color="red")
sage: b = a[0].bezier_path()
sage: b[0]
Expand Down Expand Up @@ -348,6 +351,7 @@ def _render_on_subplot(self, subplot):
"""
TESTS::

sage: from math import pi
sage: A = arc((1,1),3,4,pi/4,(pi,4*pi/3)); A
Graphics object consisting of 1 graphics primitive
"""
Expand Down Expand Up @@ -421,6 +425,7 @@ def arc(center, r1, r2=None, angle=0.0, sector=(0.0, 2 * pi), **options):
Plot an arc of circle centered at (0,0) with radius 1 in the sector
`(\pi/4,3*\pi/4)`::

sage: from math import pi
sage: arc((0,0), 1, sector=(pi/4,3*pi/4))
Graphics object consisting of 1 graphics primitive

Expand Down
3 changes: 2 additions & 1 deletion src/sage/plot/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ def arrow2d(tailpoint=None, headpoint=None, path=None, **options):

A pretty circle of arrows::

sage: sum([arrow2d((0,0), (cos(x),sin(x)), hue=x/(2*pi)) for x in [0..2*pi,step=0.1]])
sage: sum(arrow2d((0,0), (cos(x),sin(x)), hue=x/(2*pi)) # needs sage.symbolic
....: for x in [0..2*pi, step=0.1])
Graphics object consisting of 63 graphics primitives

.. PLOT::
Expand Down
8 changes: 4 additions & 4 deletions src/sage/plot/bezier_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def plot3d(self, z=0, **kwds):
EXAMPLES::

sage: b = bezier_path([[(0,0),(0,1),(1,0)]])
sage: A = b.plot3d()
sage: B = b.plot3d(z=2)
sage: A + B
sage: A = b.plot3d() # needs sage.symbolic
sage: B = b.plot3d(z=2) # needs sage.symbolic
sage: A + B # needs sage.symbolic
Graphics3d Object

.. PLOT::
Expand All @@ -182,7 +182,7 @@ def plot3d(self, z=0, **kwds):

::

sage: bezier3d([[(0,0,0),(1,0,0),(0,1,0),(0,1,1)]])
sage: bezier3d([[(0,0,0),(1,0,0),(0,1,0),(0,1,1)]]) # needs sage.symbolic
Graphics3d Object

.. PLOT::
Expand Down
35 changes: 21 additions & 14 deletions src/sage/plot/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@

class Circle(GraphicPrimitive):
"""
Primitive class for the Circle graphics type. See circle? for information
Primitive class for the :class:`Circle` graphics type. See ``circle?`` for information
about actually plotting circles.

INPUT:

- x -- `x`-coordinate of center of Circle
- ``x`` -- `x`-coordinate of center of Circle

- y -- `y`-coordinate of center of Circle
- ``y`` -- `y`-coordinate of center of Circle

- r -- radius of Circle object
- ``r`` -- radius of Circle object

- options -- dict of valid plot options to pass to constructor
- ``options`` -- dict of valid plot options to pass to constructor

EXAMPLES:

Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(self, x, y, r, options):

def get_minmax_data(self):
"""
Returns a dictionary with the bounding box data.
Return a dictionary with the bounding box data.

EXAMPLES::

Expand Down Expand Up @@ -139,6 +139,7 @@ def _render_on_subplot(self, subplot):
"""
TESTS::

sage: from math import pi
sage: C = circle((2,pi), 2, edgecolor='black', facecolor='green', fill=True)
"""
import matplotlib.patches as patches
Expand Down Expand Up @@ -182,7 +183,8 @@ def plot3d(self, z=0, **kwds):
This example uses this method implicitly, but does not pass
the optional parameter z to this method::

sage: sum([circle((random(),random()), random()).plot3d(z=random()) for _ in range(20)])
sage: sum(circle((random(),random()), random()).plot3d(z=random())
....: for _ in range(20))
Graphics3d Object

.. PLOT::
Expand All @@ -192,6 +194,7 @@ def plot3d(self, z=0, **kwds):

These examples are explicit, and pass z to this method::

sage: from math import pi
sage: C = circle((2,pi), 2, hue=.8, alpha=.3, fill=True)
sage: c = C[0]
sage: d = c.plot3d(z=2)
Expand Down Expand Up @@ -304,14 +307,16 @@ def circle(center, radius, **options):
Here we make a more complicated plot, with many circles of different colors::

sage: g = Graphics()
sage: step=6; ocur=1/5; paths=16
sage: step = 6; ocur = 1/5; paths = 16
sage: PI = math.pi # numerical for speed -- fine for graphics
sage: for r in range(1,paths+1):
....: 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)]:
....: 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)]:
....: g += circle((x,y), ocur, rgbcolor=hue(r/paths))
....: rnext = (r+1)^2
....: ocur = (rnext-r)-ocur
sage: g.show(xmin=-(paths+1)^2, xmax=(paths+1)^2, ymin=-(paths+1)^2, ymax=(paths+1)^2, figsize=[6,6])
sage: g.show(xmin=-(paths+1)^2, xmax=(paths+1)^2,
....: ymin=-(paths+1)^2, ymax=(paths+1)^2, figsize=[6,6])

.. PLOT::

Expand Down Expand Up @@ -358,7 +363,8 @@ def circle(center, radius, **options):

And circles with legends::

sage: circle((4,5), 1, rgbcolor='yellow', fill=True, legend_label='the sun').show(xmin=0, ymin=0)
sage: circle((4,5), 1, rgbcolor='yellow', fill=True,
....: legend_label='the sun').show(xmin=0, ymin=0)

.. PLOT::

Expand All @@ -368,7 +374,8 @@ def circle(center, radius, **options):

::

sage: circle((4,5), 1, legend_label='the sun', legend_color='yellow').show(xmin=0, ymin=0)
sage: circle((4,5), 1,
....: legend_label='the sun', legend_color='yellow').show(xmin=0, ymin=0)

.. PLOT::

Expand All @@ -378,12 +385,12 @@ def circle(center, radius, **options):

Extra options will get passed on to show(), as long as they are valid::

sage: circle((0, 0), 2, figsize=[10,10]) # That circle is huge!
sage: circle((0, 0), 2, figsize=[10,10]) # That circle is huge!
Graphics object consisting of 1 graphics primitive

::

sage: circle((0, 0), 2).show(figsize=[10,10]) # These are equivalent
sage: circle((0, 0), 2).show(figsize=[10,10]) # These are equivalent

TESTS:

Expand Down
2 changes: 1 addition & 1 deletion src/sage/plot/colors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# sage.doctest: needs sage.plot
r"""
Colors

Expand Down
Loading