On Tue, Apr 5, 2011 at 7:02 PM, Christopher Barker <chris.bar...@noaa.gov> wrote: > HI folks, > > What's the fastest way to convert a numpy array to tuples? > > Unfortunately, not all packages take arbitrary sequences when they are > expecting a list of tuples. In this case, I'm using PIL's ImageDraw, and > want to do: > > draw.line(points) > > (points is an Nx2 numpy array of ints) > > but if I pass in an array, I get, oddly enough, nothing. NO error, just > nothing drawn. > > if I do: > > draw.line(points.tolist()) > > SystemError: new style getargs format but argument is not a tuple > > So I seem to need tuples. This works: > > draw.line([tuple(p) for p in points.tolist()]) > > but that seems like it would be slower than it should be (to be honest, > not profiled). > > Is there a faster way? > > Maybe numpy should have a ndarray.totuple() method. > > -Chris > How about fixing PIL... I know that there is not a good track record of getting patches into PIL , but did you get to the bottom of it and find how draw.line is implemented? BTW, is it drawing anti-aliased lines ?
- Sebastian Haase _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion