Hi,
On Mon, 29 Nov 2004, Joerg Lehmann wrote:
> Hi Arnd,
>
> On 28.11.04, Arnd Baecker wrote:
> > I encountered the problem that files
> > with comments are not read properly
> > (anymore ?, PyX 0.7, debian package).
> >
> > This example demonstrates the problem
> >
> > ############################
> > from pyx import *
> > from pyx.graph import graphxy
> > from pyx.graph.axis import linear
> >
> >
> > fp=open("test.dat","w")
> > fp.write("# test commentOK\n")
> > #fp.write("# test comment fails\n") # uncomment this to see the problem
> > fp.write("0.0 0.0\n")
> > fp.write("1.0 3.0\n")
> > fp.write("2.0 1.0\n")
> > fp.close()
> >
> > c = canvas.canvas()
> > g = graphxy(width=6,height=4,
> > x=linear(min=-1.0, max=3.0),
> > y=linear(min=-1.0, max=3.0) )
> > g.plot(graph.data.file("test.dat",x=1,y=2))
> > c.insert(g)
> >
> > c.writeEPSfile("test.eps",paperformat="A4")
> > #############################
> >
> > Uncommenting the one line I get:
> > ValueError: column number bigger than number of columns
> > ValueError: column number bigger than number of columns
> >
> > Somehow it seems that the number of space separated elements
> > is taken to determine the number of columns, even
> > within comments.
> >
> > I think the problem was not present with the previous version.
>
> Are you sure? I think this behaviour is already present in older PyX
> versions.
I just checked it on a different machine with 0.6.3.
No problems with the example above.
> The problem is that the last comment before the first real
> data line is used by PyX as keys for the various columns. In your case
> (when commenting the problematic line in), there are three keys for only
> two columns, which leads to the error.
Interesting - thanks for the explanation
and indeed the doc for 0.7 does contain
a detailed explanation on this ;-).
> Maybe PyX should be a bit more tolerant here or give at least more
> information about what the real problem is.
Personally I'd think that a switch to turn the interpretation
as keys off would be useful.
(I have quite a few data files lying around which
don't adhere to the PyX convention).
> > P.S.: it seems that the translatablecanvas.py you (=Andre)
> > sent to me at the end of August does not work anymore:
> >
> > In [2]: import translateablecanvas
> > ---------------------------------------------------------------------------
> > AttributeError Traceback (most recent call
> > last)
> >
> > ---> 76 class ref(base.PSCmd):
> >
> > AttributeError: 'module' object has no attribute 'PSCmd'
>
> base.PSCmd does no longer exist, use base.canvasitem instead.
Thanks - so now I can import the translateablecanvas
again, but calling it via
s=translateablecanvas.translateablecanvas()
s.fill(path.circle(0, 0, 0.035))
g.plot(graph.data.file("../Daten/limacon_orbits_regular2_.dat",
x=1,y=2),
[ translateablecanvas.insertstyle(s) ])
results in
446 def donedrawpoints(self, privatedata, sharedata, graph):
TypeError: 'translateablecanvas' object is not callable
> /usr/lib/python2.3/site-packages/pyx/graph/style.py(444)drawpoint()
-> privatedata.symbol(privatedata.symbolcanvas, xpos, ypos,
privatedata.size_pt, privatedata.symbolattrs)
Presumably I am missing something simple here
(or translateablecanvas.py is not fully adapted for 0.7 yet ;-(...)
Many thanks,
Arnd
|