On Thu, Jul 17, 2008 at 2:44 PM, David M. Kaplan <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I committed to svn (revision 5782) a version of the patch for clabel and
> waitforbuttonpress.  I haven't perfected label rotation yet, but it
> works at the moment.  I also haven't yet followed Paul Kienzle's
> suggestions (though I think they are a good idea), as I wanted to get a
> bit more information in relation to one of Gael's comments below.

Just reading through the blocking_inpu with comments mostly unrelated
to those you are raising here, and I was just reading for style rather
than logic.  Some of this stuff may not be your code but here is what
I found:

    def __init__(self, fig, eventslist=()):
        self.fig = fig
        assert isinstance(eventslist, tuple), "Requires a tuple of
event name strings"
        self.eventslist = eventslist

It is rarely necessary to require *a tuple* though in some cases it
might be.  Wouldn't a list work here?  We use duck typing in mpl:  eg
if you want to make sure the input is iterable and it contains strings

  import matplotlib.cbook

  if not cbook.iterable(eventslist):
      raise ValueError('events list must be iterable')

  if cbook.is_string_like(eventslist):
      raise ValueError('eventslist cannot be a string')

  for event in eventslist:
      if not cbook.is_string_like(event):
          raise ValueError('events list must be a list of strings')


I would probably write a cbook method is_sequence_of_strings and just
call that since it will be more readable and reusable...

I notice there are some residual print statements in the code -- these
should be replaced by the verbose handler in matplotlib/__init__.py,
eg in

                if timeout > 0 and counter > timeout/0.01:
                    print "Timeout reached";
                    break;

and
            if self.verbose:
                print "input %i: %f,%f" % (len(self.clicks),
                                    event.xdata, event.ydata)

and others in contour.py

You can replace these with

  import matplotlib
  matplotlib.verbose.report('something')

and

  matplotlib.verbose.report('some nitty gritty details', 'debug')

There should be no prints in mpl.

In contour.py, we have

        xmax = np.amax(np.array(linecontour)[:,0])
        xmin = np.amin(np.array(linecontour)[:,0])
        ymax = np.amax(np.array(linecontour)[:,1])
        ymin = np.amin(np.array(linecontour)[:,1])


which needlessly repears the array creation.  I would create it once
and reuse it.

That's all for now.  Thanks.

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to