Should Path objects have an initial MOVETO? (was: error with basemap and pdf)

Jeff Whitaker <jswhit@...196...> writes:

Jouni: That test script now crashes with:

  File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py",
line 1214, in pathOperations
    raise ValueError, 'Path lacks initial MOVETO'
ValueError: Path lacks initial MOVETO

I think this confirms my suspicion that the bug is really elsewhere. A
path in PDF needs to begin with a "m" that sets the initial point, and
that particular Path object only consisted of one LINETO operation. Am I
correct in thinking that this is an invalid path?

I'm not too familiar with Path (and I'm terribly busy today) but I think
the way to catch this bug is to add a sanity check to Path, similar to
the check in the pdf backend that produces that error. Then the
traceback would show what code is creating the invalid path -- the
traceback from the backend is too late in the execution to tell us that.

···

--
Jouni K. Seppänen

Jouni K. Seppänen wrote:

Jeff Whitaker <jswhit@...196...> writes:

Jouni: That test script now crashes with:

  File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py", line 1214, in pathOperations
    raise ValueError, 'Path lacks initial MOVETO'
ValueError: Path lacks initial MOVETO
    
I think this confirms my suspicion that the bug is really elsewhere. A
path in PDF needs to begin with a "m" that sets the initial point, and
that particular Path object only consisted of one LINETO operation. Am I
correct in thinking that this is an invalid path?
  

Yes -- that path should be considered invalid, though the Path class doesn't do any verification. I'll add this. I'm surprised that it's coming from the line class, which in general doesn't allow for customization of the path codes. There must be something unanticipated happening.

Cheers,
Mike

···

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

The bug was actually in the path simplification. In really degenerate cases (bravo for finding it) of paths that are completely outside of the clip region, it would create a path with a single LINETO command.

This is now fixed in SVN on the branch and trunk.

Mike

Michael Droettboom wrote:

···

Jouni K. Seppänen wrote:
  

Jeff Whitaker <jswhit@...196...> writes:

Jouni: That test script now crashes with:

  File "/Users/jwhitaker/lib/python/matplotlib/backends/backend_pdf.py", line 1214, in pathOperations
    raise ValueError, 'Path lacks initial MOVETO'
ValueError: Path lacks initial MOVETO
    

I think this confirms my suspicion that the bug is really elsewhere. A
path in PDF needs to begin with a "m" that sets the initial point, and
that particular Path object only consisted of one LINETO operation. Am I
correct in thinking that this is an invalid path?
  

Yes -- that path should be considered invalid, though the Path class doesn't do any verification. I'll add this. I'm surprised that it's coming from the line class, which in general doesn't allow for customization of the path codes. There must be something unanticipated happening.

Cheers,
Mike

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA