Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
make srange an iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Aug 18, 2021
1 parent 7282b2b commit efc3d67
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/sage/arith/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@
LCM = lcm

from .srange import xsrange, srange, ellipsis_iter, ellipsis_range
sxrange = xsrange

σ = sigma
2 changes: 1 addition & 1 deletion src/sage/arith/srange.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def srange(*args, **kwds):
sage: srange(10^5) == list(range(10^5))
True
"""
return [x for x in xsrange(*args, **kwds)]
return xsrange(*args, **kwds)


def ellipsis_iter(*args, step=None):
Expand Down
14 changes: 7 additions & 7 deletions src/sage/plot/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
The sine function::
sage: sines = [plot(c*sin(x), (-2*pi,2*pi), color=Color(c,0,0), ymin=-1, ymax=1) for c in sxrange(0,1,.2)]
sage: sines = [plot(c*sin(x), (-2*pi,2*pi), color=Color(c,0,0), ymin=-1, ymax=1) for c in srange(0,1,.2)]
sage: a = animate(sines)
sage: a # optional -- ImageMagick
Animation with 5 frames
Expand All @@ -47,7 +47,7 @@
An animated :class:`sage.plot.multigraphics.GraphicsArray` of rotating ellipses::
sage: E = animate((graphics_array([[ellipse((0,0),a,b,angle=t,xmin=-3,xmax=3)+circle((0,0),3,color='blue') for a in range(1,3)] for b in range(2,4)]) for t in sxrange(0,pi/4,.15)))
sage: E = animate((graphics_array([[ellipse((0,0),a,b,angle=t,xmin=-3,xmax=3)+circle((0,0),3,color='blue') for a in range(1,3)] for b in range(2,4)]) for t in srange(0,pi/4,.15)))
sage: str(E) # animations produced from a generator do not have a known length
'Animation with unknown number of frames'
sage: E.show() # optional -- ImageMagick
Expand All @@ -65,7 +65,7 @@
(s, t)
sage: def sphere_and_plane(x):
....: return sphere((0,0,0),1,color='red',opacity=.5)+parametric_plot3d([t,x,s],(s,-1,1),(t,-1,1),color='green',opacity=.7)
sage: sp = animate([sphere_and_plane(x) for x in sxrange(-1,1,.3)])
sage: sp = animate([sphere_and_plane(x) for x in srange(-1,1,.3)])
sage: sp[0] # first frame
Graphics3d Object
sage: sp[-1] # last frame
Expand All @@ -86,7 +86,7 @@
illustrated by the following example::
sage: t = var('t')
sage: a = animate((sin(c*pi*t) for c in sxrange(1,2,.2)))
sage: a = animate((sin(c*pi*t) for c in srange(1,2,.2)))
sage: a.show() # optional -- ImageMagick
Expand Down Expand Up @@ -134,7 +134,7 @@ def animate(frames, **kwds):
EXAMPLES::
sage: t = var('t')
sage: a = animate((cos(c*pi*t) for c in sxrange(1,2,.2)))
sage: a = animate((cos(c*pi*t) for c in srange(1,2,.2)))
sage: a.show() # optional -- ImageMagick
See also :mod:`sage.plot.animate` for more examples.
Expand Down Expand Up @@ -207,7 +207,7 @@ class Animation(WithEqualityById, SageObject):
Do not convert input iterator to a list, but ensure that
the frame count is known after rendering the frames::
sage: a = animate((plot(x^p, (x,0,2)) for p in sxrange(1,2,.1)))
sage: a = animate((plot(x^p, (x,0,2)) for p in srange(1,2,.1)))
sage: str(a)
'Animation with unknown number of frames'
sage: a.png() # long time
Expand Down Expand Up @@ -504,7 +504,7 @@ def graphics_array(self, ncols=3):
Frames can be specified as a generator too; it is internally converted to a list::
sage: t = var('t')
sage: b = animate((plot(sin(c*pi*t)) for c in sxrange(1,2,.2)))
sage: b = animate((plot(sin(c*pi*t)) for c in srange(1,2,.2)))
sage: g = b.graphics_array()
sage: g
Graphics Array of size 2 x 3
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/real_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2145,9 +2145,9 @@ cdef class RealDoubleElement(FieldElement):
....: return False
sage: all( check_error(2^x) for x in range(-100,100) )
True
sage: all( check_error(x) for x in sxrange(0.01, 2.00, 0.01) )
sage: all( check_error(x) for x in srange(0.01, 2.00, 0.01) )
True
sage: all( check_error(x) for x in sxrange(0.99, 1.01, 0.001) )
sage: all( check_error(x) for x in srange(0.99, 1.01, 0.001) )
True
sage: RDF(1.000000001).log()
1.000000082240371e-09
Expand Down

0 comments on commit efc3d67

Please sign in to comment.