Hi,
Can anyone tell me why the following short program sometimes succeeds,
and sometimes fails with the following error? (For readability I have
changed all occurences of
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages"
to "...")
Traceback (most recent call last):
File "chaos.py", line 28, in <module>
main()
File "chaos.py", line 22, in main
(x, y) = l.at(0.5 * l.arclen())
File ".../pyx/path.py", line 1009, in at
return self.normpath().at(params)
File ".../pyx/normpath.py", line 1418, in wrappedmethod
return method(self, [valueorlist], *args, **kwargs)[0]
File ".../pyx/normpath.py", line 1569, in at
for x_pt, y_pt in self._at_pt(self._convertparams(params,
self.arclentoparam))]
File ".../pyx/normpath.py", line 1479, in _convertparams
for i, param in zip(convertparamindices, convertmethod(converttoparams)):
File ".../pyx/normpath.py", line 1419, in wrappedmethod
return method(self, valueorlist, *args, **kwargs)
File ".../pyx/normpath.py", line 1550, in arclentoparam
return self._arclentoparam_pt([unit.topt(l) for l in lengths])
File ".../pyx/normpath.py", line 1536, in _arclentoparam_pt
results[i] = normpathparam(self, normsubpathindex, params[i])
File ".../pyx/normpath.py", line 1354, in __init__
float(normsubpathparam)
TypeError: float() argument must be a string or a number
Thanks for any insight,
Hamish
#### chaos.py ####
from pyx import *
import math, random
def main():
r = 10
z = path.circle(0, 0, r)
(c1x, c1y) = z.at(r * math.pi * 3 / 6)
(c2x, c2y) = z.at(r * math.pi * 7 / 6)
(c3x, c3y) = z.at(r * math.pi * 11 / 6)
x, y = c1x, c1y
c = canvas.canvas()
d = [0, 0, 1, 1, 2]
for i in range(10000):
w = d[int(len(d) * random.random())]
cx, cy = [(c1x, c1y), (c2x, c2y), (c3x, c3y)][w]
l = path.line(x, y, cx, cy)
(x, y) = l.at(0.5 * l.arclen())
c.stroke(path.circle(x, y, 0.01))
c.writePDFfile('chaos.pdf')
if __name__ == '__main__':
main()
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user