Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#17 rater.py: division by Zero

closed
Andre Wobst
None
5
2012-10-16
2004-06-22
Marko Vendelin
No

I would like to report a bug (or rather strange feature
:) ) in
pyx/graph/axis/rater.py. If I specify limits of axis
equal to [12.5 to 1050] then pyx crashes somewhere in
rater.py:


Example program:

from pyx import *

g = graph.graphxy(height=8, width=8,
x=graph.axis.linear(min=12.5,
max=1050, title=r"\large{X}"),
y=graph.axis.linear(title=r"\large{Y}") )

g.plot( graph.data.list( [[0, 50], [10, 50]],
addlinenumbers=0, x=0, y=1),

graph.style.line(lineattrs=[style.linewidth.thick,style.linecap.round])
)

g.writetofile("test.eps")


Output:

Traceback (most recent call last):
File "test.py", line 10, in ?
g.writetofile("test.eps")
File
"/home/markov/python/graphics/PyX-0.6.3/pyx/canvas.py",
line 533,
in writetofile
self.writeEPSfile(filename, args, *kwargs)
File
"/home/markov/python/graphics/PyX-0.6.3/pyx/canvas.py",
line 367,
in writeEPSfile
abbox = bbox is not None and bbox or self.bbox()
File
"/home/markov/python/graphics/PyX-0.6.3/pyx/graph/graph.py",
line
418, in bbox
self.finish()
File
"/home/markov/python/graphics/PyX-0.6.3/pyx/graph/graph.py",
line
368, in finish
self.domethods0
File
"/home/markov/python/graphics/PyX-0.6.3/pyx/graph/graph.py",
line
310, in dolayout
axis.finish(self.axespos[key])
File
"/home/markov/python/graphics/PyX-0.6.3/pyx/graph/axis/axis.py",
line 313, in finish
newrate = self.rater.rateticks(self, newticks,
self.density)
File "/home/markov/python/pyx/graph/axis/rater.py",
line 193, in
rateticks
return rate/weight
ZeroDivisionError: integer division or modulo by zero

cheers,

Marko

Discussion

  • Andre Wobst
    Andre Wobst
    2004-06-29

    Logged In: YES
    user_id=405853

    Thanks for reporting this issue and sorry for my late response. The
    problem is, that a partitioner might return an empty list of ticks but was
    not considered in the code. This behaviour of the partitioner is also
    beyond to be changed. Its also interesting to see your example, where
    you step into that problem even for the default parameters of the
    automatic linear partitioner.

    To solve the problem at least the axis need to take care of this special
    case. (While the axis must take care of it, the rater might not even be
    asked for such a case.) A patch is enclosed. Note, that you will get an
    error from the partitioner for the y axis in your example, but this is due
    to the y range from 50 to 50. I do not consider this later issue to be a
    bug.

     
  • Andre Wobst
    Andre Wobst
    2004-06-29

     
    Attachments