# Ticket #10948: trac_10948_point3d-sl.patch

File trac_10948_point3d-sl.patch, 2.1 KB (added by slabbe, 8 years ago)
• ## sage/plot/plot3d/shapes2.py

```# HG changeset patch
# User Sebastien Labbe <slabqc at gmail.com>
# Date 1300308736 14400
# Node ID 2ee27b88384e32839c9a921e62d09315928aeb74
# Parent  7692a0902797e202f3226a02bdd8d4d00b5e3169
#10948: Calling point on an iterator of 3d points raises an AttributeError

diff --git a/sage/plot/plot3d/shapes2.py b/sage/plot/plot3d/shapes2.py```
 a def point3d(v, size=5, **kwds): We check to make sure the options work:: sage: point3d((4,3,2),size=20,color='red',opacity=.5) TESTS:: sage: point3d([]) sage: point3d(iter([])) sage: point3d((i,i,i) for i in range(10)) """ if (isinstance(v,(list,tuple)) or is_Vector(v)) and len(v) == 3 and not (isinstance(v[0],(list,tuple)) or is_Vector(v[0])): return Point(v, size, **kwds) else: A = sum([Point(z, size, **kwds) for z in v]) from sage.plot.plot3d.base import Graphics3d A = sum([Point(z, size, **kwds) for z in v], Graphics3d()) A._set_extra_kwds(kwds) return A
• ## sage/plot/point.py

`diff --git a/sage/plot/point.py b/sage/plot/point.py`
 a TESTS:: #                  http://www.gnu.org/licenses/ #***************************************************************************** from sage.misc.decorators import options, rename_keyword from sage.misc.misc import is_iterator from sage.plot.colors import to_mpl_color from sage.plot.primitive import GraphicPrimitive_xydata def point(points, **kwds): sage: point([(cos(theta), sin(theta)) for theta in srange(0, 2*pi, pi/8)], frame=True) sage: point([(cos(theta), sin(theta)) for theta in srange(0, 2*pi, pi/8)]).show(frame=True) # These are equivalent Also works for iterator input (trac: #10948):: sage: point((i,i,i) for i in range(10)) TESTS:: sage: point(iter([])) """ if is_iterator(points): points = list(points) try: return point2d(points, **kwds) except (ValueError, TypeError):