On Friday 16 January 2009, Eric Firing wrote:
> Neal Becker wrote:
> >     pylab.plot (xaxis, log10 (the_sum)*10)
> > where xaxis is numpy array, and log10(the_sum)*10 is my own class that is
> > a valid python sequence (it is a c++ wrapper around boost::ublas), gives:
> > File "/usr/lib/python2.5/site-packages/matplotlib-0.98.5.2-py2.5-linux-
> > x86_64.egg/matplotlib/pyplot.py", line 2096, in plot
> >     ret =  gca().plot(*args, **kwargs)
> >   File "/usr/lib/python2.5/site-packages/matplotlib-0.98.5.2-py2.5-linux-
> > x86_64.egg/matplotlib/axes.py", line 3277, in plot
> >     for line in self._get_lines(*args, **kwargs):
> >   File "/usr/lib/python2.5/site-packages/matplotlib-0.98.5.2-py2.5-linux-
> > x86_64.egg/matplotlib/axes.py", line 394, in _grab_next_args
> >     for seg in self._plot_2_args(remaining, **kwargs):
> >   File "/usr/lib/python2.5/site-packages/matplotlib-0.98.5.2-py2.5-linux-
> > x86_64.egg/matplotlib/axes.py", line 267, in _plot_2_args
> >     if is_string_like(tup2[1]):
> >   File "/usr/lib/python2.5/site-packages/matplotlib-0.98.5.2-py2.5-linux-
> > x86_64.egg/matplotlib/cbook.py", line 277, in is_string_like
> >     try: obj + ''
> > RuntimeError: check:: failed
> >
> > If I convert the 2nd arg to array, it works:
> >    pylab.plot (xaxis, np.array(log10 (the_sum)*10))
> >
> > Doesn't plot support arbitrary sequences?
>
> Not *completely* arbitrary, evidently.  It has to raise a Python
> exception when an invalid operation (specifically, adding an empty
> string) is attempted.  Apparently your wrapper is not doing this.  This
> is the duck-typing check for a string that mpl has used from early times.
>
> Eric
Is it possible that this could be better?  I'm not sure what's happening here, 
but I think it is trying to see if my type can be a string first.  It can, but 
that's not a good idea in this case.  It should correctly support a sequence 
(and iterator) protocol.  Shouldn't matplotlib try that first?


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to