Gregory H. Ball - 2000-03-19

Hi.

I submitted three trivial patches for bugs I found.

First bug:
>>> import graphite
>>> l=graphite.LineStyle(width=0.1)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "primitive.py", line 50, in __init__
    self.width = width
  File "property.py", line 247, in __setattr__
    raise ValueError, val
ValueError: value 0 out of range (0 to 10)

The property type "width" is currently an IntProperty.  Comments suggest the minimum value is 0.1,
so I changed it to a FloatProperty.  (Change made in __init__ method of class LineStyle, in primitive.py.

Second bug:
>>> import graphite
>>> g=graphite.Graph()
>>> g.axes[0].range[0]=0
>>> g.axes[0].range
[0, 'AUTO']
>>> g.axes[1].range
[0, 'AUTO']
>>> g.axes[2].range
[0, 'AUTO']

The Axis object's default range property is currently shared between all instances, so if you assign by indexing you get unwanted effects.  This can be worked around by assigning a new list to the whole property,  instead of indexing, but is easily fixed by having the Axis object make a copy of the default range object in its constructor.  (Change made in __init__ method of class Axis, in graphite.py)

Third bug:
>>> import graphite
>>> g=graphite.Graph()
>>> g.datasets.append(graphite.Dataset([(1,1),(2,2)]))
>>> g.axes[0].logbase=10.
>>> graphite.genOutput(g,'PS')
magnitude =  -1.0self._actualRange =  [0, 2.1]
_actualSpacing =  0.1
magnitude =  -1.0
self._actualRange =  [0, 2.1]
_actualSpacing =  0.1
magnitude =  -1.0
self._actualRange =  [0, 1.1]
_actualSpacing =  0.1
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "utility.py", line 75, in genOutput
    graph.draw(canvas)
  File "graphite.py", line 888, in draw
    self.submit(primitives)
  File "graphite.py", line 1030, in submit
    dataTrans = self.getDataTrans(i)
  File "graphite.py", line 965, in getDataTrans
    lineartrans = Numeric.array( \   File "graphite.py", line 567, in logscale
    return 1.0/(log(self.range[1],self.logbase) - log(self.actualRange()[0],self.logbase))
  File "graphite.py", line 121, in log
    return math.log(num)/math.log(base)
TypeError: illegal argument type for built-in operation

The culprit is line 567 of graphite.py, where we take  log('AUTO').
Inspecting this line we can see that the lower limit has already been fixed by replacing self.range by self.actualRange().
I just repeated this for the upper limit.  This could possibly be done more efficiently by calling self.actualRange only once, but it probably doesn't matter.
(Change made to logscale method of class Axis, in graphite.py)

Greg Ball