Opened 11 years ago

Closed 10 years ago

#10478 closed enhancement (fixed)

line() does not accept iterators

Reported by: ddrake Owned by: jason, was
Priority: major Milestone: sage-4.6.2
Component: graphics Keywords: line plot iterator
Cc: Merged in: sage-4.6.2.alpha1
Authors: Dan Drake Reviewers: Robert Bradshaw
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The line() function fails when given an iterator:

sage: line(iter([(0,0), (1,0), (2,2)]))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[...]
/opt/sage/local/lib/python2.6/site-packages/sage/plot/plot.pyc in xydata_from_point_list(points)
   2529             pass
   2530     
-> 2531     if len(points)>0 and len(list(points[0]))!=2:
   2532         raise ValueError, "points must have 2 coordinates in a 2d line"
   2533 

TypeError: object of type 'listiterator' has no len()

Attachments (1)

trac_10478.patch (3.4 KB) - added by ddrake 10 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 11 years ago by ddrake

Here's a patch which corrects the problem, but on my test machine, I'm getting doctest errors in shapes2.py just like those reported at #9088:

sage -t  "devel/sage-hack/sage/plot/plot3d/shapes2.py"      
**********************************************************************
File "/home/drake/s/sage-4.6.1.alpha3/devel/sage-hack/sage/plot/plot3d/shapes2.py", line 706:
    sage: P.tachyon_repr(P.default_render_params())
Expected:
    'Sphere center 1.0 2.0 3.0 Rad 0.015 texture85'
Got:
    'Sphere center 1.0 2.0 3.0 Rad 0.015 texture139'
**********************************************************************
File "/home/drake/s/sage-4.6.1.alpha3/devel/sage-hack/sage/plot/plot3d/shapes2.py", line 723:
    sage: P.obj_repr(P.default_render_params())[0][0:2]
Expected:
    ['g obj_1', 'usemtl texture87']
Got:
    ['g obj_1', 'usemtl texture141']
**********************************************************************
File "/home/drake/s/sage-4.6.1.alpha3/devel/sage-hack/sage/plot/plot3d/shapes2.py", line 831:
    sage: L.tachyon_repr(L.default_render_params())[0]
Expected:
    'FCylinder base 1.0 0.0 0.0 apex 0.999950000417 0.00999983333417 0.0001 rad 0.005 texture127'
Got:
    'FCylinder base 1.0 0.0 0.0 apex 0.999950000417 0.00999983333417 0.0001 rad 0.005 texture181'
**********************************************************************

That ticket got merged and it doesn't look like anyone fixed those doctests, but they haven't been failing...so I'm not sure what's going on.

comment:2 Changed 11 years ago by ddrake

  • Authors set to Dan Drake
  • Status changed from new to needs_review

I'm marking this as "needs review" because it is ready for review -- I hope someone can explain the above test failures so I can fix them.

comment:3 Changed 11 years ago by robertwb

The doctest failures are due to an internal counter used for uniqification. You can just change them to the new output, or "texture..."

Changed 10 years ago by ddrake

comment:4 Changed 10 years ago by ddrake

New patch up; I just used the new values for the textures to fix the doctests. Please review.

comment:5 Changed 10 years ago by robertwb

  • Status changed from needs_review to positive_review

Looks good to me.

comment:6 Changed 10 years ago by jdemeyer

  • Type changed from defect to enhancement

comment:7 Changed 10 years ago by jdemeyer

  • Reviewers set to Robert Bradshaw

comment:8 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.6.2.alpha1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.